Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -48,27 +48,7 @@ rag_chain = (
|
|
48 |
)
|
49 |
import gradio as gr
|
50 |
|
51 |
-
|
52 |
def rag_memory_stream(message, history):
|
53 |
-
|
54 |
-
# Define possible greeting messages and their responses
|
55 |
-
greetings = {
|
56 |
-
"hello": "Hello! How can I assist you today?",
|
57 |
-
"hi": "Hi there! How can I help you?",
|
58 |
-
"good morning": "Good morning! How can I assist you?",
|
59 |
-
"good afternoon": "Good afternoon! What can I help you with?",
|
60 |
-
"good evening": "Good evening! Do you have any questions for me?",
|
61 |
-
}
|
62 |
-
|
63 |
-
# Normalize the input message to lowercase for comparison
|
64 |
-
normalized_message = message.strip().lower()
|
65 |
-
|
66 |
-
# Check if the message is a greeting
|
67 |
-
if normalized_message in greetings:
|
68 |
-
yield greetings[normalized_message]
|
69 |
-
return # End early as the greeting is handled
|
70 |
-
|
71 |
-
# Default behavior for non-greeting messages
|
72 |
partial_text = ""
|
73 |
for new_text in rag_chain.stream(message):
|
74 |
partial_text += new_text
|
@@ -77,8 +57,14 @@ def rag_memory_stream(message, history):
|
|
77 |
|
78 |
examples = ['I feel dizzy', 'what is the possible sickness for fatigue']
|
79 |
|
|
|
80 |
|
81 |
title = "MediGuide ChatBot"
|
|
|
|
|
|
|
|
|
|
|
82 |
demo = gr.Interface(
|
83 |
title=title,
|
84 |
fn=rag_memory_stream,
|
@@ -88,6 +74,7 @@ demo = gr.Interface(
|
|
88 |
allow_flagging="never",
|
89 |
fill_height=True,
|
90 |
theme="glass",
|
|
|
91 |
)
|
92 |
|
93 |
|
|
|
48 |
)
|
49 |
import gradio as gr
|
50 |
|
|
|
51 |
def rag_memory_stream(message, history):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
partial_text = ""
|
53 |
for new_text in rag_chain.stream(message):
|
54 |
partial_text += new_text
|
|
|
57 |
|
58 |
examples = ['I feel dizzy', 'what is the possible sickness for fatigue']
|
59 |
|
60 |
+
greetingsmessage = "Hi, I'm the CAMELS DocBot, I'm here to assist you with any question related to the CAMELS simulations."
|
61 |
|
62 |
title = "MediGuide ChatBot"
|
63 |
+
|
64 |
+
chatbot = gr.Chatbot([{"role":"assistant", "content":greetingsmessage}],
|
65 |
+
type="messages",
|
66 |
+
height="60vh")
|
67 |
+
|
68 |
demo = gr.Interface(
|
69 |
title=title,
|
70 |
fn=rag_memory_stream,
|
|
|
74 |
allow_flagging="never",
|
75 |
fill_height=True,
|
76 |
theme="glass",
|
77 |
+
chatbot=chatbot
|
78 |
)
|
79 |
|
80 |
|