| title | SQL Query Agent Environment |
|---|---|
| emoji | 🤖 |
| colorFrom | blue |
| colorTo | green |
| sdk | python |
| sdk_version | |
| python_version | 3.10 |
| app_file | app.py |
| pinned | false |
A minimal but fully working SQL Query Agent Environment for hackathon validation with OpenEnv-compatible endpoints.
.
├── Dockerfile # Docker container configuration
├── README.md # This file
├── requirements.txt # Python dependencies
├── openenv.yaml # OpenEnv configuration
├── app.py # Gradio UI application
├── inference.py # Main inference module
├── baseline_inference.py # Baseline inference module
├── models.py # Pydantic models
├── ecommerce.db # SQLite database (auto-created)
├── __init__.py # Package init
├── server/
│ ├── __init__.py
│ └── app.py # FastAPI application
└── tests/
└── test_smoke.py # Smoke tests
- SQLite-backed ecommerce database with sample data
- OpenEnv-compatible reset/step/state API
- FastAPI application with health checks
- Read-only SQL query execution
- Automatic database initialization
python3 -m venv .venv
source .venv/bin/activatepip install -r requirements.txtuvicorn server.app:app --host 0.0.0.0 --port 7860Or run directly with Python:
python -c "from server.app import app; import uvicorn; uvicorn.run(app, host='0.0.0.0', port=7860)"# Health check
curl -X GET http://localhost:7860/health
# Get state
curl -X GET http://localhost:7860/state
# Reset environment
curl -X POST http://localhost:7860/reset \
-H 'Content-Type: application/json' \
-d '{"task_id":"task_1"}'
# Execute SQL query
curl -X POST http://localhost:7860/step \
-H 'Content-Type: application/json' \
-d '{"query":"SELECT COUNT(*) FROM customers;","task_id":"task_1"}'source .venv/bin/activate
openenv validate| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Root response |
/health |
GET | Health check |
/state |
GET | Get current environment state |
/reset |
POST | Reset environment and get task info |
/step |
POST | Execute SQL query and get observation |
/docs |
GET | FastAPI auto documentation |
# Install huggingface_hub
pip install huggingface_hub
# Login
huggingface-cli login
# Create space
huggingface-cli create-repo sql-query-agent --type space
# Clone and push
git clone https://huggingface.co/spaces/YOUR_USERNAME/sql-query-agent
cd sql-query-agent
# Copy all files from this repo
git add .
git commit -m "Initial commit"
git push- Create a new Space on Hugging Face
- Select "Docker" as the SDK
- Add your Dockerfile and requirements.txt
- HF will automatically build and deploy
The environment includes an ecommerce database with these tables:
- customers: Customer information
- categories: Product categories
- products: Product catalog
- orders: Customer orders
- order_items: Individual order items
| Task ID | Description |
|---|---|
| task_1 | Count total customers |
| task_2 | Find products with price > 50 |
| task_3 | Calculate revenue from completed orders |
| task_4 | List top 3 customers by order count |
| Variable | Default | Description |
|---|---|---|
| DB_PATH | ecommerce.db | Path to SQLite database |
MIT