TilanB commited on
Commit
7b1cb2d
·
verified ·
1 Parent(s): c489928
Files changed (1) hide show
  1. main.py +14 -7
main.py CHANGED
@@ -652,7 +652,9 @@ setInterval(tick, 500);
652
  )
653
  try:
654
  if not question_text.strip():
655
- chat_history.append([question_text, "Please enter a question."])
 
 
656
  yield (
657
  chat_history,
658
  gr.update(visible=False),
@@ -664,9 +666,10 @@ setInterval(tick, 500);
664
  gr.update(value="", visible=False)
665
  )
666
  return
667
- if not uploaded_files:
668
-
669
- chat_history.append([question_text, "Please upload at least one document."])
 
670
  yield (
671
  chat_history,
672
  gr.update(visible=False),
@@ -790,7 +793,9 @@ setInterval(tick, 500);
790
  verification = result.get("verification_report", "No verification details available.")
791
  logger.info(f"Verification (internal):\n{verification}")
792
  # Do not display verification to user, only use internally
793
- chat_history.append([question_text, f"**Answer:**\n{answer}"])
 
 
794
  session_state.value["last_documents"] = retriever.invoke(question_text)
795
  yield (
796
  chat_history,
@@ -818,7 +823,9 @@ setInterval(tick, 500);
818
  except Exception as e:
819
  logger.error(f"Processing error: {e}", exc_info=True)
820
 
821
- chat_history.append([question_text, f"Error: {str(e)}"])
 
 
822
  yield (
823
  chat_history,
824
  gr.update(visible=False),
@@ -891,7 +898,7 @@ setInterval(tick, 500);
891
  if is_hf_space:
892
  # Hugging Face Spaces configuration
893
  logger.info("Running on Hugging Face Spaces")
894
- demo.launch(server_name="0.0.0.0", server_port=7860, js=js, css=css)
895
  else:
896
  # Local development configuration
897
  configured_port = int(os.environ.get("GRADIO_SERVER_PORT", "7860"))
 
652
  )
653
  try:
654
  if not question_text.strip():
655
+
656
+ chat_history.append({"role": "user", "content": question_text})
657
+ chat_history.append({"role": "assistant", "content": "Please enter a question."})
658
  yield (
659
  chat_history,
660
  gr.update(visible=False),
 
666
  gr.update(value="", visible=False)
667
  )
668
  return
669
+ if not uploaded_files:
670
+
671
+ chat_history.append({"role": "user", "content": question_text})
672
+ chat_history.append({"role": "assistant", "content": "Please upload at least one document."})
673
  yield (
674
  chat_history,
675
  gr.update(visible=False),
 
793
  verification = result.get("verification_report", "No verification details available.")
794
  logger.info(f"Verification (internal):\n{verification}")
795
  # Do not display verification to user, only use internally
796
+
797
+ chat_history.append({"role": "user", "content": question_text})
798
+ chat_history.append({"role": "assistant", "content": f"**Answer:**\n{answer}"})
799
  session_state.value["last_documents"] = retriever.invoke(question_text)
800
  yield (
801
  chat_history,
 
823
  except Exception as e:
824
  logger.error(f"Processing error: {e}", exc_info=True)
825
 
826
+
827
+ chat_history.append({"role": "user", "content": question_text})
828
+ chat_history.append({"role": "assistant", "content": f"Error: {str(e)}"})
829
  yield (
830
  chat_history,
831
  gr.update(visible=False),
 
898
  if is_hf_space:
899
  # Hugging Face Spaces configuration
900
  logger.info("Running on Hugging Face Spaces")
901
+ demo.launch(server_name="0.0.0.0", server_port=7860, css=css, js=js)
902
  else:
903
  # Local development configuration
904
  configured_port = int(os.environ.get("GRADIO_SERVER_PORT", "7860"))