Sadmo commited on
Commit
998e8e9
·
verified ·
1 Parent(s): 2189910

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -12,14 +12,18 @@ def respond(message, history):
12
  messages.extend(history)
13
  messages.append({"role": "user", "content": message})
14
 
15
- response = client.chat_completion(
 
16
  messages,
17
  max_tokens=100, # change the length of message
18
  temperature = 0.1,
19
- top_p = 0.7
20
- )
 
 
 
21
 
22
- return response['choices'][0]['message']['content'].strip()
23
 
24
  chatbot = gr.ChatInterface(respond, type = "messages", title = "SadhanaGPT for KWK", theme = gr.themes.Glass(), examples = ["How's the weather today?", "Who won the match?", "Is the sky green?"])
25
 
 
12
  messages.extend(history)
13
  messages.append({"role": "user", "content": message})
14
 
15
+ response = ""
16
+ for message in client.chat_completion(
17
  messages,
18
  max_tokens=100, # change the length of message
19
  temperature = 0.1,
20
+ top_p = 0.7,
21
+ stream = True,
22
+ ):
23
+ token = messages.choices[0].delta.content
24
+ response += token
25
 
26
+ yield response['choices'][0]['message']['content'].strip()
27
 
28
  chatbot = gr.ChatInterface(respond, type = "messages", title = "SadhanaGPT for KWK", theme = gr.themes.Glass(), examples = ["How's the weather today?", "Who won the match?", "Is the sky green?"])
29