Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -128,35 +128,20 @@ def ask_agent(question: str) -> str:
|
|
| 128 |
return result_str or "No results."
|
| 129 |
return str(result)
|
| 130 |
except Exception as e:
|
| 131 |
-
return f"
|
| 132 |
|
| 133 |
with gr.Blocks() as demo:
|
| 134 |
-
gr.Markdown("##
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
gr.Markdown(f"- {prompt}")
|
| 146 |
-
|
| 147 |
-
# --- Right column: question & response (larger) ---
|
| 148 |
-
with gr.Column(scale=2):
|
| 149 |
-
gr.Markdown("### Ask questions about students, subjects, marks, and teachers")
|
| 150 |
-
question_input = gr.Textbox(
|
| 151 |
-
label="Your question",
|
| 152 |
-
placeholder="e.g., Which student scored highest in Math?",
|
| 153 |
-
lines=2
|
| 154 |
-
)
|
| 155 |
-
answer_output = gr.Textbox(
|
| 156 |
-
label="Agent response",
|
| 157 |
-
lines=20
|
| 158 |
-
)
|
| 159 |
-
|
| 160 |
question_input.submit(fn=ask_agent, inputs=question_input, outputs=answer_output)
|
| 161 |
|
| 162 |
demo.launch()
|
|
|
|
| 128 |
return result_str or "No results."
|
| 129 |
return str(result)
|
| 130 |
except Exception as e:
|
| 131 |
+
return f" Error: {str(e)}"
|
| 132 |
|
| 133 |
with gr.Blocks() as demo:
|
| 134 |
+
gr.Markdown("## Text to SQL Agent")
|
| 135 |
+
gr.Markdown("### Students Table")
|
| 136 |
+
gr.DataFrame(value=students_df, interactive=False)
|
| 137 |
+
gr.Markdown("### Subjects Table")
|
| 138 |
+
gr.DataFrame(value=subjects_df, interactive=False)
|
| 139 |
+
gr.Markdown("### Ask questions about students, subjects, marks, and teachers")
|
| 140 |
+
question_input = gr.Textbox(label="Your question", placeholder="e.g., Which student scored highest in Math?")
|
| 141 |
+
answer_output = gr.Textbox(label="Agent response")
|
| 142 |
+
gr.Markdown("### Sample Prompts")
|
| 143 |
+
for prompt in sample_prompts:
|
| 144 |
+
gr.Markdown(f"- {prompt}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
question_input.submit(fn=ask_agent, inputs=question_input, outputs=answer_output)
|
| 146 |
|
| 147 |
demo.launch()
|