Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -12,8 +12,8 @@ def respond(user_message, history, chat_state):
|
|
12 |
# Start a new chat with an initial greeting
|
13 |
chat_state = model.start_chat(
|
14 |
history=[
|
15 |
-
{"author": "user", "
|
16 |
-
{"author": "assistant", "
|
17 |
]
|
18 |
)
|
19 |
# Initialize history if it's empty
|
@@ -21,11 +21,11 @@ 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 |
-
chat_state.messages.append({"author": "user", "
|
25 |
# Generate a response
|
26 |
response = chat_state.generate_message()
|
27 |
# Append the user's message and model's response to the history
|
28 |
-
history.append([user_message, response])
|
29 |
return history, chat_state, ''
|
30 |
|
31 |
with gr.Blocks() as demo:
|
|
|
12 |
# Start a new chat with an initial greeting
|
13 |
chat_state = model.start_chat(
|
14 |
history=[
|
15 |
+
{"author": "user", "parts": ["Hello"]},
|
16 |
+
{"author": "assistant", "parts": ["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 |
+
chat_state.messages.append({"author": "user", "parts": [user_message]})
|
25 |
# Generate a response
|
26 |
response = chat_state.generate_message()
|
27 |
# Append the user's message and model's response to the history
|
28 |
+
history.append([user_message, response.text])
|
29 |
return history, chat_state, ''
|
30 |
|
31 |
with gr.Blocks() as demo:
|