root commited on
Commit
9d28948
·
1 Parent(s): c2fa0f1

good to go

Browse files
Files changed (1) hide show
  1. README.md +72 -0
README.md ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: SQL AI Data Analyst
3
+ emoji: 📊
4
+ colorFrom: blue
5
+ colorTo: green
6
+ sdk: docker
7
+ app_port: 7860
8
+ pinned: false
9
+ tags:
10
+ - openenv
11
+ ---
12
+ # OpenEnv SQL Data Analyst
13
+
14
+ ## The Goal
15
+ 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.
16
+
17
+ Tasks increase in difficulty, pushing models to understand complex relationships such as:
18
+ - Simple Table Retrievals (`SELECT`, `WHERE`)
19
+ - Aggregating related tables (`JOIN`, `GROUP BY`)
20
+ - Complex constraint execution bounds (Logic matching)
21
+
22
+ ## Fast Execution
23
+ 1. **Install:** `pip install -r requirements.txt`
24
+ 2. **Setup your preferred engine:**
25
+ ```powershell
26
+ $env:GEMINI_API_KEY="your-api-key"
27
+ # Or use OPENAI_API_KEY
28
+ ```
29
+ 3. **Run the Simulation Base:**
30
+ ```powershell
31
+ python inference.py
32
+ ```
33
+
34
+ ## Architecture Workflow
35
+
36
+ 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.
37
+
38
+ ```mermaid
39
+ flowchart TD
40
+ Start([Episode Start]) --> EnvInit[Environment loads Task 1]
41
+
42
+ EnvInit --> Obs[Generate Observation]
43
+ Obs -.-> |1. Send Schema and Instruction| Agent((LLM Agent))
44
+
45
+ Agent -.-> |2. Predicts SQL Query| Step[Environment step function]
46
+
47
+ Step --> Exec{Execute SQL on SQLite Engine}
48
+
49
+ Exec -->|SQL Syntax Error| Pen[Return Negative Reward]
50
+ Exec -->|Valid SQL| Grader[Evaluate Pandas DataFrame]
51
+
52
+ Grader --> Match{Compare Expected DataFrame}
53
+ Match -->|Perfect Match| Rew1[Reward 1.0 Advance Level]
54
+ Match -->|Unordered Match| RewPartial[Reward 0.8]
55
+ Match -->|Incorrect Data| Rew0[Reward 0.0]
56
+
57
+ Pen --> StateUpdate
58
+ Rew1 --> StateUpdate
59
+ RewPartial --> StateUpdate
60
+ Rew0 --> StateUpdate
61
+
62
+ StateUpdate[Log History and Update Episode state] --> CheckDone{All Tasks Completed Yes or No}
63
+
64
+ CheckDone -->|No| Obs
65
+ CheckDone -->|Yes| Finish([Episode End])
66
+ ```
67
+
68
+ ## Internal Engine Design
69
+ To read more about exactly how the logic is handled under the hood, access the OOP components inside the root directory:
70
+ - `server/environment.py`: The orchestrator handling the OpenEnv lifecycle.
71
+ - `database/sqlite_manager.py`: Creates ephemeral SQLite sandboxes per session.
72
+ - `core/grader.py`: Evaluates logic correctness independent of string semantics by leveraging Pandas DataFrame alignments.