stream not working on Vercel. Local work #1953
Unanswered
almaziphone
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
import process from 'node:process'
import type { Context } from 'hono'
import { openai } from '@ai-sdk/openai'
import { streamText } from 'ai'
// export const runtime = 'edge'
export async function getOpenAi(c: Context) {
const { prompt } = await c.req.json<{ prompt: string }>()
const temperature = 0.7
if (!prompt) {
return c.json({ error: 'Prompt is required' }, 400)
}
const result = await streamText({
model: openai('gpt-3.5-turbo'),
prompt,
temperature,
frequencyPenalty: 0.8,
})
const reader = result.textStream.getReader()
while (true) {
const { done, value } = await reader.read()
if (done) {
break
}
console.error(value)
}
}
Beta Was this translation helpful? Give feedback.
All reactions