mirror of
https://github.com/hanzoai/python-sdk.git
synced 2026-10-23 20:23:00 +00:00
Fix 35 ruff errors (E722, F841, B904, B905, B007, E741, S202, S310, S306, S110, TID251, UP042, F401) and run black on 526 files. Co-authored-by: Hanzo Dev <[email protected]>
53 lines
1.3 KiB
Python
53 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Quick test of Agent SDK
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
|
|
sys.path.insert(0, "src")
|
|
|
|
# For synchronous execution
|
|
from agents import Agent, Runner
|
|
|
|
# Create a simple agent
|
|
agent = Agent(
|
|
name="MathHelper",
|
|
instructions="You are a helpful assistant. Answer concisely.",
|
|
)
|
|
|
|
# Make sure we have an API key
|
|
if not os.getenv("OPENAI_API_KEY") and not os.getenv("ANTHROPIC_API_KEY"):
|
|
# Set a dummy key for now
|
|
os.environ["OPENAI_API_KEY"] = "sk-dummy"
|
|
|
|
print("Testing Agent SDK...")
|
|
print("Question: What's 1+2?")
|
|
print("-" * 40)
|
|
|
|
try:
|
|
# Use the synchronous runner
|
|
result = Runner.run_sync(agent, "What's 1+2?")
|
|
print(f"Answer: {result.final_output}")
|
|
except Exception as e:
|
|
print(f"Error: {e}")
|
|
|
|
# Try with explicit provider
|
|
print("\nTrying with Hanzo Router...")
|
|
from agents.models.openai_provider import OpenAIProvider
|
|
|
|
provider = OpenAIProvider(base_url="http://localhost:4000/v1", api_key="sk-1234")
|
|
|
|
try:
|
|
from agents import RunConfig
|
|
|
|
result = Runner.run_sync(
|
|
agent,
|
|
"What's 1+2?",
|
|
run_config=RunConfig(model_provider=provider, model="gpt-3.5-turbo"),
|
|
)
|
|
print(f"Answer: {result.final_output}")
|
|
except Exception as e2:
|
|
print(f"Router Error: {e2}")
|