Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/backend/src/modules/puterai/lib/OpenAIUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ const create_chat_stream_handler = ({

const choice = chunk.choices[0];

if ( choice.delta.reasoning_content ){
textblock.addReasoning(choice.delta.reasoning_content);
// Q: Why don't "continue" to next chunk here?
// A: For now, reasoning_content and content never appear together, but I’m not sure if they’ll always be mutually exclusive.
}

if ( choice.delta.content ){
if ( mode === 'tool' ) {
toolblock.end();
Expand Down
7 changes: 7 additions & 0 deletions src/backend/src/modules/puterai/lib/Streaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ class AIChatTextStream extends AIChatConstructStream {
});
this.chatStream.stream.write(json + '\n');
}

addReasoning (reasoning) {
const json = JSON.stringify({
type: 'reasoning', reasoning,
});
this.chatStream.stream.write(json + '\n');
}
}

class AIChatToolUseStream extends AIChatConstructStream {
Expand Down