Spaces:
Sleeping
Sleeping
Rafael Poyiadzi Claude Opus 4.6 commited on
Commit ·
dab8980
1
Parent(s): 87e5a25
Add everyrow research app
Browse filesGradio app that lets users upload a CSV, provide a research query,
and runs everyrow's agent_map on every row to produce enriched results.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- README.md +5 -7
- app.py +110 -0
- requirements.txt +1 -0
README.md
CHANGED
|
@@ -1,13 +1,11 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
short_description: everyrow to research and enrich your dataset
|
| 11 |
---
|
| 12 |
-
|
| 13 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: everyrow research
|
| 3 |
+
emoji: 🔍
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: "5.0"
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
short_description: everyrow to research and enrich your dataset
|
| 11 |
---
|
|
|
|
|
|
app.py
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
+
import os
|
| 3 |
+
import tempfile
|
| 4 |
+
|
| 5 |
+
import gradio as gr
|
| 6 |
+
import pandas as pd
|
| 7 |
+
|
| 8 |
+
from everyrow.ops import agent_map
|
| 9 |
+
from everyrow.task import EffortLevel
|
| 10 |
+
|
| 11 |
+
EFFORT_LEVELS = {
|
| 12 |
+
"Low": EffortLevel.LOW,
|
| 13 |
+
"Minimal": EffortLevel.MINIMAL,
|
| 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.")
|
| 28 |
+
if file is None:
|
| 29 |
+
raise gr.Error("Please upload a CSV file.")
|
| 30 |
+
if not query.strip():
|
| 31 |
+
raise gr.Error("Please enter a research query.")
|
| 32 |
+
|
| 33 |
+
os.environ["EVERYROW_API_KEY"] = api_key
|
| 34 |
+
|
| 35 |
+
df = pd.read_csv(file.name)
|
| 36 |
+
if df.empty:
|
| 37 |
+
raise gr.Error("The uploaded CSV is empty.")
|
| 38 |
+
|
| 39 |
+
effort_level = EFFORT_LEVELS[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(
|
| 46 |
+
delete=False, suffix=".csv", prefix="everyrow_results_"
|
| 47 |
+
)
|
| 48 |
+
output_df.to_csv(tmp.name, index=False)
|
| 49 |
+
|
| 50 |
+
return output_df, gr.update(value=tmp.name, visible=True)
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
with gr.Blocks(title="everyrow research") as demo:
|
| 54 |
+
gr.Markdown(
|
| 55 |
+
"""
|
| 56 |
+
# everyrow research
|
| 57 |
+
Upload a CSV, describe what you want to research for each row, and get
|
| 58 |
+
enriched results powered by [everyrow](https://everyrow.com).
|
| 59 |
+
"""
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
api_key = gr.Textbox(
|
| 63 |
+
label="everyrow API key",
|
| 64 |
+
type="password",
|
| 65 |
+
placeholder="sk-cho-...",
|
| 66 |
+
)
|
| 67 |
+
|
| 68 |
+
file = gr.File(label="Upload CSV", file_types=[".csv"])
|
| 69 |
+
|
| 70 |
+
preview_heading = gr.Markdown("### Preview", visible=False)
|
| 71 |
+
preview_table = gr.Dataframe(label="Input preview", visible=False)
|
| 72 |
+
|
| 73 |
+
query = gr.Textbox(
|
| 74 |
+
label="Research query",
|
| 75 |
+
placeholder="e.g. Find this company's latest funding round and amount",
|
| 76 |
+
lines=3,
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
effort = gr.Dropdown(
|
| 80 |
+
choices=list(EFFORT_LEVELS.keys()),
|
| 81 |
+
value="Low",
|
| 82 |
+
label="Effort level",
|
| 83 |
+
)
|
| 84 |
+
|
| 85 |
+
submit_btn = gr.Button("Run", variant="primary")
|
| 86 |
+
|
| 87 |
+
gr.Markdown("### Results")
|
| 88 |
+
output_table = gr.Dataframe(label="Results")
|
| 89 |
+
download_btn = gr.File(label="Download CSV", visible=False)
|
| 90 |
+
|
| 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.name)
|
| 95 |
+
return gr.update(visible=True), gr.update(value=df, visible=True)
|
| 96 |
+
|
| 97 |
+
file.change(
|
| 98 |
+
fn=on_upload,
|
| 99 |
+
inputs=[file],
|
| 100 |
+
outputs=[preview_heading, preview_table],
|
| 101 |
+
)
|
| 102 |
+
|
| 103 |
+
submit_btn.click(
|
| 104 |
+
fn=run_agent_map,
|
| 105 |
+
inputs=[api_key, file, query, effort],
|
| 106 |
+
outputs=[output_table, download_btn],
|
| 107 |
+
)
|
| 108 |
+
|
| 109 |
+
if __name__ == "__main__":
|
| 110 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
everyrow>=0.2.0
|