pragyarama commited on
Commit
e56cfaa
·
verified ·
1 Parent(s): 80953fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -86,7 +86,8 @@ def respond(message, history, name, country): # Generate a response using the mo
86
  ]
87
 
88
  if history:
89
- messages.extend(history)
 
90
 
91
  messages.append({"role": "user", "content": message})
92
 
@@ -96,7 +97,9 @@ def respond(message, history, name, country): # Generate a response using the mo
96
  temperature=0.2
97
  )
98
 
99
- return response["choices"][0]["message"]["content"].strip()
 
 
100
 
101
 
102
  # SURVEY
@@ -135,7 +138,7 @@ with gr.Blocks() as demo:
135
  send_btn.click(
136
  fn=respond,
137
  inputs=[msg, chat_state, name_state, country_state],
138
- outputs=chatbot
139
  )
140
 
141
  demo.launch()
 
86
  ]
87
 
88
  if history:
89
+ messages.extend([{"role": "user", "content": m[0]} for m in history])
90
+ messages.extend([{"role": "assistant", "content": m[1]} for m in history])
91
 
92
  messages.append({"role": "user", "content": message})
93
 
 
97
  temperature=0.2
98
  )
99
 
100
+ bot_reply = response["choices"][0]["message"]["content"].strip()
101
+
102
+ return [message, bot_reply], history + [[message, bot_reply]]
103
 
104
 
105
  # SURVEY
 
138
  send_btn.click(
139
  fn=respond,
140
  inputs=[msg, chat_state, name_state, country_state],
141
+ outputs=[chatbot, chat_state]
142
  )
143
 
144
  demo.launch()