Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -82,8 +82,13 @@ def rag_memory_stream(messages, history=[]):
|
|
| 82 |
A generator-based function that processes messages, maintains history,
|
| 83 |
and streams responses for interaction with the chatbot.
|
| 84 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
partial_text = ""
|
| 86 |
-
user_message = messages[-1]["content"] # Extract the latest user message
|
| 87 |
history.append({"user": user_message, "bot": ""}) # Add to history
|
| 88 |
|
| 89 |
# Simulate response generation (replace with actual rag_chain logic)
|
|
@@ -93,8 +98,8 @@ def rag_memory_stream(messages, history=[]):
|
|
| 93 |
yield partial_text
|
| 94 |
|
| 95 |
examples = [
|
| 96 |
-
|
| 97 |
-
|
| 98 |
]
|
| 99 |
|
| 100 |
# Title and description for the app
|
|
@@ -105,7 +110,7 @@ Powered by the Groq API and LangChain, it delivers real-time, accurate responses
|
|
| 105 |
|
| 106 |
Example Questions:
|
| 107 |
- What are the side effects of aspirin?
|
| 108 |
-
-
|
| 109 |
|
| 110 |
Disclaimer: This chatbot is for informational purposes only and not a substitute for professional medical advice.
|
| 111 |
"""
|
|
@@ -128,7 +133,7 @@ Disclaimer: This chatbot is for informational purposes only and not a substitute
|
|
| 128 |
# )
|
| 129 |
|
| 130 |
demo = gr.ChatInterface(fn=rag_memory_stream,
|
| 131 |
-
type="
|
| 132 |
title=title,
|
| 133 |
description=description,
|
| 134 |
fill_height=True,
|
|
|
|
| 82 |
A generator-based function that processes messages, maintains history,
|
| 83 |
and streams responses for interaction with the chatbot.
|
| 84 |
"""
|
| 85 |
+
# Ensure messages is a list of strings
|
| 86 |
+
if isinstance(messages, list) and all(isinstance(msg, str) for msg in messages):
|
| 87 |
+
user_message = messages[-1] # Extract the latest user message
|
| 88 |
+
else:
|
| 89 |
+
raise ValueError("Expected messages to be a list of strings.")
|
| 90 |
+
|
| 91 |
partial_text = ""
|
|
|
|
| 92 |
history.append({"user": user_message, "bot": ""}) # Add to history
|
| 93 |
|
| 94 |
# Simulate response generation (replace with actual rag_chain logic)
|
|
|
|
| 98 |
yield partial_text
|
| 99 |
|
| 100 |
examples = [
|
| 101 |
+
"What are the side effects of aspirin?",
|
| 102 |
+
"Can ibuprofen cause dizziness?"
|
| 103 |
]
|
| 104 |
|
| 105 |
# Title and description for the app
|
|
|
|
| 110 |
|
| 111 |
Example Questions:
|
| 112 |
- What are the side effects of aspirin?
|
| 113 |
+
- Can ibuprofen cause dizziness?
|
| 114 |
|
| 115 |
Disclaimer: This chatbot is for informational purposes only and not a substitute for professional medical advice.
|
| 116 |
"""
|
|
|
|
| 133 |
# )
|
| 134 |
|
| 135 |
demo = gr.ChatInterface(fn=rag_memory_stream,
|
| 136 |
+
type="list",
|
| 137 |
title=title,
|
| 138 |
description=description,
|
| 139 |
fill_height=True,
|