fraudTech commited on
Commit
dda41bc
·
1 Parent(s): e837790

refactor system prompt to functions

Browse files
Files changed (1) hide show
  1. web/src/App.tsx +21 -0
web/src/App.tsx CHANGED
@@ -1058,6 +1058,7 @@ function App() {
1058
  let localThinkingContent = '';
1059
  let finalBuffer = '';
1060
  let toolsUsed = false;
 
1061
 
1062
  // RAF batching for content_chunk / reasoning_chunk.
1063
  // Accumulate text locally; flush to React state at most once per frame.
@@ -1289,6 +1290,22 @@ function App() {
1289
  setMessages((prev) =>
1290
  prev.map((msg) => {
1291
  if (msg.id !== assistantId) return msg;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1292
  if (!toolsUsed) {
1293
  // Pure V3 response without tools – show as normal content,
1294
  // no Thinking panel needed.
@@ -1335,6 +1352,10 @@ function App() {
1335
  };
1336
  })
1337
  );
 
 
 
 
1338
  } else if (event === 'error') {
1339
  if (rafId !== null) { cancelAnimationFrame(rafId); rafId = null; }
1340
  // Error occurred
 
1058
  let localThinkingContent = '';
1059
  let finalBuffer = '';
1060
  let toolsUsed = false;
1061
+ let serverResponseContent: string | null = null;
1062
 
1063
  // RAF batching for content_chunk / reasoning_chunk.
1064
  // Accumulate text locally; flush to React state at most once per frame.
 
1290
  setMessages((prev) =>
1291
  prev.map((msg) => {
1292
  if (msg.id !== assistantId) return msg;
1293
+ if (serverResponseContent && serverResponseContent.trim()) {
1294
+ if (!toolsUsed || isR1) {
1295
+ return {
1296
+ ...msg,
1297
+ content: serverResponseContent,
1298
+ thinkingContent: undefined,
1299
+ thinkingExpanded: undefined,
1300
+ isStreaming: false,
1301
+ };
1302
+ }
1303
+ return {
1304
+ ...msg,
1305
+ content: serverResponseContent,
1306
+ isStreaming: false,
1307
+ };
1308
+ }
1309
  if (!toolsUsed) {
1310
  // Pure V3 response without tools – show as normal content,
1311
  // no Thinking panel needed.
 
1352
  };
1353
  })
1354
  );
1355
+ } else if (event === 'response') {
1356
+ if (typeof data?.content === 'string') {
1357
+ serverResponseContent = data.content;
1358
+ }
1359
  } else if (event === 'error') {
1360
  if (rafId !== null) { cancelAnimationFrame(rafId); rafId = null; }
1361
  // Error occurred