Skip to content
Closed
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
Binary file modified tools/server/public/index.html.gz
Binary file not shown.
25 changes: 24 additions & 1 deletion tools/server/webui/src/utils/app.context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,37 @@ export const AppContextProvider = ({
throw new Error(body?.error?.message || 'Unknown error');
}
const chunks = getSSEStreamAsync(fetchResponse);
let thinkingTagOpen = false;
for await (const chunk of chunks) {
// const stop = chunk.stop;
if (chunk.error) {
throw new Error(chunk.error?.message || 'Unknown error');
}

const reasoningContent = chunk.choices[0].delta.reasoning_content;
if (reasoningContent) {
if (pendingMsg.content === null || pendingMsg.content === '') {
thinkingTagOpen = true;
pendingMsg = {
...pendingMsg,
content: '<think>' + reasoningContent,
};
} else {
pendingMsg = {
...pendingMsg,
content: pendingMsg.content + reasoningContent,
};
}
}

const addedContent = chunk.choices[0].delta.content;
const lastContent = pendingMsg.content || '';
let lastContent = pendingMsg.content || '';
if (addedContent) {
if (thinkingTagOpen) {
lastContent = lastContent + '</think>';
thinkingTagOpen = false;
}

pendingMsg = {
...pendingMsg,
content: lastContent + addedContent,
Expand Down