trinity-tandon commited on
Commit
123fe0d
·
verified ·
1 Parent(s): 886526c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -14,10 +14,16 @@ def respond(message, history):
14
  if history:
15
  messages.extend(history)
16
  messages.append({"role": "user", "content": message})
17
- response = client.chat_completion(
 
18
  messages,
19
  temperature = 0.1
 
20
  )
 
 
 
 
21
  return response['choices'][0]['message']['content'].strip()
22
 
23
  chatbot = gr.ChatInterface(respond, type = "messages")
 
14
  if history:
15
  messages.extend(history)
16
  messages.append({"role": "user", "content": message})
17
+ response = ""
18
+ client.chat_completion(
19
  messages,
20
  temperature = 0.1
21
+ stream = True
22
  )
23
+ for message in client.chat_completion:
24
+ token = messages.choices[0].delta.content
25
+ response += token
26
+ yield response
27
  return response['choices'][0]['message']['content'].strip()
28
 
29
  chatbot = gr.ChatInterface(respond, type = "messages")