maahikachitagi commited on
Commit
cea42eb
·
verified ·
1 Parent(s): 41ce0fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -9,14 +9,20 @@ def respond(message, history):
9
  if history:
10
  messages.extend(history)
11
  messages.append({"role":"user", "content": message})
12
- response = client.chat_completion(
 
13
  messages,
14
- max_tokens = 50, #change the length
15
  temperature = 0.5,
16
- top_p = 0.7
17
- )
18
- print(response["choices"][0]["message"]["content"].strip())
19
- return response["choices"][0]["message"]["content"].strip()
 
 
 
 
 
20
 
21
  def echo(message, history):
22
  choices = ["Without a doubt", "Ask again later","Yes, definitely","Don't count on it"]
 
9
  if history:
10
  messages.extend(history)
11
  messages.append({"role":"user", "content": message})
12
+ response = ""
13
+ for message in client.chat_completion(
14
  messages,
15
+ max_tokens = 100, #change the length
16
  temperature = 0.5,
17
+ top_p = 0.7,
18
+ stream=True
19
+ ):
20
+ token = message.choices[0].delta.content
21
+ response += token
22
+
23
+
24
+
25
+ yield response["choices"][0]["message"]["content"].strip()
26
 
27
  def echo(message, history):
28
  choices = ["Without a doubt", "Ask again later","Yes, definitely","Don't count on it"]