Spaces:
Running
Running
cleaned duckdbinst template
Browse files- app.py +5 -5
- duckdb-nsql/eval/prompt_formatters.py +12 -14
app.py
CHANGED
@@ -105,11 +105,11 @@ with gr.Blocks(gr.themes.Soft()) as demo:
|
|
105 |
)
|
106 |
|
107 |
# Update format dropdown when template is edited
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
|
114 |
start_btn.click(
|
115 |
fn=gradio_run_evaluation,
|
|
|
105 |
)
|
106 |
|
107 |
# Update format dropdown when template is edited
|
108 |
+
custom_prompt.change(
|
109 |
+
fn=handle_template_edit,
|
110 |
+
inputs=[prompt_format, custom_prompt],
|
111 |
+
outputs=[prompt_format]
|
112 |
+
)
|
113 |
|
114 |
start_btn.click(
|
115 |
fn=gradio_run_evaluation,
|
duckdb-nsql/eval/prompt_formatters.py
CHANGED
@@ -115,8 +115,17 @@ class DuckDBFormatter(RajkumarFormatter):
|
|
115 |
class DuckDBInstFormatter(RajkumarFormatter):
|
116 |
"""DuckDB Inst class."""
|
117 |
|
118 |
-
PROMPT_TEMPLATE = """### Instruction
|
119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
|
121 |
@classmethod
|
122 |
def format_retrieved_context(
|
@@ -135,19 +144,8 @@ class DuckDBInstFormatter(RajkumarFormatter):
|
|
135 |
context_text: str,
|
136 |
) -> str | list[str]:
|
137 |
"""Get prompt format."""
|
138 |
-
input = ""
|
139 |
-
if table_text:
|
140 |
-
input = """Here is the database schema that the SQL query will run on:\n{schema}\n""".format( # noqa: E501
|
141 |
-
schema=table_text
|
142 |
-
)
|
143 |
instruction = cls.PROMPT_TEMPLATE.format(
|
144 |
-
|
145 |
-
has_schema="."
|
146 |
-
if table_text == ""
|
147 |
-
else ", given a duckdb database schema."
|
148 |
-
),
|
149 |
-
context=context_text,
|
150 |
-
input=input,
|
151 |
question=instruction,
|
152 |
)
|
153 |
return instruction
|
|
|
115 |
class DuckDBInstFormatter(RajkumarFormatter):
|
116 |
"""DuckDB Inst class."""
|
117 |
|
118 |
+
PROMPT_TEMPLATE = """### Instruction:
|
119 |
+
Your task is to generate valid duckdb SQL to answer the following question, given a duckdb database schema.
|
120 |
+
|
121 |
+
Here is the database schema that the SQL query will run on:
|
122 |
+
{schema}
|
123 |
+
|
124 |
+
### Question:
|
125 |
+
{question}
|
126 |
+
|
127 |
+
### Response (use duckdb shorthand if possible):
|
128 |
+
"""
|
129 |
|
130 |
@classmethod
|
131 |
def format_retrieved_context(
|
|
|
144 |
context_text: str,
|
145 |
) -> str | list[str]:
|
146 |
"""Get prompt format."""
|
|
|
|
|
|
|
|
|
|
|
147 |
instruction = cls.PROMPT_TEMPLATE.format(
|
148 |
+
schema=table_text,
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
question=instruction,
|
150 |
)
|
151 |
return instruction
|