sankalphs commited on
Commit
1c45b4e
·
1 Parent(s): 724f227

fix: switch to microsoft/Phi-3-mini-4k-instruct (Gemma 2B down, LoRA not on serverless API)

Browse files
Files changed (1) hide show
  1. agents.py +11 -3
agents.py CHANGED
@@ -25,7 +25,7 @@ _MODEL_DIR = Path(__file__).resolve().parent / "models"
25
  MODEL_PATH = os.getenv("MODEL_PATH") or str(_MODEL_DIR / "NVIDIA-Nemotron-3-Nano-4B.Q4_K_M.gguf")
26
 
27
  _HF_TOKEN = os.getenv("HF_TOKEN", "")
28
- _HF_MODEL = os.getenv("HF_MODEL", "sankalphs/retro-alpha-nemotron-lora")
29
 
30
  _client = None
31
  _llm_status = "mock"
@@ -67,8 +67,16 @@ def _hf_generate(messages: list, max_tokens: int = 256, temperature: float = 0.7
67
  return clean_text(content)
68
  except Exception as e:
69
  global _llm_status, _llm_error
70
- print(f"HF API call failed: {type(e).__name__}: {e}")
71
- _llm_error = str(e)[:120]
 
 
 
 
 
 
 
 
72
  if _llm_status == "loading":
73
  _llm_status = "error"
74
  return ""
 
25
  MODEL_PATH = os.getenv("MODEL_PATH") or str(_MODEL_DIR / "NVIDIA-Nemotron-3-Nano-4B.Q4_K_M.gguf")
26
 
27
  _HF_TOKEN = os.getenv("HF_TOKEN", "")
28
+ _HF_MODEL = os.getenv("HF_MODEL", "microsoft/Phi-3-mini-4k-instruct")
29
 
30
  _client = None
31
  _llm_status = "mock"
 
67
  return clean_text(content)
68
  except Exception as e:
69
  global _llm_status, _llm_error
70
+ msg = str(e)
71
+ # Extract the actual API error message if present
72
+ try:
73
+ body = e.response.json() if hasattr(e, 'response') else None
74
+ if body and isinstance(body, dict):
75
+ msg = str(body.get("error", body.get("message", msg)))
76
+ except Exception:
77
+ pass
78
+ _llm_error = msg[:200]
79
+ print(f"HF API call failed: {msg[:200]}")
80
  if _llm_status == "loading":
81
  _llm_status = "error"
82
  return ""