Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -62,8 +62,10 @@ rag_chain = (
|
|
62 |
| StrOutputParser()
|
63 |
)
|
64 |
|
65 |
-
# Function to handle chatbot interaction
|
66 |
def rag_chain_response(messages):
|
|
|
|
|
|
|
67 |
# Extract the last user message
|
68 |
user_message = messages[-1][0]
|
69 |
|
@@ -74,11 +76,11 @@ def rag_chain_response(messages):
|
|
74 |
messages.append((user_message, response))
|
75 |
return messages
|
76 |
|
77 |
-
|
78 |
with gr.Blocks(theme="rawrsor1/Everforest") as app:
|
|
|
79 |
|
80 |
-
|
81 |
-
chatbot = gr.Chatbot([], elem_id="RADAR", bubble_full_width=False)
|
82 |
question_input = gr.Textbox(label="Ask a Question", placeholder="Type your question here...")
|
83 |
submit_btn = gr.Button("Submit")
|
84 |
|
@@ -90,4 +92,4 @@ with gr.Blocks(theme="rawrsor1/Everforest") as app:
|
|
90 |
)
|
91 |
|
92 |
# Launch the Gradio app
|
93 |
-
app.launch(show_error=True)
|
|
|
62 |
| StrOutputParser()
|
63 |
)
|
64 |
|
|
|
65 |
def rag_chain_response(messages):
|
66 |
+
if not messages: # If messages list is empty
|
67 |
+
return [("System", "Hi! How can I assist you today?")] # Provide a default greeting
|
68 |
+
|
69 |
# Extract the last user message
|
70 |
user_message = messages[-1][0]
|
71 |
|
|
|
76 |
messages.append((user_message, response))
|
77 |
return messages
|
78 |
|
79 |
+
|
80 |
with gr.Blocks(theme="rawrsor1/Everforest") as app:
|
81 |
+
gr.Markdown("## Welcome to Annie's Chatbot - Your Friendly Guide to Birmingham!")
|
82 |
|
83 |
+
chatbot = gr.Chatbot([("System", "Hi! How can I assist you today?")], elem_id="RADAR", bubble_full_width=False)
|
|
|
84 |
question_input = gr.Textbox(label="Ask a Question", placeholder="Type your question here...")
|
85 |
submit_btn = gr.Button("Submit")
|
86 |
|
|
|
92 |
)
|
93 |
|
94 |
# Launch the Gradio app
|
95 |
+
app.launch(show_error=True)
|