Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -16,7 +16,7 @@ system_instructions = (
|
|
16 |
def chat(user_input, history):
|
17 |
global context
|
18 |
if user_input.lower() == "exit":
|
19 |
-
return history + [
|
20 |
|
21 |
# Construct the modified input including system instructions and context
|
22 |
modified_input = (
|
@@ -34,13 +34,13 @@ def chat(user_input, history):
|
|
34 |
# Update the context with the latest conversation
|
35 |
context += f"User: {user_input}\nAI: {ai_response}\n"
|
36 |
|
37 |
-
# Append the AI's response to the conversation history
|
38 |
-
history.append(
|
39 |
-
history.append(
|
40 |
return history
|
41 |
|
42 |
# Gradio interface using ChatInterface
|
43 |
-
interface = gr.
|
44 |
|
45 |
# Launch the chatbot
|
46 |
interface.launch()
|
|
|
16 |
def chat(user_input, history):
|
17 |
global context
|
18 |
if user_input.lower() == "exit":
|
19 |
+
return history + [("assistant", "Ending session. Goodbye!")] # Using tuples here to avoid errors
|
20 |
|
21 |
# Construct the modified input including system instructions and context
|
22 |
modified_input = (
|
|
|
34 |
# Update the context with the latest conversation
|
35 |
context += f"User: {user_input}\nAI: {ai_response}\n"
|
36 |
|
37 |
+
# Append the AI's response to the conversation history using the correct tuple format
|
38 |
+
history.append(("user", user_input))
|
39 |
+
history.append(("assistant", ai_response))
|
40 |
return history
|
41 |
|
42 |
# Gradio interface using ChatInterface
|
43 |
+
interface = gr.Interface(fn=chat, inputs=["text", "state"], outputs=["chatbot", "state"])
|
44 |
|
45 |
# Launch the chatbot
|
46 |
interface.launch()
|