ai: Better json decode with 2.1.1-ft-QwQ-32B version.
Browse files
jarvis.py
CHANGED
@@ -153,12 +153,15 @@ async def fetch_response_async(host, provider_key, selected_model, messages, mod
|
|
153 |
extra = {"optillm_approach": "rto|re2|cot_reflection|self_consistency|plansearch|leap|z3|bon|moa|mcts|mcp|router|privacy|executecode|json", "session_id": session_id}
|
154 |
response = await client.post(f"{host}", json={**data, "extra_body": extra, "session_id": session_id}, headers={"Authorization": f"Bearer {provider_key}"})
|
155 |
response.raise_for_status()
|
156 |
-
|
|
|
|
|
|
|
157 |
ai_text = resp_json["choices"][0]["message"]["content"] if resp_json.get("choices") and resp_json["choices"][0].get("message") and resp_json["choices"][0]["message"].get("content") else RESPONSES["RESPONSE_2"]
|
158 |
return process_ai_response(ai_text)
|
159 |
except Exception:
|
160 |
marked_item(provider_key, LINUX_SERVER_PROVIDER_KEYS_MARKED, LINUX_SERVER_PROVIDER_KEYS_ATTEMPTS)
|
161 |
-
|
162 |
|
163 |
async def chat_with_model_async(history, user_input, selected_model_display, sess):
|
164 |
if not get_available_items(LINUX_SERVER_PROVIDER_KEYS, LINUX_SERVER_PROVIDER_KEYS_MARKED) or not get_available_items(LINUX_SERVER_HOSTS, LINUX_SERVER_HOSTS_MARKED):
|
|
|
153 |
extra = {"optillm_approach": "rto|re2|cot_reflection|self_consistency|plansearch|leap|z3|bon|moa|mcts|mcp|router|privacy|executecode|json", "session_id": session_id}
|
154 |
response = await client.post(f"{host}", json={**data, "extra_body": extra, "session_id": session_id}, headers={"Authorization": f"Bearer {provider_key}"})
|
155 |
response.raise_for_status()
|
156 |
+
try:
|
157 |
+
resp_json = response.json()
|
158 |
+
except json.JSONDecodeError:
|
159 |
+
return RESPONSES["RESPONSE_2"]
|
160 |
ai_text = resp_json["choices"][0]["message"]["content"] if resp_json.get("choices") and resp_json["choices"][0].get("message") and resp_json["choices"][0]["message"].get("content") else RESPONSES["RESPONSE_2"]
|
161 |
return process_ai_response(ai_text)
|
162 |
except Exception:
|
163 |
marked_item(provider_key, LINUX_SERVER_PROVIDER_KEYS_MARKED, LINUX_SERVER_PROVIDER_KEYS_ATTEMPTS)
|
164 |
+
return RESPONSES["RESPONSE_2"]
|
165 |
|
166 |
async def chat_with_model_async(history, user_input, selected_model_display, sess):
|
167 |
if not get_available_items(LINUX_SERVER_PROVIDER_KEYS, LINUX_SERVER_PROVIDER_KEYS_MARKED) or not get_available_items(LINUX_SERVER_HOSTS, LINUX_SERVER_HOSTS_MARKED):
|