Spaces:
Running
Running
File size: 2,039 Bytes
038867c c0cfae9 038867c |
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 56 57 58 59 60 61 62 63 64 65 66 |
#!/usr/bin/env python3
"""Quick smoke test for the FoodWise inventory agent.
Run with: uv run python scripts/agent_smoke.py
"""
import os
import sys
from pathlib import Path
from dotenv import load_dotenv
# Ensure src is on path for direct script execution and pytest collection contexts
sys.path.insert(0, str(Path(__file__).parent.parent / "src"))
from foodwise.agent.agent import create_inventory_agent, run_agent_query
def main() -> None:
load_dotenv()
if not os.getenv("OPENAI_API_KEY"):
print("β OPENAI_API_KEY not found in environment")
return
if not os.getenv("NOTION_SECRET"):
print("β NOTION_SECRET not found in environment")
return
if not os.getenv("NOTION_INVENTORY_DB_ID"):
print("β NOTION_INVENTORY_DB_ID not found in environment")
return
# Prefer test databases if provided to avoid modifying prod data
test_inventory_db = os.getenv("NOTION_INVENTORY_DB_ID_TEST")
if test_inventory_db:
os.environ["NOTION_INVENTORY_DB_ID"] = test_inventory_db
test_shopping_db = os.getenv("NOTION_SHOPPING_DB_ID_TEST")
if test_shopping_db:
os.environ["NOTION_SHOPPING_DB_ID"] = test_shopping_db
print("π€ Creating FoodWise Inventory Agent...")
try:
agent = create_inventory_agent()
print("β
Agent created successfully!")
except Exception as e:
print(f"β Failed to create agent: {e}")
return
# Read-only prompts to avoid modifying data in smoke checks
test_queries = [
"List a few items from my inventory.",
"Which items are expiring soon?",
"Search for milk in my inventory.",
]
for query in test_queries:
print(f"\nπ Testing: '{query}'")
try:
response = run_agent_query(query, agent)
print(f"π€ Response: {response}")
print("β
Query completed successfully!")
except Exception as e:
print(f"β Query failed: {e}")
if __name__ == "__main__":
main()
|