@ignore
(values: ChainValues, runManager?: CallbackManagerForChainRun)
| 85 | |
| 86 | /** @ignore */ |
| 87 | async _call(values: ChainValues, runManager?: CallbackManagerForChainRun): Promise<ChainValues> { |
| 88 | try { |
| 89 | const question: string = values[this.inputKey] |
| 90 | |
| 91 | const api_url_body = await this.apiRequestChain.predict({ question, api_docs: this.apiDocs }, runManager?.getChild()) |
| 92 | |
| 93 | const { url, data } = JSON.parse(api_url_body) |
| 94 | |
| 95 | const res = await secureFetch(url, { |
| 96 | method: 'POST', |
| 97 | headers: this.headers, |
| 98 | body: JSON.stringify(data) |
| 99 | }) |
| 100 | |
| 101 | const api_response = await res.text() |
| 102 | |
| 103 | const answer = await this.apiAnswerChain.predict( |
| 104 | { question, api_docs: this.apiDocs, api_url_body, api_response }, |
| 105 | runManager?.getChild() |
| 106 | ) |
| 107 | |
| 108 | return { [this.outputKey]: answer } |
| 109 | } catch (error) { |
| 110 | return { [this.outputKey]: error } |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | _chainType() { |
| 115 | return 'api_chain' as const |
nothing calls this directly
no test coverage detected