PicoCreator / smol-dev-js

Smol personal AI, for smol incremental tasks in a JS project
MIT License
322 stars 52 forks source link

fetch is not defined #12

Closed glennfu closed 1 year ago

glennfu commented 1 year ago

I'm using node -v v14.19.0. I tried to run this in my project and got the following:

## Unable to handle prompt for ...
{"model":"gpt-4","temperature":0,"max_tokens":7905,"top_p":1,"frequency_penalty":0,"presence_penalty":0,"messages":[{"role":"system","content":"You are an assistant, who can only reply in JSON object, reply with a yes (in a param named 'reply') if you understand"},{"role":"assistant","content":"{\"reply\":\"yes\"}"},{"role":"user","content":"[object Object]\n[object Object]\n[object Object]\n[object Object]\n[object Object]"}]}
## Recieved error ...
ReferenceError: fetch is not defined

I checked out the project and added const fetch = require('node-fetch'); to the top of ai-bridge/src/openai/getChatCompletion.js and it solved it for me.

varun508 commented 1 year ago

But it gives this error 🐣 [ai]: Unexpected event processing error TypeError: resp.body.getReader is not a function

PicoCreator commented 1 year ago

You should update to node 18 LTS, which includes native fetch implementation