Skip to content

Commit dac4f28

Browse files
committed
refactor: allow streaming to work with or without Responses API
1 parent c115fdf commit dac4f28

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/agent-api/src/functions/chats-post.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,14 @@ async function* createJsonStream(chunks: AsyncIterable<StreamEvent>, sessionId:
208208

209209
if (chunk.event === 'on_chat_model_end' && data.output?.content.length > 0) {
210210
// End of our agentic chain
211-
const content = data?.output.content[0].text ?? '';
211+
const content = data?.output.content[0].text ?? data.output.content ?? '';
212212
await onComplete(content);
213213

214214
} else if (chunk.event === 'on_chat_model_stream' && data.chunk.content.length > 0) {
215215
// Streaming response from the LLM
216216
responseChunk = {
217217
delta: {
218-
content: data.chunk.content[0].text,
218+
content: data.chunk.content[0].text ?? data.chunk.content,
219219
role: 'assistant',
220220
}
221221
};

0 commit comments

Comments
 (0)