Fixing-2
Browse files
app.py
CHANGED
|
@@ -97,7 +97,7 @@ def generate_sql(question, table_headers):
|
|
| 97 |
print(error_msg)
|
| 98 |
return error_msg
|
| 99 |
|
| 100 |
-
def batch_generate_sql(questions_text, table_headers
|
| 101 |
"""Generate SQL for multiple questions."""
|
| 102 |
print(f"batch_generate_sql called with: {questions_text}, {table_headers}")
|
| 103 |
|
|
@@ -120,7 +120,7 @@ def batch_generate_sql(questions_text, table_headers, progress=gr.Progress()):
|
|
| 120 |
successful_count = 0
|
| 121 |
|
| 122 |
for i, question in enumerate(questions):
|
| 123 |
-
|
| 124 |
|
| 125 |
try:
|
| 126 |
start_time = time.time()
|
|
@@ -180,7 +180,7 @@ Check the console/logs above for detailed initialization information.
|
|
| 180 |
|
| 181 |
# Create Gradio interface
|
| 182 |
with gr.Blocks(title="Text-to-SQL RAG with CodeLlama", theme=gr.themes.Soft()) as demo:
|
| 183 |
-
gr.Markdown("#
|
| 184 |
gr.Markdown("Generate SQL queries from natural language using **RAG (Retrieval-Augmented Generation)** and **CodeLlama** models.")
|
| 185 |
gr.Markdown("**Features:** RAG-enhanced generation, CodeLlama integration, Vector-based retrieval, Advanced prompt engineering")
|
| 186 |
|
|
@@ -228,29 +228,25 @@ with gr.Blocks(title="Text-to-SQL RAG with CodeLlama", theme=gr.themes.Soft()) a
|
|
| 228 |
|
| 229 |
with gr.Tab("System Health"):
|
| 230 |
with gr.Row():
|
| 231 |
-
health_btn = gr.Button("Check System Health", variant="secondary", size="lg")
|
| 232 |
health_output = gr.Markdown(label="Health Status")
|
| 233 |
|
| 234 |
-
# Event handlers -
|
| 235 |
generate_btn.click(
|
| 236 |
-
|
| 237 |
inputs=[question_input, table_headers_input],
|
| 238 |
-
outputs=output
|
| 239 |
-
api_name="generate_sql"
|
| 240 |
)
|
| 241 |
|
| 242 |
batch_btn.click(
|
| 243 |
-
|
| 244 |
inputs=[batch_questions, batch_headers],
|
| 245 |
-
outputs=batch_output
|
| 246 |
-
api_name="batch_generate_sql"
|
| 247 |
)
|
| 248 |
|
| 249 |
health_btn.click(
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
outputs=health_output,
|
| 253 |
-
api_name="check_health"
|
| 254 |
)
|
| 255 |
|
| 256 |
gr.Markdown("---")
|
|
@@ -270,7 +266,7 @@ with gr.Blocks(title="Text-to-SQL RAG with CodeLlama", theme=gr.themes.Soft()) a
|
|
| 270 |
- **Frontend**: Gradio interface
|
| 271 |
- **Hosting**: Hugging Face Spaces
|
| 272 |
|
| 273 |
-
## Performance
|
| 274 |
|
| 275 |
- **Model**: CodeLlama-7B-Python-GGUF
|
| 276 |
- **Response Time**: < 5 seconds
|
|
|
|
| 97 |
print(error_msg)
|
| 98 |
return error_msg
|
| 99 |
|
| 100 |
+
def batch_generate_sql(questions_text, table_headers):
|
| 101 |
"""Generate SQL for multiple questions."""
|
| 102 |
print(f"batch_generate_sql called with: {questions_text}, {table_headers}")
|
| 103 |
|
|
|
|
| 120 |
successful_count = 0
|
| 121 |
|
| 122 |
for i, question in enumerate(questions):
|
| 123 |
+
print(f"Processing query {i+1}/{total_questions}: {question}")
|
| 124 |
|
| 125 |
try:
|
| 126 |
start_time = time.time()
|
|
|
|
| 180 |
|
| 181 |
# Create Gradio interface
|
| 182 |
with gr.Blocks(title="Text-to-SQL RAG with CodeLlama", theme=gr.themes.Soft()) as demo:
|
| 183 |
+
gr.Markdown("#Text-to-SQL RAG with CodeLlama")
|
| 184 |
gr.Markdown("Generate SQL queries from natural language using **RAG (Retrieval-Augmented Generation)** and **CodeLlama** models.")
|
| 185 |
gr.Markdown("**Features:** RAG-enhanced generation, CodeLlama integration, Vector-based retrieval, Advanced prompt engineering")
|
| 186 |
|
|
|
|
| 228 |
|
| 229 |
with gr.Tab("System Health"):
|
| 230 |
with gr.Row():
|
| 231 |
+
health_btn = gr.Button("🔍 Check System Health", variant="secondary", size="lg")
|
| 232 |
health_output = gr.Markdown(label="Health Status")
|
| 233 |
|
| 234 |
+
# Event handlers - Simple and working
|
| 235 |
generate_btn.click(
|
| 236 |
+
generate_sql,
|
| 237 |
inputs=[question_input, table_headers_input],
|
| 238 |
+
outputs=output
|
|
|
|
| 239 |
)
|
| 240 |
|
| 241 |
batch_btn.click(
|
| 242 |
+
batch_generate_sql,
|
| 243 |
inputs=[batch_questions, batch_headers],
|
| 244 |
+
outputs=batch_output
|
|
|
|
| 245 |
)
|
| 246 |
|
| 247 |
health_btn.click(
|
| 248 |
+
check_system_health,
|
| 249 |
+
outputs=health_output
|
|
|
|
|
|
|
| 250 |
)
|
| 251 |
|
| 252 |
gr.Markdown("---")
|
|
|
|
| 266 |
- **Frontend**: Gradio interface
|
| 267 |
- **Hosting**: Hugging Face Spaces
|
| 268 |
|
| 269 |
+
## 📊 Performance
|
| 270 |
|
| 271 |
- **Model**: CodeLlama-7B-Python-GGUF
|
| 272 |
- **Response Time**: < 5 seconds
|