Spaces:
Sleeping
Sleeping
File size: 1,595 Bytes
2f25a40 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | """Day 1 smoke test: verify both Gemini and Groq API keys work end-to-end.
Usage:
uv run python scripts/smoke_test.py
"""
from __future__ import annotations
import sys
from pathlib import Path
# Make `researchpath` importable when running this file directly.
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from rich.console import Console
from researchpath.llm import gemini_generate, groq_generate
console = Console()
PROMPT = "In one sentence, what is policy gradient in reinforcement learning?"
def run_provider(name: str, fn) -> bool:
console.print(f"[bold cyan]Testing {name}...[/bold cyan]")
try:
result = fn(PROMPT)
console.print(f"[green]OK[/green] {name} ({result.model}):")
console.print(f" {result.text.strip()}")
if result.input_tokens is not None:
console.print(
f" [dim]tokens: {result.input_tokens} in / {result.output_tokens} out[/dim]"
)
console.print()
return True
except Exception as e:
console.print(f"[red]FAIL {name}:[/red] {e}\n")
return False
def main() -> int:
console.print("[bold]ResearchPath smoke test[/bold]\n")
results = [
run_provider("Gemini", gemini_generate),
run_provider("Groq", groq_generate),
]
if all(results):
console.print("[bold green]All providers working. You're ready for Day 2.[/bold green]")
return 0
console.print("[bold red]One or more providers failed. Fix and re-run.[/bold red]")
return 1
if __name__ == "__main__":
sys.exit(main())
|