akhaliq HF Staff commited on
Commit
092a2ce
·
verified ·
1 Parent(s): b71dea6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
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", "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,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", "content": 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])
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: