ChenyuRabbitLove commited on
Commit
f52c513
1 Parent(s): 9eefa43

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -63,6 +63,12 @@ def respond(
63
  history: list[tuple[str, str]],
64
  ):
65
  messages = [{"role": "system", "content": [{'type': 'text', 'text': 'You are a helpful agent'}]}]
 
 
 
 
 
 
66
  messages.append({"role": "user", "content": [{'type': 'text', 'text': message}]})
67
 
68
  response = chat_completion_request(messages, tools=tools, tool_choice='auto')
@@ -92,11 +98,9 @@ def respond(
92
  )
93
  second_response = chat_completion_request(messages)
94
  messages.append({"role": "assistant", "content": [{'type': 'text', 'text': second_response.choices[0].message.content}]})
95
- print(messages)
96
- return messages
97
  messages.append({"role": "assistant", "content": [{'type': 'text', 'text': response.choices[0].message.content}]})
98
- print(messages)
99
- return messages
100
 
101
  """
102
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
 
63
  history: list[tuple[str, str]],
64
  ):
65
  messages = [{"role": "system", "content": [{'type': 'text', 'text': 'You are a helpful agent'}]}]
66
+ for val in history:
67
+ if val[0]:
68
+ messages.append({"role": "user", "content": [{'type': 'text', 'text': val[0]}]})
69
+ if val[1]:
70
+ messages.append({"role": "assistant", "content": [{'type': 'text', 'text': val[1]}]})
71
+
72
  messages.append({"role": "user", "content": [{'type': 'text', 'text': message}]})
73
 
74
  response = chat_completion_request(messages, tools=tools, tool_choice='auto')
 
98
  )
99
  second_response = chat_completion_request(messages)
100
  messages.append({"role": "assistant", "content": [{'type': 'text', 'text': second_response.choices[0].message.content}]})
101
+ return second_response.choices[0].message.content
 
102
  messages.append({"role": "assistant", "content": [{'type': 'text', 'text': response.choices[0].message.content}]})
103
+ return response.choices[0].message.content
 
104
 
105
  """
106
  For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface