Fix AI SQL query generation
This commit is contained in:
@@ -78,8 +78,8 @@ def _generate_sql_from_natural_language(natural_query):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# Get and format schema
|
# Get and format schema
|
||||||
schema_info = _get_schema_info()
|
schema_info = db.schema.get_schema_info()
|
||||||
schema_string = _generate_create_script(schema_info)
|
schema_string = db.schema.generate_create_script(schema_info)
|
||||||
|
|
||||||
prompt = f"""Given the following database schema:
|
prompt = f"""Given the following database schema:
|
||||||
```sql
|
```sql
|
||||||
|
|||||||
@@ -32,8 +32,8 @@
|
|||||||
class="flex-grow p-2 border border-gray-300 rounded-l-md shadow-sm focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent"
|
class="flex-grow p-2 border border-gray-300 rounded-l-md shadow-sm focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent"
|
||||||
placeholder="e.g., 'Show me the number of workouts per person'">
|
placeholder="e.g., 'Show me the number of workouts per person'">
|
||||||
<button type="button" hx-post="{{ url_for('sql_explorer.generate_sql') }}"
|
<button type="button" hx-post="{{ url_for('sql_explorer.generate_sql') }}"
|
||||||
hx-include="[name='natural_query']" hx-target="#query" hx-swap="innerHTML"
|
hx-include="[name='natural_query']" hx-indicator="#sql-spinner" hx-swap="none"
|
||||||
hx-indicator="#sql-spinner"
|
_="on htmx:afterRequest set #query.value to detail.xhr.responseText then send input to #query"
|
||||||
class="bg-purple-600 text-white p-2.5 rounded-r-md hover:bg-purple-700 focus:outline-none focus:ring-2 focus:ring-purple-500 focus:ring-opacity-50 inline-flex items-center">
|
class="bg-purple-600 text-white p-2.5 rounded-r-md hover:bg-purple-700 focus:outline-none focus:ring-2 focus:ring-purple-500 focus:ring-opacity-50 inline-flex items-center">
|
||||||
Generate SQL
|
Generate SQL
|
||||||
<span id="sql-spinner" class="htmx-indicator ml-2">
|
<span id="sql-spinner" class="htmx-indicator ml-2">
|
||||||
|
|||||||
Reference in New Issue
Block a user