Files
controls-web/ai_agents/cane_agent/ui/README.md
2026-02-17 09:29:34 -06:00

36 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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
```powershell
# 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 to `http://192.168.0.30:8080`). Update if your TGI server runs elsewhere.
- Interaction logs still append to `db_agent/logs/query_log.jsonl` by default.
## Next Ideas
- Add user authentication or API keys.
- Save favorite queries or table presets.
- Stream results for large datasets.