Spaces:
Runtime error
Runtime error
Mustehson
commited on
Commit
Β·
28623de
1
Parent(s):
9a42f0f
Added empty fig
Browse files- app.py +8 -0
- requirements.txt +1 -0
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import os
|
2 |
import duckdb
|
3 |
import gradio as gr
|
|
|
4 |
from transformers import HfEngine, ReactCodeAgent
|
5 |
from transformers.agents import Tool
|
6 |
|
@@ -65,6 +66,7 @@ def get_visualization(question, tool):
|
|
65 |
|
66 |
return fig
|
67 |
|
|
|
68 |
class SQLExecutorTool(Tool):
|
69 |
name = "sql_engine"
|
70 |
inputs = {
|
@@ -83,15 +85,21 @@ class SQLExecutorTool(Tool):
|
|
83 |
tool = SQLExecutorTool()
|
84 |
|
85 |
def main(table, text_query):
|
|
|
|
|
|
|
|
|
86 |
schema, _ = get_table_schema(table)
|
87 |
tool.description = f"""Allows you to perform SQL queries on the table. Returns a pandas dataframe representation of the result.
|
88 |
The table schema is as follows: \n{schema}"""
|
89 |
|
|
|
90 |
try:
|
91 |
fig = get_visualization(question=text_query, tool=tool)
|
92 |
except Exception as e:
|
93 |
gr.Warning(f"β Unable to generate the visualization. {e}")
|
94 |
|
|
|
95 |
return fig
|
96 |
|
97 |
|
|
|
1 |
import os
|
2 |
import duckdb
|
3 |
import gradio as gr
|
4 |
+
import matplotlib.pyplot as plt
|
5 |
from transformers import HfEngine, ReactCodeAgent
|
6 |
from transformers.agents import Tool
|
7 |
|
|
|
66 |
|
67 |
return fig
|
68 |
|
69 |
+
|
70 |
class SQLExecutorTool(Tool):
|
71 |
name = "sql_engine"
|
72 |
inputs = {
|
|
|
85 |
tool = SQLExecutorTool()
|
86 |
|
87 |
def main(table, text_query):
|
88 |
+
# Empty Fig
|
89 |
+
fig, ax = plt.subplots()
|
90 |
+
ax.set_axis_off()
|
91 |
+
|
92 |
schema, _ = get_table_schema(table)
|
93 |
tool.description = f"""Allows you to perform SQL queries on the table. Returns a pandas dataframe representation of the result.
|
94 |
The table schema is as follows: \n{schema}"""
|
95 |
|
96 |
+
|
97 |
try:
|
98 |
fig = get_visualization(question=text_query, tool=tool)
|
99 |
except Exception as e:
|
100 |
gr.Warning(f"β Unable to generate the visualization. {e}")
|
101 |
|
102 |
+
|
103 |
return fig
|
104 |
|
105 |
|
requirements.txt
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
huggingface_hub
|
2 |
transformers
|
3 |
duckdb
|
|
|
1 |
+
torch
|
2 |
huggingface_hub
|
3 |
transformers
|
4 |
duckdb
|