galbendavids's picture
ืืจื’ื•ืŸ ืžื—ื“ืฉ ืฉืœ ื”ืกืคืจื™ื”: ืžื—ื™ืงืช CreationDate, ืืจื’ื•ืŸ ืœืคื™ 0_preprocessing, 1_frontend, 2_backend_llm
9a7cb3e
#!/usr/bin/env python3
"""Simple smoke check that hits the running FastAPI server root and /query.
This uses only the standard library so it should work in the project's venv.
"""
from __future__ import annotations
import json
import urllib.request
def get_root() -> str:
with urllib.request.urlopen("http://127.0.0.1:8000/") as resp:
return resp.read().decode("utf-8")
def post_query(q: str):
"""Test SQL-based query endpoint."""
data = json.dumps({"query": q, "top_k": 5}).encode("utf-8")
req = urllib.request.Request("http://127.0.0.1:8000/query-sql", data=data, headers={"Content-Type": "application/json"})
with urllib.request.urlopen(req, timeout=30) as resp:
return json.load(resp)
def main() -> None:
print("Checking http://127.0.0.1:8000/ ...")
try:
root = get_root()
print("Root response length:", len(root))
except Exception as e:
print("Failed to GET root:", e)
return
sample_q = "ืžื” ื”ื‘ืขื™ื•ืช ื”ืขื™ืงืจื™ื•ืช ืฉืžืฉืชืžืฉื™ื ืžืฆื™ื™ื ื™ื?"
print("Posting sample query to /query-sql ...")
try:
resp = post_query(sample_q)
print("Query response keys:", list(resp.keys()))
print("Summary (truncated):\n", (resp.get("summary") or "(no summary)")[:800])
if resp.get("sql_queries"):
print(f"Generated {len(resp['sql_queries'])} SQL queries")
except Exception as e:
print("Failed to POST /query-sql:", e)
if __name__ == "__main__":
main()