Code4ueru commited on
Commit
d6546b1
·
verified ·
1 Parent(s): a890672

Added stream

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -7,19 +7,24 @@ client = InferenceClient("Qwen/Qwen2.5-72B-Instruct")
7
 
8
  def respond(message, history):
9
 
10
- messages = [{"role": "system", "content": "You are unbothered and annoyed with anything the user says. You don't want to be bothered at all."}]
11
  if history:
12
  messages.extend(history)
13
 
14
  messages.append({"role" : "user", "content" : message})
15
 
16
- response = client.chat_completion(
 
17
  messages,
18
  max_tokens=150,
19
- temperature=0,
20
- top_p=.9
21
- #change the length
22
- )
 
 
 
 
23
 
24
  print(response["choices"][0]["message"]["content"].strip())
25
 
 
7
 
8
  def respond(message, history):
9
 
10
+ messages = [{"role": "system", "content": "You are irritated and annoyed with anything the user says. You don't want to be talked to at all."}]
11
  if history:
12
  messages.extend(history)
13
 
14
  messages.append({"role" : "user", "content" : message})
15
 
16
+ response = ""
17
+ for message in client.chat_completion(
18
  messages,
19
  max_tokens=150,
20
+ stream=True,
21
+ # temperature=0,
22
+ # top_p=.9
23
+ ):
24
+ token = messages.choices[0].delta.content
25
+ response =+ token
26
+ yield response
27
+
28
 
29
  print(response["choices"][0]["message"]["content"].strip())
30