You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've tried return StreamingTextResponse but it not work. Did I make mistake?
export default async function handler(req, res) {
const { method } = req;
switch (method) {
case 'POST': {
let { prompt } = JSON.parse(req.body);
const messages = [
{
role: 'system',
content:
'You are an AI writing assistant that continues existing text based on context from prior text. ' +
'Give more weight/priority to the later characters than the beginning ones. ' +
'Limit your response to no more than 200 characters, but make sure to construct complete sentences.',
},
{
role: 'user',
content: prompt,
},
];
const response = await openAIService.chat({
messages: messages,
stream: false,
});
const stream = OpenAIStream(response);
return new StreamingTextResponse(stream);
// or: return streamToResponse(stream, res);
}
default: {
res.status(400).json({ message: 'Action not found' });
}
}
}```
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I've tried return StreamingTextResponse but it not work. Did I make mistake?
Beta Was this translation helpful? Give feedback.
All reactions