Spaces:
Sleeping
Sleeping
root commited on
Commit ·
c2fa0f1
1
Parent(s): bb9eaef
hf issues now fixed
Browse files- Dockerfile +3 -3
- README.md +0 -12
- openenv.yaml +1 -1
- readme.md +0 -71
- server/__pycache__/app.cpython-313.pyc +0 -0
- server/app.py +10 -0
Dockerfile
CHANGED
|
@@ -17,9 +17,9 @@ ENV PYTHONPATH="/app"
|
|
| 17 |
|
| 18 |
# Health check
|
| 19 |
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
| 20 |
-
CMD curl -f http://localhost:
|
| 21 |
|
| 22 |
-
EXPOSE
|
| 23 |
|
| 24 |
# Run server with updated root OOP Path
|
| 25 |
-
CMD ["uvicorn", "server.app:app", "--host", "0.0.0.0", "--port", "
|
|
|
|
| 17 |
|
| 18 |
# Health check
|
| 19 |
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
| 20 |
+
CMD curl -f http://localhost:7860/health || exit 1
|
| 21 |
|
| 22 |
+
EXPOSE 7860
|
| 23 |
|
| 24 |
# Run server with updated root OOP Path
|
| 25 |
+
CMD ["uvicorn", "server.app:app", "--host", "0.0.0.0", "--port", "7860"]
|
README.md
DELETED
|
@@ -1,12 +0,0 @@
|
|
| 1 |
-
---
|
| 2 |
-
title: Sql Agent
|
| 3 |
-
emoji: 😻
|
| 4 |
-
colorFrom: green
|
| 5 |
-
colorTo: yellow
|
| 6 |
-
sdk: docker
|
| 7 |
-
pinned: false
|
| 8 |
-
license: apache-2.0
|
| 9 |
-
short_description: sql-agent
|
| 10 |
-
---
|
| 11 |
-
|
| 12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
openenv.yaml
CHANGED
|
@@ -3,4 +3,4 @@ name: sql-agent-env
|
|
| 3 |
type: space
|
| 4 |
runtime: fastapi
|
| 5 |
app: server.app:app
|
| 6 |
-
port:
|
|
|
|
| 3 |
type: space
|
| 4 |
runtime: fastapi
|
| 5 |
app: server.app:app
|
| 6 |
+
port: 7860
|
readme.md
DELETED
|
@@ -1,71 +0,0 @@
|
|
| 1 |
-
---
|
| 2 |
-
title: SQL AI Data Analyst
|
| 3 |
-
emoji: 📊
|
| 4 |
-
colorFrom: blue
|
| 5 |
-
colorTo: green
|
| 6 |
-
sdk: docker
|
| 7 |
-
app_port: 8000
|
| 8 |
-
tags:
|
| 9 |
-
- openenv
|
| 10 |
-
---
|
| 11 |
-
# OpenEnv SQL Data Analyst
|
| 12 |
-
|
| 13 |
-
## The Goal
|
| 14 |
-
The objective is straightforward: the AI must interpret an internal database schema and translate human business instructions into valid SQL queries natively executed against the pipeline.
|
| 15 |
-
|
| 16 |
-
Tasks increase in difficulty, pushing models to understand complex relationships such as:
|
| 17 |
-
- Simple Table Retrievals (`SELECT`, `WHERE`)
|
| 18 |
-
- Aggregating related tables (`JOIN`, `GROUP BY`)
|
| 19 |
-
- Complex constraint execution bounds (Logic matching)
|
| 20 |
-
|
| 21 |
-
## Fast Execution
|
| 22 |
-
1. **Install:** `pip install -r requirements.txt`
|
| 23 |
-
2. **Setup your preferred engine:**
|
| 24 |
-
```powershell
|
| 25 |
-
$env:GEMINI_API_KEY="your-api-key"
|
| 26 |
-
# Or use OPENAI_API_KEY
|
| 27 |
-
```
|
| 28 |
-
3. **Run the Simulation Base:**
|
| 29 |
-
```powershell
|
| 30 |
-
python inference.py
|
| 31 |
-
```
|
| 32 |
-
|
| 33 |
-
## Architecture Workflow
|
| 34 |
-
|
| 35 |
-
This environment follows strict [OpenEnv Gym interface](https://github.com/meta-pytorch/OpenEnv) standards, utilizing `step()`, `reset()`, and `state()` endpoints wrapped locally or exposed natively via Hugging Face.
|
| 36 |
-
|
| 37 |
-
```mermaid
|
| 38 |
-
flowchart TD
|
| 39 |
-
Start([Episode Start]) --> EnvInit[Environment loads Task 1]
|
| 40 |
-
|
| 41 |
-
EnvInit --> Obs[Generate Observation]
|
| 42 |
-
Obs -.-> |1. Send Schema and Instruction| Agent((LLM Agent))
|
| 43 |
-
|
| 44 |
-
Agent -.-> |2. Predicts SQL Query| Step[Environment step function]
|
| 45 |
-
|
| 46 |
-
Step --> Exec{Execute SQL on SQLite Engine}
|
| 47 |
-
|
| 48 |
-
Exec -->|SQL Syntax Error| Pen[Return Negative Reward]
|
| 49 |
-
Exec -->|Valid SQL| Grader[Evaluate Pandas DataFrame]
|
| 50 |
-
|
| 51 |
-
Grader --> Match{Compare Expected DataFrame}
|
| 52 |
-
Match -->|Perfect Match| Rew1[Reward 1.0 Advance Level]
|
| 53 |
-
Match -->|Unordered Match| RewPartial[Reward 0.8]
|
| 54 |
-
Match -->|Incorrect Data| Rew0[Reward 0.0]
|
| 55 |
-
|
| 56 |
-
Pen --> StateUpdate
|
| 57 |
-
Rew1 --> StateUpdate
|
| 58 |
-
RewPartial --> StateUpdate
|
| 59 |
-
Rew0 --> StateUpdate
|
| 60 |
-
|
| 61 |
-
StateUpdate[Log History and Update Episode state] --> CheckDone{All Tasks Completed Yes or No}
|
| 62 |
-
|
| 63 |
-
CheckDone -->|No| Obs
|
| 64 |
-
CheckDone -->|Yes| Finish([Episode End])
|
| 65 |
-
```
|
| 66 |
-
|
| 67 |
-
## Internal Engine Design
|
| 68 |
-
To read more about exactly how the logic is handled under the hood, access the OOP components inside the root directory:
|
| 69 |
-
- `server/environment.py`: The orchestrator handling the OpenEnv lifecycle.
|
| 70 |
-
- `database/sqlite_manager.py`: Creates ephemeral SQLite sandboxes per session.
|
| 71 |
-
- `core/grader.py`: Evaluates logic correctness independent of string semantics by leveraging Pandas DataFrame alignments.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
server/__pycache__/app.cpython-313.pyc
CHANGED
|
Binary files a/server/__pycache__/app.cpython-313.pyc and b/server/__pycache__/app.cpython-313.pyc differ
|
|
|
server/app.py
CHANGED
|
@@ -4,3 +4,13 @@ from models import SqlAction, SqlObservation
|
|
| 4 |
from server.environment import SqlEnvironment
|
| 5 |
|
| 6 |
app = create_fastapi_app(SqlEnvironment, SqlAction, SqlObservation)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
from server.environment import SqlEnvironment
|
| 5 |
|
| 6 |
app = create_fastapi_app(SqlEnvironment, SqlAction, SqlObservation)
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
@app.get("/")
|
| 10 |
+
def root():
|
| 11 |
+
return {"status": "ok"}
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
@app.get("/health")
|
| 15 |
+
def health():
|
| 16 |
+
return {"status": "healthy"}
|