(documents: string, llm: BaseLanguageModel, headers: string, urlPrompt: string, ansPrompt: string)
| 118 | } |
| 119 | |
| 120 | const getAPIChain = async (documents: string, llm: BaseLanguageModel, headers: string, urlPrompt: string, ansPrompt: string) => { |
| 121 | const apiUrlPrompt = new PromptTemplate({ |
| 122 | inputVariables: ['api_docs', 'question'], |
| 123 | template: urlPrompt ? urlPrompt : API_URL_RAW_PROMPT_TEMPLATE |
| 124 | }) |
| 125 | |
| 126 | const apiResponsePrompt = new PromptTemplate({ |
| 127 | inputVariables: ['api_docs', 'question', 'api_url', 'api_response'], |
| 128 | template: ansPrompt ? ansPrompt : API_RESPONSE_RAW_PROMPT_TEMPLATE |
| 129 | }) |
| 130 | |
| 131 | const chain = APIChain.fromLLMAndAPIDocs(llm, documents, { |
| 132 | apiUrlPrompt, |
| 133 | apiResponsePrompt, |
| 134 | verbose: process.env.DEBUG === 'true' ? true : false, |
| 135 | headers: typeof headers === 'object' ? headers : headers ? JSON.parse(headers) : {} |
| 136 | }) |
| 137 | return chain |
| 138 | } |
| 139 | |
| 140 | module.exports = { nodeClass: GETApiChain_Chains } |
no test coverage detected