feat(devgen/providers): normalize token limit error handling
Add token limit error detection and formatting across all provider modules to surface clear diagnostics when context windows are exceeded, improving error messages and preventing silent failures. New Features - Introduce `is_token_limit_error` checks in Anthropic, Gemini, Hugging Face, Ollama, OpenAI, and OpenRouter providers. - Use `format_token_limit_error` to generate user‑friendly error messages for token limit overs. Enhancements - Centralize token limit error handling for consistent diagnostics across providers. - Explicitly re‑raise `RuntimeError` in Hugging Face to preserve original behavior. Bug Fixes - None
This commit is contained in:
6 files changed
+37
-1
No files matched your search
@@ -1,3 +1,4 @@
|
||||
from devgen.utils import format_token_limit_error, is_token_limit_error
|
||||
|
||||
|
||||
class OllamaProvider:
|
||||
@@ -37,6 +38,8 @@ class OllamaProvider:
|
||||
**kwargs,
|
||||
)
|
||||
except Exception as e:
|
||||
if is_token_limit_error(e):
|
||||
raise RuntimeError(format_token_limit_error("Ollama", e)) from e
|
||||
raise RuntimeError(
|
||||
f"Ollama request failed (host={host}, model={chosen_model}): {e}. "
|
||||
"Is the Ollama server running? Start it with `ollama serve` and "
|
||||
|
||||
Reference in new issue
Block a user