Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -91,9 +91,8 @@ class tools:
|
|
91 |
|
92 |
class AgentLoader:
|
93 |
|
94 |
-
|
95 |
-
|
96 |
-
agent = await create_csv_agent(
|
97 |
ChatGoogleGenerativeAI(temperature=0.6, model="gemini-1.5-flash-latest"),
|
98 |
path,
|
99 |
verbose=True,
|
@@ -173,7 +172,7 @@ def getTasks(query, agent, exp):
|
|
173 |
return [task_read, task_write]
|
174 |
|
175 |
# Gradio interface function
|
176 |
-
|
177 |
path = file.name
|
178 |
|
179 |
if path.endswith(".pdf"):
|
@@ -183,7 +182,7 @@ async def process_file(file, query, expected_output):
|
|
183 |
elif path.endswith(".json") or path.endswith(".txt"):
|
184 |
agent = AgentLoader.fileReaderAgent(path)
|
185 |
elif path.endswith(".csv"):
|
186 |
-
agent =
|
187 |
results = agent.run(query)
|
188 |
else:
|
189 |
return 'File NOT supported'
|
@@ -201,7 +200,7 @@ async def process_file(file, query, expected_output):
|
|
201 |
|
202 |
# Create the Gradio interface
|
203 |
interface = gr.Interface(
|
204 |
-
fn=
|
205 |
inputs=[
|
206 |
gr.File(label="Upload File"),
|
207 |
gr.Textbox(label="Query"),
|
@@ -214,3 +213,4 @@ interface = gr.Interface(
|
|
214 |
|
215 |
# Launch the Gradio interface
|
216 |
interface.launch()
|
|
|
|
91 |
|
92 |
class AgentLoader:
|
93 |
|
94 |
+
def csvReaderAgent(path):
|
95 |
+
agent = create_csv_agent(
|
|
|
96 |
ChatGoogleGenerativeAI(temperature=0.6, model="gemini-1.5-flash-latest"),
|
97 |
path,
|
98 |
verbose=True,
|
|
|
172 |
return [task_read, task_write]
|
173 |
|
174 |
# Gradio interface function
|
175 |
+
def process_file(file, query, expected_output):
|
176 |
path = file.name
|
177 |
|
178 |
if path.endswith(".pdf"):
|
|
|
182 |
elif path.endswith(".json") or path.endswith(".txt"):
|
183 |
agent = AgentLoader.fileReaderAgent(path)
|
184 |
elif path.endswith(".csv"):
|
185 |
+
agent = AgentLoader.csvReaderAgent(path)
|
186 |
results = agent.run(query)
|
187 |
else:
|
188 |
return 'File NOT supported'
|
|
|
200 |
|
201 |
# Create the Gradio interface
|
202 |
interface = gr.Interface(
|
203 |
+
fn=process_file,
|
204 |
inputs=[
|
205 |
gr.File(label="Upload File"),
|
206 |
gr.Textbox(label="Query"),
|
|
|
213 |
|
214 |
# Launch the Gradio interface
|
215 |
interface.launch()
|
216 |
+
|