Skip to content

Commit c203815

Browse files
committed
fix: more cleanup
1 parent b128ca5 commit c203815

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

tools/server/webui/src/components/ChatMessage.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useMemo, useState } from 'react';
1+
import { useMemo, useState, Fragment } from 'react';
22
import { useAppContext } from '../utils/app.context';
33
import { Message, PendingMessage } from '../utils/types';
44
import { classNames } from '../utils/misc';
@@ -72,14 +72,11 @@ export default function ChatMessage({
7272
) {
7373
return { content: msg.content };
7474
}
75-
7675
let actualContent = '';
7776
let thought = '';
7877
let isThinking = false;
7978
let thinkSplit = msg.content.split('<think>', 2);
80-
8179
actualContent += thinkSplit[0];
82-
8380
while (thinkSplit[1] !== undefined) {
8481
// <think> tag found
8582
thinkSplit = thinkSplit[1].split('</think>', 2);
@@ -204,7 +201,7 @@ export default function ChatMessage({
204201
))}
205202

206203
{chainedParts?.map((part) => (
207-
<React.Fragment key={part.id}>
204+
<Fragment key={part.id}>
208205
{part.role === 'tool' && part.content && (
209206
<ToolCallResultDisplay
210207
content={part.content}
@@ -229,7 +226,7 @@ export default function ChatMessage({
229226
baseClassName="collapse bg-base-200 collapse-arrow mb-4 mt-2"
230227
/>
231228
))}
232-
</React.Fragment>
229+
</Fragment>
233230
))}
234231
{/* render timings if enabled */}
235232
{timings && config.showTokensPerSecond && (

tools/server/webui/src/components/ChatScreen.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ function getListMessageDisplay(
6262
nodeMap.set(msg.id, msg);
6363
}
6464

65+
// find leaf node from a message node
6566
const findLeafNode = (msgId: Message['id']): Message['id'] => {
6667
let currNode: Message | undefined = nodeMap.get(msgId);
6768
while (currNode) {

tools/server/webui/src/utils/misc.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ export function filterThoughtFromMsgs(messages: APIMessage[]) {
117117
return msg;
118118
}
119119
// assistant message is always a string
120+
// except when tool_calls is present - it can be null then
120121
const contentStr = msg.content as string | null;
121122
let content;
122123
if (msg.role === 'assistant' && contentStr !== null) {

0 commit comments

Comments
 (0)