(documents: string, llm: BaseLanguageModel, headers: string, urlPrompt: string, ansPrompt: string)
| 108 | } |
| 109 | |
| 110 | const getAPIChain = async (documents: string, llm: BaseLanguageModel, headers: string, urlPrompt: string, ansPrompt: string) => { |
| 111 | const apiUrlPrompt = new PromptTemplate({ |
| 112 | inputVariables: ['api_docs', 'question'], |
| 113 | template: urlPrompt ? urlPrompt : API_URL_RAW_PROMPT_TEMPLATE |
| 114 | }) |
| 115 | |
| 116 | const apiResponsePrompt = new PromptTemplate({ |
| 117 | inputVariables: ['api_docs', 'question', 'api_url_body', 'api_response'], |
| 118 | template: ansPrompt ? ansPrompt : API_RESPONSE_RAW_PROMPT_TEMPLATE |
| 119 | }) |
| 120 | |
| 121 | const chain = APIChain.fromLLMAndAPIDocs(llm, documents, { |
| 122 | apiUrlPrompt, |
| 123 | apiResponsePrompt, |
| 124 | verbose: process.env.DEBUG === 'true' ? true : false, |
| 125 | headers: typeof headers === 'object' ? headers : headers ? JSON.parse(headers) : {} |
| 126 | }) |
| 127 | return chain |
| 128 | } |
| 129 | |
| 130 | module.exports = { nodeClass: POSTApiChain_Chains } |
no test coverage detected