mirror of
https://github.com/hanzoai/python-sdk.git
synced 2026-10-23 20:23:00 +00:00
- Remove random summary files (QUICK_REFERENCE.md, GRPO_*.md, etc.) - Fix pytest-asyncio configuration with asyncio_mode=auto - Fix async_client fixture with @pytest_asyncio.fixture decorator - Fix test imports with correct sys.path for hanzo package - Update hanzo-agent submodule reference - All 2828+ API tests passing
49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
"""Test the fallback handler."""
|
|
|
|
import sys
|
|
import asyncio
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
from rich.console import Console
|
|
|
|
# Add hanzo src to path
|
|
sys.path.insert(0, str(Path(__file__).parent.parent / "pkg" / "hanzo" / "src"))
|
|
|
|
from hanzo.fallback_handler import FallbackHandler, smart_chat
|
|
|
|
|
|
async def test_fallback():
|
|
"""Test the fallback handler."""
|
|
console = Console()
|
|
|
|
console.print("\n[bold cyan]Testing Fallback Handler[/bold cyan]\n")
|
|
|
|
# Create handler and check status
|
|
handler = FallbackHandler()
|
|
handler.print_status(console)
|
|
|
|
# Test smart chat
|
|
console.print("\n[bold]Testing smart chat with automatic fallback:[/bold]")
|
|
|
|
test_message = "What is 2 + 2? Reply with just the number."
|
|
console.print(f"\nMessage: [cyan]{test_message}[/cyan]")
|
|
|
|
response = await smart_chat(test_message, console)
|
|
|
|
if response:
|
|
console.print(f"\n[green]Success! AI responded:[/green]")
|
|
console.print(f"[bold]{response}[/bold]")
|
|
else:
|
|
console.print("\n[red]Failed to get response from any AI option[/red]")
|
|
console.print("\n[yellow]Setup suggestions:[/yellow]")
|
|
console.print(handler.suggest_setup())
|
|
|
|
return response is not None
|
|
|
|
|
|
if __name__ == "__main__":
|
|
success = asyncio.run(test_fallback())
|
|
sys.exit(0 if success else 1)
|