Update app.py
Browse files
app.py
CHANGED
|
@@ -55,29 +55,26 @@ def run_sql(sql_text: str):
|
|
| 55 |
cf, gap = pd.DataFrame(), pd.DataFrame()
|
| 56 |
return df, "OK", cf, gap
|
| 57 |
|
| 58 |
-
with gr.
|
| 59 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
-
|
| 62 |
-
nl = gr.Textbox(label="Ask a question", placeholder="e.g., show me the top 10 fds by portfolio value")
|
| 63 |
-
btn = gr.Button("Run")
|
| 64 |
-
sql_out = gr.Textbox(label="Generated SQL", interactive=False)
|
| 65 |
-
why_out = gr.Textbox(label="Reasoning", interactive=False)
|
| 66 |
-
df_out = gr.Dataframe(label="Query Result", wrap=True)
|
| 67 |
-
cf_out = gr.Dataframe(label="Projected Cash-Flows (if applicable)", wrap=True, height=250)
|
| 68 |
-
gap_out = gr.Dataframe(label="Liquidity Gap (monthly)", wrap=True, height=200)
|
| 69 |
-
|
| 70 |
-
btn.click(fn=run_nl, inputs=[nl], outputs=[df_out, sql_out, why_out, cf_out, gap_out])
|
| 71 |
|
| 72 |
with gr.Tab("Run Raw SQL"):
|
| 73 |
sql_in = gr.Code(label="SQL", language="sql", value=f"SELECT * FROM {DEFAULT_SCHEMA}.{DEFAULT_TABLE} LIMIT 20;")
|
| 74 |
btn2 = gr.Button("Execute")
|
| 75 |
-
df2 = gr.Dataframe(label="Result",
|
| 76 |
status = gr.Textbox(label="Status", interactive=False)
|
| 77 |
-
cf2 = gr.Dataframe(label="Projected Cash-Flows (if applicable)",
|
| 78 |
-
gap2 = gr.Dataframe(label="Liquidity Gap (monthly)",
|
| 79 |
|
| 80 |
-
|
| 81 |
|
| 82 |
if __name__ == "__main__":
|
| 83 |
# Spaces set PORT automatically; otherwise, Gradio defaults are fine.
|
|
|
|
| 55 |
cf, gap = pd.DataFrame(), pd.DataFrame()
|
| 56 |
return df, "OK", cf, gap
|
| 57 |
|
| 58 |
+
with gr.Tab("Ask in Natural Language"):
|
| 59 |
+
nl = gr.Textbox(label="Ask a question", placeholder="e.g., show me the top 10 fds by portfolio value")
|
| 60 |
+
btn = gr.Button("Run")
|
| 61 |
+
sql_out = gr.Textbox(label="Generated SQL", interactive=False)
|
| 62 |
+
why_out = gr.Textbox(label="Reasoning", interactive=False)
|
| 63 |
+
df_out = gr.Dataframe(label="Query Result", interactive=True)
|
| 64 |
+
cf_out = gr.Dataframe(label="Projected Cash-Flows (if applicable)", interactive=True)
|
| 65 |
+
gap_out = gr.Dataframe(label="Liquidity Gap (monthly)", interactive=True)
|
| 66 |
|
| 67 |
+
btn.click(fn=run_nl, inputs=[nl], outputs=[df_out, sql_out, why_out, cf_out, gap_out])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
with gr.Tab("Run Raw SQL"):
|
| 70 |
sql_in = gr.Code(label="SQL", language="sql", value=f"SELECT * FROM {DEFAULT_SCHEMA}.{DEFAULT_TABLE} LIMIT 20;")
|
| 71 |
btn2 = gr.Button("Execute")
|
| 72 |
+
df2 = gr.Dataframe(label="Result", interactive=True)
|
| 73 |
status = gr.Textbox(label="Status", interactive=False)
|
| 74 |
+
cf2 = gr.Dataframe(label="Projected Cash-Flows (if applicable)", interactive=True)
|
| 75 |
+
gap2 = gr.Dataframe(label="Liquidity Gap (monthly)", interactive=True)
|
| 76 |
|
| 77 |
+
btn2.click(fn=run_sql, inputs=[sql_in], outputs=[df2, status, cf2, gap2])
|
| 78 |
|
| 79 |
if __name__ == "__main__":
|
| 80 |
# Spaces set PORT automatically; otherwise, Gradio defaults are fine.
|