fraudTech commited on
Commit
80e7e28
·
1 Parent(s): 09aec5a

fixed front end network error

Browse files
Files changed (1) hide show
  1. src/App.js +9 -10
src/App.js CHANGED
@@ -500,6 +500,7 @@ function App() {
500
  }));
501
 
502
  let streamedText = "";
 
503
 
504
  // STREAM HERE ⬇⬇⬇
505
  await streamChat(
@@ -517,11 +518,9 @@ function App() {
517
  // Add any remaining text before the debug marker
518
  if (textPart) {
519
  streamedText += textPart;
520
- if (assistantMsg.thinking && !streamedText.trim()) {
521
- assistantMsg.text = streamedText;
522
  assistantMsg.thinking = false;
523
- } else {
524
- assistantMsg.text = streamedText;
525
  }
526
  }
527
 
@@ -529,6 +528,7 @@ function App() {
529
  try {
530
  const debugData = JSON.parse(debugPart.trim());
531
  assistantMsg.debug = debugData;
 
532
  console.log("✅ Debug info received from stream:", {
533
  total_results: debugData.total_results,
534
  queries_count: debugData.queries_executed?.length,
@@ -536,7 +536,7 @@ function App() {
536
  });
537
  } catch (parseErr) {
538
  console.error("❌ Failed to parse debug JSON:", parseErr);
539
- console.log("Debug chunk:", debugPart);
540
  assistantMsg.debug = {
541
  error: "Failed to parse debug info",
542
  total_results: 0,
@@ -545,16 +545,15 @@ function App() {
545
  };
546
  }
547
  setMessages([...newMessages]);
 
548
  return;
549
  }
550
 
551
  // Regular text chunk
552
  streamedText += chunk;
553
- if (assistantMsg.thinking && !streamedText.trim()) {
554
- assistantMsg.text = streamedText;
555
  assistantMsg.thinking = false;
556
- } else {
557
- assistantMsg.text = streamedText;
558
  }
559
  setMessages([...newMessages]); // re-render UI
560
  },
@@ -565,7 +564,7 @@ function App() {
565
  assistantMsg.thinking = false;
566
 
567
  // If debug info wasn't received in stream, set empty defaults
568
- if (!assistantMsg.debug) {
569
  console.warn("⚠️ No debug info received in stream");
570
  assistantMsg.debug = {
571
  warning: "Debug info not received from stream",
 
500
  }));
501
 
502
  let streamedText = "";
503
+ let debugInfoReceived = false;
504
 
505
  // STREAM HERE ⬇⬇⬇
506
  await streamChat(
 
518
  // Add any remaining text before the debug marker
519
  if (textPart) {
520
  streamedText += textPart;
521
+ assistantMsg.text = streamedText;
522
+ if (assistantMsg.thinking && streamedText.trim()) {
523
  assistantMsg.thinking = false;
 
 
524
  }
525
  }
526
 
 
528
  try {
529
  const debugData = JSON.parse(debugPart.trim());
530
  assistantMsg.debug = debugData;
531
+ debugInfoReceived = true;
532
  console.log("✅ Debug info received from stream:", {
533
  total_results: debugData.total_results,
534
  queries_count: debugData.queries_executed?.length,
 
536
  });
537
  } catch (parseErr) {
538
  console.error("❌ Failed to parse debug JSON:", parseErr);
539
+ console.log("Debug chunk:", debugPart.substring(0, 200));
540
  assistantMsg.debug = {
541
  error: "Failed to parse debug info",
542
  total_results: 0,
 
545
  };
546
  }
547
  setMessages([...newMessages]);
548
+ // Don't return - let the stream complete naturally
549
  return;
550
  }
551
 
552
  // Regular text chunk
553
  streamedText += chunk;
554
+ assistantMsg.text = streamedText;
555
+ if (assistantMsg.thinking && streamedText.trim()) {
556
  assistantMsg.thinking = false;
 
 
557
  }
558
  setMessages([...newMessages]); // re-render UI
559
  },
 
564
  assistantMsg.thinking = false;
565
 
566
  // If debug info wasn't received in stream, set empty defaults
567
+ if (!debugInfoReceived) {
568
  console.warn("⚠️ No debug info received in stream");
569
  assistantMsg.debug = {
570
  warning: "Debug info not received from stream",