Spaces:
Running
Running
Commit ·
02cc090
1
Parent(s): 71cf583
fix: improve model router error handling and add debug logging
Browse files- Strip provider prefix from model names before passing to providers (google/gemini-1.5-flash -> gemini-1.5-flash)
- Fix GoogleProvider 404 error to report actual model name instead of hardcoded 'unknown'
- Add debug logging to router and provider to trace model name resolution
- Handle both bare model names and provider/model format in router
- backend/app/agents/__pycache__/__init__.cpython-314.pyc +0 -0
- backend/app/agents/__pycache__/base.cpython-314.pyc +0 -0
- backend/app/agents/__pycache__/coordinator.cpython-314.pyc +0 -0
- backend/app/agents/__pycache__/extractor.cpython-314.pyc +0 -0
- backend/app/agents/__pycache__/memory_agent.cpython-314.pyc +0 -0
- backend/app/agents/__pycache__/navigator.cpython-314.pyc +0 -0
- backend/app/agents/__pycache__/planner.cpython-314.pyc +0 -0
- backend/app/agents/__pycache__/verifier.cpython-314.pyc +0 -0
- backend/app/models/__pycache__/router.cpython-314.pyc +0 -0
- backend/app/models/providers/__pycache__/google.cpython-314.pyc +0 -0
- backend/app/models/providers/google.py +14 -1
- backend/app/models/router.py +1 -0
- backend/app/search/__pycache__/__init__.cpython-314.pyc +0 -0
- backend/app/search/__pycache__/engine.cpython-314.pyc +0 -0
- backend/app/search/providers/__pycache__/__init__.cpython-314.pyc +0 -0
- backend/app/search/providers/__pycache__/base.cpython-314.pyc +0 -0
- backend/app/search/providers/__pycache__/bing.cpython-314.pyc +0 -0
- backend/app/search/providers/__pycache__/duckduckgo.cpython-314.pyc +0 -0
- backend/app/search/providers/__pycache__/google.cpython-314.pyc +0 -0
- backend/app/tools/__pycache__/__init__.cpython-314.pyc +0 -0
- backend/app/tools/__pycache__/browser.cpython-314.pyc +0 -0
- backend/app/tools/__pycache__/html.cpython-314.pyc +0 -0
- backend/app/tools/__pycache__/registry.cpython-314.pyc +0 -0
- backend/app/tools/__pycache__/search.cpython-314.pyc +0 -0
- backend/app/utils/__pycache__/__init__.cpython-314.pyc +0 -0
- backend/app/utils/__pycache__/html.cpython-314.pyc +0 -0
- backend/app/utils/__pycache__/logging.cpython-314.pyc +0 -0
- backend/hacker_news.csv +31 -0
- backend/tests/__pycache__/__init__.cpython-314.pyc +0 -0
- backend/tests/__pycache__/conftest.cpython-314-pytest-9.0.2.pyc +0 -0
- backend/tests/test_agents/__pycache__/__init__.cpython-314.pyc +0 -0
- backend/tests/test_agents/__pycache__/test_coordinator.cpython-314-pytest-9.0.2.pyc +0 -0
- backend/tests/test_api/__pycache__/__init__.cpython-314.pyc +0 -0
- backend/tests/test_api/__pycache__/test_agents.cpython-314-pytest-9.0.2.pyc +0 -0
- backend/tests/test_api/__pycache__/test_episode.cpython-314-pytest-9.0.2.pyc +0 -0
- backend/tests/test_api/__pycache__/test_health.cpython-314-pytest-9.0.2.pyc +0 -0
- backend/tests/test_api/__pycache__/test_tools.cpython-314-pytest-9.0.2.pyc +0 -0
- backend/tests/test_core/__pycache__/__init__.cpython-314.pyc +0 -0
- backend/tests/test_core/__pycache__/test_action.cpython-314-pytest-9.0.2.pyc +0 -0
- backend/tests/test_core/__pycache__/test_env.cpython-314-pytest-9.0.2.pyc +0 -0
- backend/tests/test_core/__pycache__/test_observation.cpython-314-pytest-9.0.2.pyc +0 -0
- backend/tests/test_core/__pycache__/test_reward.cpython-314-pytest-9.0.2.pyc +0 -0
backend/app/agents/__pycache__/__init__.cpython-314.pyc
DELETED
|
Binary file (1.16 kB)
|
|
|
backend/app/agents/__pycache__/base.cpython-314.pyc
DELETED
|
Binary file (6.75 kB)
|
|
|
backend/app/agents/__pycache__/coordinator.cpython-314.pyc
DELETED
|
Binary file (19.6 kB)
|
|
|
backend/app/agents/__pycache__/extractor.cpython-314.pyc
DELETED
|
Binary file (18 kB)
|
|
|
backend/app/agents/__pycache__/memory_agent.cpython-314.pyc
DELETED
|
Binary file (20.8 kB)
|
|
|
backend/app/agents/__pycache__/navigator.cpython-314.pyc
DELETED
|
Binary file (16.8 kB)
|
|
|
backend/app/agents/__pycache__/planner.cpython-314.pyc
DELETED
|
Binary file (11.5 kB)
|
|
|
backend/app/agents/__pycache__/verifier.cpython-314.pyc
DELETED
|
Binary file (19.2 kB)
|
|
|
backend/app/models/__pycache__/router.cpython-314.pyc
CHANGED
|
Binary files a/backend/app/models/__pycache__/router.cpython-314.pyc and b/backend/app/models/__pycache__/router.cpython-314.pyc differ
|
|
|
backend/app/models/providers/__pycache__/google.cpython-314.pyc
CHANGED
|
Binary files a/backend/app/models/providers/__pycache__/google.cpython-314.pyc and b/backend/app/models/providers/__pycache__/google.cpython-314.pyc differ
|
|
|
backend/app/models/providers/google.py
CHANGED
|
@@ -277,10 +277,15 @@ class GoogleProvider(BaseProvider):
|
|
| 277 |
**kwargs: Any,
|
| 278 |
) -> CompletionResponse:
|
| 279 |
"""Generate a completion using Google AI API."""
|
|
|
|
|
|
|
|
|
|
| 280 |
await self._acquire_rate_limit()
|
| 281 |
|
| 282 |
model = self._resolve_model(model)
|
|
|
|
| 283 |
model_info = self.get_model_info(model)
|
|
|
|
| 284 |
if not model_info:
|
| 285 |
raise ModelNotFoundError(self.PROVIDER_NAME, model)
|
| 286 |
|
|
@@ -424,7 +429,15 @@ class GoogleProvider(BaseProvider):
|
|
| 424 |
message=message,
|
| 425 |
)
|
| 426 |
elif status == 404:
|
| 427 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 428 |
else:
|
| 429 |
raise ProviderError(message, self.PROVIDER_NAME, status)
|
| 430 |
|
|
|
|
| 277 |
**kwargs: Any,
|
| 278 |
) -> CompletionResponse:
|
| 279 |
"""Generate a completion using Google AI API."""
|
| 280 |
+
import logging
|
| 281 |
+
logger = logging.getLogger(__name__)
|
| 282 |
+
logger.info(f"GoogleProvider.complete called with model={model}")
|
| 283 |
await self._acquire_rate_limit()
|
| 284 |
|
| 285 |
model = self._resolve_model(model)
|
| 286 |
+
logger.info(f"GoogleProvider after resolve: model={model}")
|
| 287 |
model_info = self.get_model_info(model)
|
| 288 |
+
logger.info(f"GoogleProvider model_info: {model_info}")
|
| 289 |
if not model_info:
|
| 290 |
raise ModelNotFoundError(self.PROVIDER_NAME, model)
|
| 291 |
|
|
|
|
| 429 |
message=message,
|
| 430 |
)
|
| 431 |
elif status == 404:
|
| 432 |
+
# Extract model name from URL if possible
|
| 433 |
+
model_name = "unknown"
|
| 434 |
+
url = str(error.request.url)
|
| 435 |
+
if "/models/" in url:
|
| 436 |
+
try:
|
| 437 |
+
model_name = url.split("/models/")[1].split(":")[0]
|
| 438 |
+
except Exception:
|
| 439 |
+
pass
|
| 440 |
+
raise ModelNotFoundError(self.PROVIDER_NAME, model_name)
|
| 441 |
else:
|
| 442 |
raise ProviderError(message, self.PROVIDER_NAME, status)
|
| 443 |
|
backend/app/models/router.py
CHANGED
|
@@ -548,6 +548,7 @@ class SmartModelRouter:
|
|
| 548 |
# Strip provider prefix if present (e.g., "google/gemini-1.5-flash" -> "gemini-1.5-flash")
|
| 549 |
model_name = model_id.split("/", 1)[1] if "/" in model_id else model_id
|
| 550 |
logger.info(f"Attempting completion with {provider.PROVIDER_NAME}/{model_name}")
|
|
|
|
| 551 |
response = await provider.complete(messages, model_name, **kwargs)
|
| 552 |
|
| 553 |
# Track cost
|
|
|
|
| 548 |
# Strip provider prefix if present (e.g., "google/gemini-1.5-flash" -> "gemini-1.5-flash")
|
| 549 |
model_name = model_id.split("/", 1)[1] if "/" in model_id else model_id
|
| 550 |
logger.info(f"Attempting completion with {provider.PROVIDER_NAME}/{model_name}")
|
| 551 |
+
logger.debug(f"Router: model_id={model_id}, model_name={model_name}, provider={provider.PROVIDER_NAME}")
|
| 552 |
response = await provider.complete(messages, model_name, **kwargs)
|
| 553 |
|
| 554 |
# Track cost
|
backend/app/search/__pycache__/__init__.cpython-314.pyc
CHANGED
|
Binary files a/backend/app/search/__pycache__/__init__.cpython-314.pyc and b/backend/app/search/__pycache__/__init__.cpython-314.pyc differ
|
|
|
backend/app/search/__pycache__/engine.cpython-314.pyc
CHANGED
|
Binary files a/backend/app/search/__pycache__/engine.cpython-314.pyc and b/backend/app/search/__pycache__/engine.cpython-314.pyc differ
|
|
|
backend/app/search/providers/__pycache__/__init__.cpython-314.pyc
CHANGED
|
Binary files a/backend/app/search/providers/__pycache__/__init__.cpython-314.pyc and b/backend/app/search/providers/__pycache__/__init__.cpython-314.pyc differ
|
|
|
backend/app/search/providers/__pycache__/base.cpython-314.pyc
CHANGED
|
Binary files a/backend/app/search/providers/__pycache__/base.cpython-314.pyc and b/backend/app/search/providers/__pycache__/base.cpython-314.pyc differ
|
|
|
backend/app/search/providers/__pycache__/bing.cpython-314.pyc
CHANGED
|
Binary files a/backend/app/search/providers/__pycache__/bing.cpython-314.pyc and b/backend/app/search/providers/__pycache__/bing.cpython-314.pyc differ
|
|
|
backend/app/search/providers/__pycache__/duckduckgo.cpython-314.pyc
CHANGED
|
Binary files a/backend/app/search/providers/__pycache__/duckduckgo.cpython-314.pyc and b/backend/app/search/providers/__pycache__/duckduckgo.cpython-314.pyc differ
|
|
|
backend/app/search/providers/__pycache__/google.cpython-314.pyc
CHANGED
|
Binary files a/backend/app/search/providers/__pycache__/google.cpython-314.pyc and b/backend/app/search/providers/__pycache__/google.cpython-314.pyc differ
|
|
|
backend/app/tools/__pycache__/__init__.cpython-314.pyc
CHANGED
|
Binary files a/backend/app/tools/__pycache__/__init__.cpython-314.pyc and b/backend/app/tools/__pycache__/__init__.cpython-314.pyc differ
|
|
|
backend/app/tools/__pycache__/browser.cpython-314.pyc
CHANGED
|
Binary files a/backend/app/tools/__pycache__/browser.cpython-314.pyc and b/backend/app/tools/__pycache__/browser.cpython-314.pyc differ
|
|
|
backend/app/tools/__pycache__/html.cpython-314.pyc
CHANGED
|
Binary files a/backend/app/tools/__pycache__/html.cpython-314.pyc and b/backend/app/tools/__pycache__/html.cpython-314.pyc differ
|
|
|
backend/app/tools/__pycache__/registry.cpython-314.pyc
CHANGED
|
Binary files a/backend/app/tools/__pycache__/registry.cpython-314.pyc and b/backend/app/tools/__pycache__/registry.cpython-314.pyc differ
|
|
|
backend/app/tools/__pycache__/search.cpython-314.pyc
CHANGED
|
Binary files a/backend/app/tools/__pycache__/search.cpython-314.pyc and b/backend/app/tools/__pycache__/search.cpython-314.pyc differ
|
|
|
backend/app/utils/__pycache__/__init__.cpython-314.pyc
CHANGED
|
Binary files a/backend/app/utils/__pycache__/__init__.cpython-314.pyc and b/backend/app/utils/__pycache__/__init__.cpython-314.pyc differ
|
|
|
backend/app/utils/__pycache__/html.cpython-314.pyc
CHANGED
|
Binary files a/backend/app/utils/__pycache__/html.cpython-314.pyc and b/backend/app/utils/__pycache__/html.cpython-314.pyc differ
|
|
|
backend/app/utils/__pycache__/logging.cpython-314.pyc
CHANGED
|
Binary files a/backend/app/utils/__pycache__/logging.cpython-314.pyc and b/backend/app/utils/__pycache__/logging.cpython-314.pyc differ
|
|
|
backend/hacker_news.csv
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
title,link,points
|
| 2 |
+
,,914 points
|
| 3 |
+
,,392 points
|
| 4 |
+
,,172 points
|
| 5 |
+
,,541 points
|
| 6 |
+
,,417 points
|
| 7 |
+
,,193 points
|
| 8 |
+
,,197 points
|
| 9 |
+
,,283 points
|
| 10 |
+
,,253 points
|
| 11 |
+
,,8 points
|
| 12 |
+
,,84 points
|
| 13 |
+
,,19 points
|
| 14 |
+
,,703 points
|
| 15 |
+
,,66 points
|
| 16 |
+
,,25 points
|
| 17 |
+
,,280 points
|
| 18 |
+
,,125 points
|
| 19 |
+
,,11 points
|
| 20 |
+
,,148 points
|
| 21 |
+
,,112 points
|
| 22 |
+
,,160 points
|
| 23 |
+
,,52 points
|
| 24 |
+
,,394 points
|
| 25 |
+
,,123 points
|
| 26 |
+
,,103 points
|
| 27 |
+
,,152 points
|
| 28 |
+
,,83 points
|
| 29 |
+
,,105 points
|
| 30 |
+
,,254 points
|
| 31 |
+
,,
|
backend/tests/__pycache__/__init__.cpython-314.pyc
DELETED
|
Binary file (189 Bytes)
|
|
|
backend/tests/__pycache__/conftest.cpython-314-pytest-9.0.2.pyc
DELETED
|
Binary file (3.61 kB)
|
|
|
backend/tests/test_agents/__pycache__/__init__.cpython-314.pyc
DELETED
|
Binary file (197 Bytes)
|
|
|
backend/tests/test_agents/__pycache__/test_coordinator.cpython-314-pytest-9.0.2.pyc
DELETED
|
Binary file (6.29 kB)
|
|
|
backend/tests/test_api/__pycache__/__init__.cpython-314.pyc
DELETED
|
Binary file (191 Bytes)
|
|
|
backend/tests/test_api/__pycache__/test_agents.cpython-314-pytest-9.0.2.pyc
DELETED
|
Binary file (3.62 kB)
|
|
|
backend/tests/test_api/__pycache__/test_episode.cpython-314-pytest-9.0.2.pyc
DELETED
|
Binary file (7.86 kB)
|
|
|
backend/tests/test_api/__pycache__/test_health.cpython-314-pytest-9.0.2.pyc
DELETED
|
Binary file (3.84 kB)
|
|
|
backend/tests/test_api/__pycache__/test_tools.cpython-314-pytest-9.0.2.pyc
DELETED
|
Binary file (3.59 kB)
|
|
|
backend/tests/test_core/__pycache__/__init__.cpython-314.pyc
DELETED
|
Binary file (193 Bytes)
|
|
|
backend/tests/test_core/__pycache__/test_action.cpython-314-pytest-9.0.2.pyc
DELETED
|
Binary file (12.7 kB)
|
|
|
backend/tests/test_core/__pycache__/test_env.cpython-314-pytest-9.0.2.pyc
DELETED
|
Binary file (4.03 kB)
|
|
|
backend/tests/test_core/__pycache__/test_observation.cpython-314-pytest-9.0.2.pyc
DELETED
|
Binary file (10.5 kB)
|
|
|
backend/tests/test_core/__pycache__/test_reward.cpython-314-pytest-9.0.2.pyc
DELETED
|
Binary file (3.29 kB)
|
|
|