Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files909 unmodified lines91091191291391491577 unmodified lines993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041909 unmodified lines}if model_name.startswith("gemini/"):kwargs["reasoning_effort"] = "low"return self._model_cls(**kwargs)self._build_model = _build_model77 unmodified linesreturn textdef __call__(self, question: str, task_id: str = "") -> str:prompt = question.strip()if task_id:prompt += (f"\n\nTask ID: {task_id}. If the question references an attached file "f"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"))]for model_name in models_to_try:if not hasattr(self, "_build_model") or not hasattr(self, "agent"):breaktry:self.model_id = model_nameself.agent.model = self._build_model(model_name)result = self.agent.run(prompt)cleaned = self._clean_exact_match_answer("" if result is None else str(result).strip())if cleaned and not cleaned.startswith("AGENT ERROR:"):return cleanedexcept Exception as exc:err_text = str(exc)err_lower = err_text.lower()print(f"[AGENT ERROR] task_id={task_id} model={model_name}: {err_text}")if any(marker in err_lowerfor marker in ("429", "quota", "resource_exhausted", "401", "authentication", "empty model response")):blocked_models.add(model_name)return "AGENT ERROR: All candidate models failed."def run_and_submit_all(profile: gr.OAuthProfile | None):909 unmodified lines91091191291391491591691777 unmodified lines99599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052909 unmodified lines}if model_name.startswith("gemini/"):kwargs["reasoning_effort"] = "low"elif model_name.startswith("groq/"):kwargs["tool_choice"] = "auto"return self._model_cls(**kwargs)self._build_model = _build_model77 unmodified linesreturn textdef __call__(self, question: str, task_id: str = "") -> str:prompt = question.strip()if task_id:prompt += (f"\n\nTask ID: {task_id}. If the question references an attached file "f"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"))]for model_name in models_to_try:if not hasattr(self, "_build_model") or not hasattr(self, "agent"):breaktry:self.model_id = model_nameself.agent.model = self._build_model(model_name)result = self.agent.run(prompt)cleaned = self._clean_exact_match_answer("" if result is None else str(result).strip())if cleaned and not cleaned.startswith("AGENT ERROR:"):return cleanedexcept Exception as exc:err_text = str(exc)err_lower = err_text.lower()print(f"[AGENT ERROR] task_id={task_id} model={model_name}: {err_text}")if any(marker in err_lowerfor marker in ("429","quota","resource_exhausted","401","403","authentication","insufficient permissions","empty model response",)):blocked_models.add(model_name)return "AGENT ERROR: All candidate models failed."def run_and_submit_all(profile: gr.OAuthProfile | None):
app.py+49-38