fix build error

This commit is contained in:
Henry
2023-05-23 01:48:03 +01:00
parent aac9160a9f
commit 738e3d9356
4 changed files with 236 additions and 153 deletions
@@ -1,4 +1,5 @@
import { Tool } from 'langchain/tools'
import fetch from 'node-fetch'
export const desc = `Use this when you want to POST to a website.
Input should be a json string with two keys: "url" and "data".
@@ -53,12 +54,15 @@ export class RequestsPostTool extends Tool {
inputUrl = url
inputBody = data
}
if (process.env.DEBUG === 'true') console.info(`Making POST API call to ${inputUrl} with body ${JSON.stringify(inputBody)}`)
const res = await fetch(inputUrl, {
method: 'POST',
headers: this.headers,
body: JSON.stringify(inputBody)
})
const text = await res.text()
return text.slice(0, this.maxOutputLength)
} catch (error) {