Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -11,9 +11,9 @@ def respond(user_message, history, chat_state):
|
|
11 |
if chat_state is None:
|
12 |
# Start a new chat with an initial greeting
|
13 |
chat_state = model.start_chat(
|
14 |
-
|
15 |
-
{"author": "user", "
|
16 |
-
{"author": "assistant", "
|
17 |
]
|
18 |
)
|
19 |
# Initialize history if it's empty
|
@@ -21,11 +21,12 @@ def respond(user_message, history, chat_state):
|
|
21 |
history = [["Hello", "Great to meet you. What would you like to know?"]]
|
22 |
else:
|
23 |
# Continue the conversation
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
29 |
return history, chat_state, ''
|
30 |
|
31 |
with gr.Blocks() as demo:
|
|
|
11 |
if chat_state is None:
|
12 |
# Start a new chat with an initial greeting
|
13 |
chat_state = model.start_chat(
|
14 |
+
messages=[
|
15 |
+
{"author": "user", "content": "Hello"},
|
16 |
+
{"author": "assistant", "content": "Great to meet you. What would you like to know?"},
|
17 |
]
|
18 |
)
|
19 |
# Initialize history if it's empty
|
|
|
21 |
history = [["Hello", "Great to meet you. What would you like to know?"]]
|
22 |
else:
|
23 |
# Continue the conversation
|
24 |
+
pass # No need to manually append messages; send_message handles it
|
25 |
+
|
26 |
+
# Send the user's message to the model
|
27 |
+
response = chat_state.send_message(user_message)
|
28 |
+
# Append the user's message and model's response to the history
|
29 |
+
history.append([user_message, response.text])
|
30 |
return history, chat_state, ''
|
31 |
|
32 |
with gr.Blocks() as demo:
|