Spaces:
Building
Building
Update utils/llms.py
Browse files- utils/llms.py +19 -2
utils/llms.py
CHANGED
@@ -123,7 +123,7 @@ def gpt4stream(messages,model,api_keys):
|
|
123 |
try:
|
124 |
os.environ["GEMINI_API_KEY"] =key
|
125 |
|
126 |
-
response = completion(model="gemini
|
127 |
|
128 |
cunk=""
|
129 |
for part in response:
|
@@ -136,6 +136,23 @@ def gpt4stream(messages,model,api_keys):
|
|
136 |
pass
|
137 |
helper.q.put_nowait("RESULT: "+cunk)
|
138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
|
140 |
elif model=="deepseek.r1" or model=="deepseek-chat":
|
141 |
cunk=""
|
@@ -173,7 +190,7 @@ def gpt4stream(messages,model,api_keys):
|
|
173 |
helper.q.put_nowait(part.choices[0].delta.content or "")
|
174 |
break
|
175 |
except Exception as e:
|
176 |
-
helper.q.put_nowait(str(e))
|
177 |
pass
|
178 |
print("STOPPING")
|
179 |
helper.q.put_nowait("RESULT: "+cunk)
|
|
|
123 |
try:
|
124 |
os.environ["GEMINI_API_KEY"] =key
|
125 |
|
126 |
+
response = completion(model="gemini-2.0-flash-thinking-exp-01-21", messages=messages, stream=True)
|
127 |
|
128 |
cunk=""
|
129 |
for part in response:
|
|
|
136 |
pass
|
137 |
helper.q.put_nowait("RESULT: "+cunk)
|
138 |
|
139 |
+
elif "gemini-2.5-pro-exp-03-25" :
|
140 |
+
for key in gemini_api_keys:
|
141 |
+
try:
|
142 |
+
os.environ["GEMINI_API_KEY"] =key
|
143 |
+
|
144 |
+
response = completion(model="gemini/gemini-2.5-pro-exp-03-25", messages=messages, stream=True)
|
145 |
+
|
146 |
+
cunk=""
|
147 |
+
for part in response:
|
148 |
+
cunk=cunk+(part.choices[0].delta.content or "")
|
149 |
+
if "```json" not in cunk:
|
150 |
+
helper.q.put_nowait(part.choices[0].delta.content or "")
|
151 |
+
break
|
152 |
+
except:
|
153 |
+
del response
|
154 |
+
pass
|
155 |
+
helper.q.put_nowait("RESULT: "+cunk)
|
156 |
|
157 |
elif model=="deepseek.r1" or model=="deepseek-chat":
|
158 |
cunk=""
|
|
|
190 |
helper.q.put_nowait(part.choices[0].delta.content or "")
|
191 |
break
|
192 |
except Exception as e:
|
193 |
+
#helper.q.put_nowait(str(e))
|
194 |
pass
|
195 |
print("STOPPING")
|
196 |
helper.q.put_nowait("RESULT: "+cunk)
|