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,3 +1,4 @@
import fetch from 'node-fetch'
import { Tool } from 'langchain/tools'
export const desc = `A portal to the internet. Use this when you need to get specific content from a website.
@@ -31,11 +32,14 @@ export class RequestsGetTool extends Tool {
/** @ignore */
async _call(input: string) {
const inputUrl = this.url ?? input
const inputUrl = !this.url ? input : this.url
if (process.env.DEBUG === 'true') console.info(`Making GET API call to ${inputUrl}`)
const res = await fetch(inputUrl, {
headers: this.headers
})
const text = await res.text()
return text.slice(0, this.maxOutputLength)
}
@@ -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) {
+2 -1
View File
@@ -33,13 +33,14 @@
"linkifyjs": "^4.1.1",
"mammoth": "^1.5.1",
"moment": "^2.29.3",
"node-fetch": "2",
"node-fetch": "^2.6.11",
"pdf-parse": "^1.1.1",
"weaviate-ts-client": "^1.1.0",
"ws": "^8.9.0"
},
"devDependencies": {
"@types/gulp": "4.0.9",
"@types/node-fetch": "2.6.2",
"@types/ws": "^8.5.3",
"gulp": "^4.0.2",
"typescript": "^4.8.4"