Spaces:
Running
Running
| """ | |
| Test script for bird classifier agent with multiple scenarios | |
| """ | |
| import asyncio | |
| from simple_demo import create_bird_agent | |
| async def test_agent(): | |
| """Test agent with multiple bird images.""" | |
| # Create agent once | |
| agent = await create_bird_agent() | |
| test_urls = [ | |
| "https://images.unsplash.com/photo-1555169062-013468b47731?w=400", | |
| "https://images.unsplash.com/photo-1445820200644-69f87d946277?w=400&auto=format&fit=crop&q=60&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MTV8fGJpcmR8ZW58MHx8MHx8fDA%3D" | |
| ] | |
| for i, url in enumerate(test_urls, 1): | |
| print("\n"+"="*70) | |
| print(f"[TEST {i}/{len(test_urls)}]: Testing bird classification...") | |
| print("="*70+"\n") | |
| result = await agent.ainvoke({ | |
| "messages": [{ | |
| "role": "user", | |
| "content": f"Classify the bird in this image: {url}" | |
| }] | |
| }) | |
| print("\n[AGENT RESPONSE]:") | |
| print(result["messages"][-1].content) | |
| print("\n[DEMO COMPLETE!]") | |
| if __name__ == "__main__": | |
| asyncio.run(test_agent()) |