akiko19191 commited on
Commit
6c77561
·
verified ·
1 Parent(s): 48de080

Update utils/llms.py

Browse files
Files changed (1) hide show
  1. utils/llms.py +13 -17
utils/llms.py CHANGED
@@ -67,21 +67,20 @@ def chatstream(messages,model,api_keys):
67
  pass
68
  yield ("RESULT: "+cunk)
69
  elif model == "Qwen3-235B-A22B" or model == "Qwen3-30B-A3B" or model == "Qwen3-32B":
70
- try:
71
- response = client.chat.completions.create(
72
- provider=DeepInfraChat,
73
- model=f"Qwen/{model}",
74
- messages=messages,
75
- stream=True
76
 
77
- )
78
- for part in response:
79
- cunk=cunk+(part.choices[0].delta.content or "")
80
- if "```json" not in cunk or "```" not in cunk:
81
- yield (part.choices[0].delta.content or "")
82
- except Exception as e:
83
- pass
84
- yield ("RESULT: "+cunk)
85
  elif model == "DeepSeekR1-togetherAI":
86
  response = completion(model="together_ai/deepseek-ai/DeepSeek-R1", messages=messages, stream=True)
87
 
@@ -150,9 +149,6 @@ def chatstream(messages,model,api_keys):
150
  x=str(part.choices[0].delta.content)
151
  # print(part.choices[0])
152
  # x=x.replace(">","> \n \n s ")
153
- # # if "</think>" in str(part.choices[0].delta.content):
154
- # # yield(part.choices[0].delta.content.replace("</think>","") or "")
155
- # # print(part.choices[0].delta.content.replace("</think>","</think> \n \n ") or "", end="")
156
  if "```json" not in cunk:
157
  if "None" not in x:
158
  yield(x or "")
 
67
  pass
68
  yield ("RESULT: "+cunk)
69
  elif model == "Qwen3-235B-A22B" or model == "Qwen3-30B-A3B" or model == "Qwen3-32B":
70
+ response = client.chat.completions.create(
71
+ provider=DeepInfraChat,
72
+ model=f"Qwen/{model}",
73
+ messages=messages,
74
+ stream=True
 
75
 
76
+ )
77
+ for part in response:
78
+ resp=str(part.choices[0].delta.content)
79
+ cunk=cunk+(resp or "")
80
+
81
+ if ("```json" not in cunk or "```" not in cunk) and resp != "None":
82
+ yield (resp or "")
83
+ yield ("RESULT: "+str(cunk))
84
  elif model == "DeepSeekR1-togetherAI":
85
  response = completion(model="together_ai/deepseek-ai/DeepSeek-R1", messages=messages, stream=True)
86
 
 
149
  x=str(part.choices[0].delta.content)
150
  # print(part.choices[0])
151
  # x=x.replace(">","> \n \n s ")
 
 
 
152
  if "```json" not in cunk:
153
  if "None" not in x:
154
  yield(x or "")