-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_agent_e2e.py
More file actions
44 lines (32 loc) · 1.07 KB
/
test_agent_e2e.py
File metadata and controls
44 lines (32 loc) · 1.07 KB
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
"""End-to-end test of the Text2SQL agent."""
import asyncio
import os
# Set env vars before importing app modules
os.environ.setdefault("DATABASE_URL", "sqlite:///./data/test.db")
async def test_agent():
from dotenv import load_dotenv
load_dotenv(override=True)
from app.agent import get_agent_engine
print("Initializing agent...")
engine = await get_agent_engine()
print("Agent ready!")
query = "Show me all active users with their total order amounts"
print(f"\nQuery: {query}")
print("Generating SQL...")
result = await engine.generate_sql(
natural_query=query,
database_id="default",
execute=True,
show_reasoning=True,
)
print("\n" + "=" * 50)
print("FINAL RESULT")
print("=" * 50)
print(f"SQL: {result.sql}")
print(f"Confidence: {result.confidence}")
if result.execution_results:
print(f"Rows returned: {len(result.execution_results)}")
for row in result.execution_results:
print(f" {row}")
if __name__ == "__main__":
asyncio.run(test_agent())