File size: 5,155 Bytes
a97839e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6025d0d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: sql-analyst-env
version: "1.0.0"
description: >
  A real-world SQL data analyst environment where an AI agent must write
  correct SQL queries against an e-commerce database to answer business questions.
  Tasks range from simple aggregations (Easy) to window functions and CTEs (Hard).

author: "Hackathon Submission"
license: MIT

environment:
  type: http
  base_url: "http://0.0.0.0:7860"

endpoints:
  reset:
    method: POST
    path: /reset
    description: Load a task. Returns task description and database schema.
    request_body:
      task_id:
        type: integer
        description: "1 = Easy, 2 = Medium, 3 = Hard"
        required: true
    response:
      observation:
        type: object
        properties:
          task_id:          { type: integer }
          difficulty:       { type: string }
          task_description: { type: string }
          schema:           { type: string }
          hint:             { type: string }
      info:
        type: object

  step:
    method: POST
    path: /step
    description: Submit a SQL query. Returns reward 0.0-1.0 and result preview.
    request_body:
      action:
        type: string
        description: A valid SQLite SELECT or WITH (CTE) statement.
        required: true
    response:
      observation:
        type: object
        properties:
          task_id:          { type: integer }
          task_description: { type: string }
          sql_submitted:    { type: string }
          result_preview:   { type: array }
          result_row_count: { type: integer }
          reward_breakdown:
            type: object
            properties:
              column_score:       { type: number }
              row_score:          { type: number }
              value_score:        { type: number }
              total_reward:       { type: number }
              expected_columns:   { type: array }
              agent_columns:      { type: array }
              expected_row_count: { type: integer }
              agent_row_count:    { type: integer }
      reward:
        type: number
        minimum: 0.0
        maximum: 1.0
        description: Partial score. 1.0 = perfect answer.
      done:
        type: boolean
        description: True when reward reaches 1.0
      info:
        type: object

  state:
    method: GET
    path: /state
    description: Get current task, attempt count, best reward, and full history.
    response:
      task_id:          { type: integer }
      task_description: { type: string }
      schema_info:      { type: string }
      attempts:         { type: integer }
      best_reward:      { type: number }
      history:          { type: array }

observation_space:
  description: >
    On reset: task description, database schema (3 tables), difficulty, hint.
    On step: submitted SQL, result preview (first 5 rows), row count,
    reward breakdown (column / row / value sub-scores).

action_space:
  type: string
  description: >
    A single SQLite-compatible SELECT or WITH statement.
    Only read operations are permitted. INSERT/UPDATE/DELETE are rejected.
  examples:
    - "SELECT COUNT(*) AS total_orders FROM orders WHERE status = 'completed'"
    - "SELECT c.first_name, SUM(o.total_amount) AS revenue FROM orders o JOIN customers c ON o.customer_id = c.customer_id GROUP BY o.customer_id ORDER BY revenue DESC LIMIT 5"
    - "WITH rev AS (SELECT p.category, SUM(o.total_amount) AS total FROM orders o JOIN products p ON o.product_id = p.product_id GROUP BY p.category) SELECT *, RANK() OVER (ORDER BY total DESC) AS rnk FROM rev"

reward:
  type: float
  range: [0.0, 1.0]
  description: >
    Partial credit reward with three components:
      - Column names correct : 0.30
      - Row count correct    : 0.30
      - Cell values correct  : 0.40
  partial_credit: true

tasks:
  - id: 1
    name: "Count completed orders"
    difficulty: easy
    description: >
      Find the total number of completed orders placed in 2024.
      Return a single number with column name: total_orders.

  - id: 2
    name: "Top 5 customers by revenue"
    difficulty: medium
    description: >
      Find the top 5 customers by total revenue from completed orders.
      Return: first_name, last_name, total_revenue. Order by revenue DESC.

  - id: 3
    name: "Category revenue ranking"
    difficulty: hard
    description: >
      For each product category, calculate total revenue and rank using
      a window function. Return: category, total_revenue, revenue_rank.
      Order by revenue_rank ASC.

database:
  engine: SQLite
  path: data/ecommerce.db
  tables:
    customers:
      rows: 100
      columns: [customer_id, first_name, last_name, email, city, signup_date]
    products:
      rows: 30
      columns: [product_id, product_name, category, price, stock]
    orders:
      rows: 600
      columns: [order_id, customer_id, product_id, quantity, total_amount, order_date, status]

hardware:
  min_cpu: 1
  min_ram_gb: 1
  notes: "Runs on 2 vCPU / 8GB RAM. No GPU required."

inference:
  script: inference.py
  max_runtime_minutes: 20
  llm_env_vars:
    - API_BASE_URL
    - MODEL_NAME
    - HF_TOKEN