Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files960 unmodified lines9619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000960 unmodified linesf"or image, use download_task_file(task_id='{task_id}') to inspect it.")models_to_try = list(getattr(self, "working_models", []) or [self.model_id])if self.model_id not in models_to_try:models_to_try.append(self.model_id)for model_name in models_to_try:api_key = self._get_api_key(model_name) if hasattr(self, "_get_api_key") else Noneif not api_key:continuefor attempt in range(2):try:response = litellm.completion(model=model_name,api_key=api_key,messages=[{"role": "system","content": ("Answer with ONLY the concise exact answer value itself. ""No explanation, no markdown, no prefix."),},{"role": "user", "content": prompt},],max_tokens=512,timeout=25,)content = (response.choices[0].message.content or "").strip()if content:self.model_id = model_namereturn self._clean_exact_match_answer(content)except Exception as exc:print(f"[DIRECT FALLBACK] task_id={task_id} model={model_name} attempt={attempt + 1}: {exc}")if attempt == 0:time.sleep(1.5)try:result = self.agent.run(prompt)960 unmodified lines961962963964965966967968969970971972973974975976977978979980981960 unmodified linesf"or image, use download_task_file(task_id='{task_id}') to inspect it.")blocked_models = getattr(self, "_blocked_models", None)if blocked_models is None:blocked_models = set()self._blocked_models = blocked_modelsmodels_to_try = list(getattr(self, "working_models", []) or [self.model_id])if self.model_id and self.model_id not in models_to_try:models_to_try.append(self.model_id)models_to_try = [m for m in models_to_tryif m not in blocked_modelsand not (m.startswith("openrouter/") and not self.provider_keys.get("openrouter"))]models_to_try.sort(key=lambda m: (1 if m.startswith("gemini/") else 0))try:result = self.agent.run(prompt)
app.py+12-31