Open asifmai opened 9 months ago
I'm having the same problem from yesterday night. Any solution please?
+1
Any luck finding a solution? This started happening around same time OpenAI reported possible DDoD attack. Could they have shut won something streamed-gpt was using?
Any luck finding a solution? This started happening around same time OpenAI reported possible DDoD attack. Could they have shut won something streamed-gpt was using?
With some research I noticed that the latest OpenAI API V4 update changed the way streamed answers come from the API endpoint. No longer it is needed to parse the response which makes this package obsolete. Now listening to stream is as easy as follows:
`import OpenAI from "openai";
const openai = new OpenAI();
const completion = await openai.chat.completions.create({ model: "gpt-3.5-turbo", messages: [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"} ], stream: true, });
for await (const chunk of completion) { console.log(chunk.choices[0].delta.content); } }
`
You rock. Thanks @GuiriDelNorte
Describe the bug I am getting the following error:
Error reading stream: SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) at /Volumes/Work/Web Development Current/UAskMe/uaskme-backend/node_modules/streamed-chatgpt-api/index.js:14:38 at processStream (/Volumes/Work/Web Development Current/UAskMe/uaskme-backend/node_modules/streamed-chatgpt-api/index.js:128:17) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async fetchStreamedChat (/Volumes/Work/Web Development Current/UAskMe/uaskme-backend/node_modules/streamed-chatgpt-api/index.js:183:5) at async fetchStreamedChatContent (/Volumes/Work/Web Development Current/UAskMe/uaskme-backend/node_modules/streamed-chatgpt-api/index.js:11:9)
To Reproduce Steps to reproduce the behavior: Here is how i send request to get streamed answer:
fetchStreamedChatContent( { apiKey: process.env.OPENAI_API_KEY, messageInput: messages, maxTokens, temperature, model, }, (content) => { successStream(content); completeResponse += content; }, () => { return resolve(completeResponse); }, (error) => { console.log("I'm sorry, there was an error processing your request."); console.log(error); return resolve(completeResponse); } );
Expected behavior It is supposed to return answer in streamed format
Screenshots
Desktop (please complete the following information):