Spaces:
Sleeping
Sleeping
Rafael Poyiadzi Claude Opus 4.6 commited on
Commit ·
9d22e7e
1
Parent(s): dab8980
Fix EffortLevel enum, Gradio 5 file handling, and add error checking
Browse files- Replace non-existent EffortLevel.MINIMAL with EffortLevel.MEDIUM
- Use file path string directly instead of file.name (Gradio 5 compat)
- Check result.error before displaying output
- Remove unused preview_csv function and asyncio import
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
import asyncio
|
| 2 |
import os
|
| 3 |
import tempfile
|
| 4 |
|
|
@@ -10,18 +9,11 @@ from everyrow.task import EffortLevel
|
|
| 10 |
|
| 11 |
EFFORT_LEVELS = {
|
| 12 |
"Low": EffortLevel.LOW,
|
| 13 |
-
"
|
| 14 |
"High": EffortLevel.HIGH,
|
| 15 |
}
|
| 16 |
|
| 17 |
|
| 18 |
-
def preview_csv(file):
|
| 19 |
-
if file is None:
|
| 20 |
-
return gr.update(visible=False), None
|
| 21 |
-
df = pd.read_csv(file.name)
|
| 22 |
-
return gr.update(visible=True), df
|
| 23 |
-
|
| 24 |
-
|
| 25 |
async def run_agent_map(api_key, file, query, effort_label):
|
| 26 |
if not api_key:
|
| 27 |
raise gr.Error("Please enter your everyrow API key.")
|
|
@@ -32,7 +24,7 @@ async def run_agent_map(api_key, file, query, effort_label):
|
|
| 32 |
|
| 33 |
os.environ["EVERYROW_API_KEY"] = api_key
|
| 34 |
|
| 35 |
-
df = pd.read_csv(file
|
| 36 |
if df.empty:
|
| 37 |
raise gr.Error("The uploaded CSV is empty.")
|
| 38 |
|
|
@@ -40,6 +32,9 @@ async def run_agent_map(api_key, file, query, effort_label):
|
|
| 40 |
|
| 41 |
result = await agent_map(task=query, input=df, effort_level=effort_level)
|
| 42 |
|
|
|
|
|
|
|
|
|
|
| 43 |
output_df = result.data
|
| 44 |
|
| 45 |
tmp = tempfile.NamedTemporaryFile(
|
|
@@ -91,7 +86,7 @@ with gr.Blocks(title="everyrow research") as demo:
|
|
| 91 |
def on_upload(file):
|
| 92 |
if file is None:
|
| 93 |
return gr.update(visible=False), gr.update(visible=False)
|
| 94 |
-
df = pd.read_csv(file
|
| 95 |
return gr.update(visible=True), gr.update(value=df, visible=True)
|
| 96 |
|
| 97 |
file.change(
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
import tempfile
|
| 3 |
|
|
|
|
| 9 |
|
| 10 |
EFFORT_LEVELS = {
|
| 11 |
"Low": EffortLevel.LOW,
|
| 12 |
+
"Medium": EffortLevel.MEDIUM,
|
| 13 |
"High": EffortLevel.HIGH,
|
| 14 |
}
|
| 15 |
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
async def run_agent_map(api_key, file, query, effort_label):
|
| 18 |
if not api_key:
|
| 19 |
raise gr.Error("Please enter your everyrow API key.")
|
|
|
|
| 24 |
|
| 25 |
os.environ["EVERYROW_API_KEY"] = api_key
|
| 26 |
|
| 27 |
+
df = pd.read_csv(file)
|
| 28 |
if df.empty:
|
| 29 |
raise gr.Error("The uploaded CSV is empty.")
|
| 30 |
|
|
|
|
| 32 |
|
| 33 |
result = await agent_map(task=query, input=df, effort_level=effort_level)
|
| 34 |
|
| 35 |
+
if result.error:
|
| 36 |
+
raise gr.Error(f"agent_map failed: {result.error}")
|
| 37 |
+
|
| 38 |
output_df = result.data
|
| 39 |
|
| 40 |
tmp = tempfile.NamedTemporaryFile(
|
|
|
|
| 86 |
def on_upload(file):
|
| 87 |
if file is None:
|
| 88 |
return gr.update(visible=False), gr.update(visible=False)
|
| 89 |
+
df = pd.read_csv(file)
|
| 90 |
return gr.update(visible=True), gr.update(value=df, visible=True)
|
| 91 |
|
| 92 |
file.change(
|