AriniR commited on
Commit
a0a8dca
·
verified ·
1 Parent(s): b9c6949

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -7
app.py CHANGED
@@ -10,17 +10,30 @@ def respond(message, history):
10
  if history :
11
  messages.extend(history)
12
  messages.append({"role":"user","content": message})
13
- response = client.chat_completion(messages, max_tokens = 400, temperature = 2, top_p =.999)
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
 
16
- return response["choices"][0]["message"]["content"].strip()
17
 
18
 
19
- def random_message (message, history):
20
- choices = ('yes','no','i dont think so','be so for real','yep', 'woooow', 'hmmmm', 'idk', 'idc', 'yaaay', 'why would i know')
21
- wow = random.choice(choices)
22
- theme = soft
23
- return wow
24
 
25
 
26
  chatbot = gr.ChatInterface(respond, type = "messages", title = "chatty")
 
10
  if history :
11
  messages.extend(history)
12
  messages.append({"role":"user","content": message})
13
+
14
+ response = ""
15
+
16
+ for message in client.chat_completion(
17
+ messages,
18
+ max_tokens = 400,
19
+ stream = True)
20
+ token = message.choices[0].delta.content
21
+ response += token
22
+ yield response
23
+
24
+
25
+ # top_p & temperature
26
+
27
 
28
 
29
+ #return response["choices"][0]["message"]["content"].strip()
30
 
31
 
32
+ #def random_message (message, history):
33
+ # choices = ('yes','no','i dont think so','be so for real','yep', 'woooow', 'hmmmm', 'idk', 'idc', 'yaaay', 'why would i know')
34
+ # wow = random.choice(choices)
35
+ # theme = soft
36
+ # return wow
37
 
38
 
39
  chatbot = gr.ChatInterface(respond, type = "messages", title = "chatty")