Spaces:
Sleeping
Sleeping
Upload environment.py
Browse files- server/environment.py +5 -5
server/environment.py
CHANGED
|
@@ -223,13 +223,13 @@ class SQLQualityEnvironment:
|
|
| 223 |
sql_stripped = re.sub(r"/\*.*?\*/", "", sql_stripped, flags=re.DOTALL) # block comments
|
| 224 |
first_keyword = sql_stripped.strip().split()[0].upper() if sql_stripped.strip() else ""
|
| 225 |
|
| 226 |
-
|
|
|
|
|
|
|
| 227 |
if first_keyword not in ALLOWED_READ_KEYWORDS:
|
| 228 |
rejection_feedback = (
|
| 229 |
-
f"
|
| 230 |
-
f"
|
| 231 |
-
f"To modify data, use the FIX action (action_type: 'fix'). "
|
| 232 |
-
f"To find the answer, use action_type: 'submit'."
|
| 233 |
)
|
| 234 |
# Add to trajectory as a step but with zero reward and clear feedback
|
| 235 |
self._trajectory.append(
|
|
|
|
| 223 |
sql_stripped = re.sub(r"/\*.*?\*/", "", sql_stripped, flags=re.DOTALL) # block comments
|
| 224 |
first_keyword = sql_stripped.strip().split()[0].upper() if sql_stripped.strip() else ""
|
| 225 |
|
| 226 |
+
# Allow all SQL types in query box for testing
|
| 227 |
+
# Only FIX action should be restricted
|
| 228 |
+
ALLOWED_READ_KEYWORDS = {"SELECT", "WITH", "EXPLAIN", "PRAGMA", "UPDATE", "INSERT", "DELETE", "CREATE", "DROP", "ALTER"}
|
| 229 |
if first_keyword not in ALLOWED_READ_KEYWORDS:
|
| 230 |
rejection_feedback = (
|
| 231 |
+
f"Invalid SQL keyword: '{first_keyword}'. "
|
| 232 |
+
f"Allowed keywords: {', '.join(sorted(ALLOWED_READ_KEYWORDS))}"
|
|
|
|
|
|
|
| 233 |
)
|
| 234 |
# Add to trajectory as a step but with zero reward and clear feedback
|
| 235 |
self._trajectory.append(
|