Hermes Agent commited on
Commit
aade49f
·
1 Parent(s): c373985

fix(hermes): dynamically resolve auto model to synced NVIDIA NIM / Antigravity model IDs before posting to OmniRoute

Browse files
Files changed (1) hide show
  1. gateway/hermes_standalone.py +14 -0
gateway/hermes_standalone.py CHANGED
@@ -224,6 +224,20 @@ async def chat_completions(request: Request):
224
  target_endpoint = f"{base_url}/chat/completions"
225
 
226
  async with httpx.AsyncClient(timeout=30.0) as client:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  try:
228
  r = await client.post(target_endpoint, json=payload, headers=headers)
229
  duration_ms = (time.time() - t0) * 1000
 
224
  target_endpoint = f"{base_url}/chat/completions"
225
 
226
  async with httpx.AsyncClient(timeout=30.0) as client:
227
+ if target_model == "auto":
228
+ try:
229
+ m_res = await client.get(f"{base_url}/models", headers=headers, timeout=5.0)
230
+ if m_res.status_code == 200:
231
+ m_data = m_res.json()
232
+ m_list = m_data.get("data") if isinstance(m_data, dict) else []
233
+ synced_models = [m["id"] for m in m_list if isinstance(m, dict) and m.get("id") and m["id"] not in ("hermes-agent", "auto")]
234
+ if synced_models:
235
+ target_model = synced_models[0]
236
+ payload["model"] = target_model
237
+ logger.info(f"[HERMES MODEL RESOLVE] Resolved 'auto' -> '{target_model}'")
238
+ except Exception as me:
239
+ logger.warning(f"[HERMES MODEL RESOLVE] Error resolving auto model: {me}")
240
+
241
  try:
242
  r = await client.post(target_endpoint, json=payload, headers=headers)
243
  duration_ms = (time.time() - t0) * 1000