Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
| 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 |
)
|