mikeee commited on
Commit
d1a0824
·
verified ·
1 Parent(s): 30c43ba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -38,19 +38,22 @@ def respond(
38
  messages.append({"role": "user", "content": message})
39
 
40
  response = ""
41
-
42
- for message in client.chat.completions.create(
43
  model="Qwen/Qwen2.5-72B-Instruct",
44
  max_tokens=max_tokens,
45
  stream=True,
46
  temperature=temperature,
47
  top_p=top_p,
48
  messages=messages,
49
- ):
50
- token = message.choices[0].delta.content
 
51
 
52
- response += token
53
- yield response
 
 
54
 
55
  chatbot = gr.Chatbot(height=600)
56
 
 
38
  messages.append({"role": "user", "content": message})
39
 
40
  response = ""
41
+ try:
42
+ _ = client.chat.completions.create(
43
  model="Qwen/Qwen2.5-72B-Instruct",
44
  max_tokens=max_tokens,
45
  stream=True,
46
  temperature=temperature,
47
  top_p=top_p,
48
  messages=messages,
49
+ )
50
+ for message in _:
51
+ token = message.choices[0].delta.content
52
 
53
+ response += token
54
+ yield response
55
+ except Exception as e:
56
+ yield str(e)
57
 
58
  chatbot = gr.Chatbot(height=600)
59