lisaude0512 commited on
Commit
e63c0d1
·
verified ·
1 Parent(s): 206cec0
Files changed (1) hide show
  1. app.py +8 -12
app.py CHANGED
@@ -11,19 +11,15 @@ def respond(message, history):
11
  messages.extend(history)
12
  messages.append({"role": "user", "content": message})
13
 
14
- response = client.chat_completion(
 
15
  messages,
16
- max_tokens = 190
17
- #change the text length
18
- )
19
-
20
- print(response["choices"][0]["message"]["content"].strip())
21
- return response["choices"][0]["message"]["content"].strip()
22
-
23
- def magic_eight_ball(message, history):
24
- my_list = ["yes","no","probably","absolutely", "absolutely not","that's crazy","that's amazing","Without a doubt","most likely","i wouldn't expect a no","ask later","can't tell you now","I know but I won't tell youu","how bout no","do you need that??"]
25
- chat_answer = random.choice(my_list)
26
- return chat_answer
27
 
28
  chatbot = gr.ChatInterface(respond, type = "messages")
29
  chatbot.launch(debug=True)
 
11
  messages.extend(history)
12
  messages.append({"role": "user", "content": message})
13
 
14
+ response = ""
15
+ for messages in client.chat_completion(
16
  messages,
17
+ max_tokens = 190,
18
+ stream = True,
19
+ ):
20
+ token = messages.choices[0].delta.content
21
+ response+= token
22
+ yield response["choices"][0]["message"]["content"].strip()
 
 
 
 
 
23
 
24
  chatbot = gr.ChatInterface(respond, type = "messages")
25
  chatbot.launch(debug=True)