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:
parent
c1499e76d2
commit
9d783af2f9
|
|
@ -174,7 +174,7 @@ def call_provider(provider_name: str, prompt: str, timeout: int = 300) -> Provid
|
||||||
return ProviderResult(
|
return ProviderResult(
|
||||||
text="",
|
text="",
|
||||||
success=False,
|
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:
|
try:
|
||||||
|
|
@ -188,10 +188,22 @@ def call_provider(provider_name: str, prompt: str, timeout: int = 300) -> Provid
|
||||||
)
|
)
|
||||||
|
|
||||||
if result.returncode != 0:
|
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(
|
return ProviderResult(
|
||||||
text="",
|
text="",
|
||||||
success=False,
|
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)
|
return ProviderResult(text=result.stdout, success=True)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue