1.4 KiB
1.4 KiB
SQL Agent Web UI
A lightweight FastAPI + vanilla JS frontend for interacting with the SugarScale SQL agent.
Backend
Located at db_agent/ui/backend/main.py. It exposes:
POST /api/query– wraps the existing agent pipeline (LLM + optional SQL execution + logging).GET /health– health probe.- Serves the static frontend and index page.
Run locally
# Activate your virtual environment first
uvicorn db_agent.ui.backend.main:app --reload --host 0.0.0.0 --port 8000
The UI will be available at http://localhost:8000/. Adjust the host/port as needed.
Frontend
Files under db_agent/ui/frontend/:
index.html– main page with the question form and results display.static/app.js– handles form submission, fetches/api/query, renders results.static/styles.css– modern styling.
Configuration Notes
- The backend reuses environment variables (
DB_SERVER,DB_DATABASE, etc.) for SQL execution, so ensure they are set before starting the FastAPI server. - The backend expects the LLM endpoint configured in
db_agent/client.LlmConfig.base_url(defaults tohttp://192.168.0.30:8080). Update if your TGI server runs elsewhere. - Interaction logs still append to
db_agent/logs/query_log.jsonlby default.
Next Ideas
- Add user authentication or API keys.
- Save favorite queries or table presets.
- Stream results for large datasets.