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)
- feat: define tool parameters with JSON schema instead of Zod HOT 4
- Client-side exception upon recursive append to streamable UI in production HOT 2
- Add `stop` to open-ai input options so that we can finish gracefully
- Timeout error while using `Stream Text generation` from ai-sdk (Free plan) HOT 2
- Azure OpenAI support HOT 2
- Jest: cannot find module 'ai/rsc' HOT 1
- Documentation and examples how to use Vercel AI in React HOT 2
- Groq models don't return the usage HOT 3
- Missing links in OpenAI provider README
- Erratic behavior of useChat - Could SWR be the issue?
- `onError` hook not called when an error occurs during streaming in `useAssistant`
- the example of bedrock/anthropic-v3 show error
- LangChainAdapter does not support `StringOutParser` HOT 1
- ai/packages/core/react /use-assistant.ts: expose `setThreadId` as helper
- Azure OpenAI provider HOT 5
- Add a Vue version of useAssistant hook
- [zod dependency] Is it okay to add zod dependency to the main package? HOT 2
- Prompt gets added as first message in messages array and looses its attention HOT 4
- Stop tokens?
- Can safety settings be passed to the Google provider?
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.