Comments (3)
I'm having the same problem. The data stream appears as an appendix to the message content, as indicated below
2:[{"text":"{\"metadata\":[],\"regularQuery\":{\"error\":null,\"data\":[],\"count\":null,\"status\":200,\"statusText\":\"OK\"}}"}]
0:"L" 0:"ament" 0:"able" 0:"mente" 0:"," 0:" no" 0:" tengo" 0:" acceso" 0:" a" 0:" documentos" 0:" específ" 0:"icos" 0:" del" 0:" BO" 0:"E" 0:"." 0:" Sin" 0:" embargo" 0:"," 0:" puedo" 0:" ayud" 0:"arte" 0:" a" 0:" encontrar" 0:" la" 0:" información" 0:" que" 0:" neces" 0:"itas" 0:"." 0:" ¿" 0:"En" 0:" qué" 0:" puedo" 0:" as" 0:"ist" 0:"ir" 0:"te" 0:"?"
I'm not sure how to parse this correctly or why the structure is this way. I'm using NextJS and a edge function for calling the OpenAI API. It seems it is related to how OpenAI is giving the response is that right? @MaxLeiter
from ai.
After some debugging, I found that this is not just a problem with Gatsby. The same problem also occurs when I deploy the Next.js application to Vercel and then connect to the production API via local development.
Then I also get the same encoding/decoding problem.
So I run Next.js locally via npm run dev
and the useChat()
api goes to a production endpoint.
For example, this Next.js front-end page that I run locally:
"use client";
import {useChat} from "ai/react";
const Page = () => {
const { data, handleInputChange, handleSubmit, messages } = useChat({
api: 'https://example-ai-api.vercel.app/api/chat', // <---- this is the production endpoint
});
console.log('data', data);
console.log('messages', messages);
return (
<div>
<form onSubmit={handleSubmit}>
<input
type="text"
name="input"
onChange={handleInputChange}
/>
<button type="submit">Send</button>
</form>
</div>
)
}
export default Page
from ai.
Looks like more people has the same issue:
#425 (comment)
from ai.
Related Issues (20)
- OpenAI, experimental_onToolCall - tool call messages are not streaming in realtime HOT 1
- message annotations are repeated HOT 3
- Limit number of words streaming at a time - useChat HOT 2
- Perhaps I'm missing something? `experimental_StreamData`
- Serverless stream exception HOT 1
- experimental_StreamData,If the string is too long, it will be truncated.
- Azure OpenAI Assistants
- Request body is not sent with useChat after upgrading to >=2.2.26 HOT 2
- Mistral's Mixtral-8x7b-Instruct-v0.1 model compatibility HOT 1
- experimental_StreamData not working with AIStream HELP ME!
- ability to transform response from backend in useChat
- Maintain data over multiple sessions.
- Streaming Text Response doesn't work with Azure Open AI (ai: "^2.2.35") HOT 1
- onFinish is called twice
- onToolCall payload is null
- Allow to return tool call results from server
- Passing parameter to useChat > reload() function with Server Action is not working HOT 1
- Implement onChunk() Callback to AIStreamCallbacksAndOptions and in OpenAIStream
- Unable to receive the stream as expected
- Metadata with assistants
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ai.