RahulGanapathy commited on
Commit
42399aa
·
verified ·
1 Parent(s): 85b47e4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -17,7 +17,7 @@ SYSTEM_MESSAGE = (
17
  # Function to handle chatbot responses
18
  def respond(message, history):
19
  # Ensure history is a list of tuples
20
- if not isinstance(history, list):
21
  history = []
22
 
23
  messages = [{"role": "system", "content": SYSTEM_MESSAGE}]
@@ -41,9 +41,12 @@ def respond(message, history):
41
  return history, bot_reply
42
 
43
  # Create Gradio chatbot UI
44
- demo = gr.ChatInterface(
45
- respond,
46
- chatbot=gr.Chatbot(),
 
 
 
47
  title="Misinformation Detection Chatbot",
48
  description="Ask anything, and the chatbot will verify whether it's true or false.",
49
  )
 
17
  # Function to handle chatbot responses
18
  def respond(message, history):
19
  # Ensure history is a list of tuples
20
+ if not isinstance(history, list) or not all(isinstance(i, tuple) and len(i) == 2 for i in history):
21
  history = []
22
 
23
  messages = [{"role": "system", "content": SYSTEM_MESSAGE}]
 
41
  return history, bot_reply
42
 
43
  # Create Gradio chatbot UI
44
+ chatbot_ui = gr.Chatbot()
45
+
46
+ demo = gr.Interface(
47
+ fn=respond,
48
+ inputs=["text", chatbot_ui], # Ensure chatbot component receives formatted history
49
+ outputs=[chatbot_ui, "text"], # Ensure chatbot returns formatted history
50
  title="Misinformation Detection Chatbot",
51
  description="Ask anything, and the chatbot will verify whether it's true or false.",
52
  )