Improve provider error messages with install suggestion

- Add "smarttools providers install" suggestion when command not found
- Add suggestion when provider exits with error containing "not found"
- Detect empty output and warn about unavailable model
- Show stderr hint when provider returns nothing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
rob 2025-12-30 01:11:00 -04:00
parent c1499e76d2
commit 9d783af2f9
1 changed files with 14 additions and 2 deletions

View File

@ -174,7 +174,7 @@ def call_provider(provider_name: str, prompt: str, timeout: int = 300) -> Provid
return ProviderResult(
text="",
success=False,
error=f"Command '{base_cmd}' not found. Is it installed and in PATH?"
error=f"Command '{base_cmd}' not found. Is it installed and in PATH?\n\nTo install AI providers, run: smarttools providers install"
)
try:
@ -188,10 +188,22 @@ def call_provider(provider_name: str, prompt: str, timeout: int = 300) -> Provid
)
if result.returncode != 0:
error_msg = f"Provider exited with code {result.returncode}: {result.stderr}"
if "not found" in result.stderr.lower() or "not installed" in result.stderr.lower():
error_msg += "\n\nTo install AI providers, run: smarttools providers install"
return ProviderResult(
text="",
success=False,
error=f"Provider exited with code {result.returncode}: {result.stderr}"
error=error_msg
)
# Warn if output is empty (provider ran but returned nothing)
if not result.stdout.strip():
stderr_hint = f" (stderr: {result.stderr.strip()})" if result.stderr.strip() else ""
return ProviderResult(
text="",
success=False,
error=f"Provider returned empty output{stderr_hint}.\n\nThis may mean the model is not available. Try a different provider or run: smarttools providers install"
)
return ProviderResult(text=result.stdout, success=True)