Add Bright Data Dataset Tool
Browse files- app.py +1 -17
- requirements.txt +1 -1
- tool.py +8 -24
app.py
CHANGED
|
@@ -17,20 +17,4 @@ def run(dataset, url, keyword, first_name, last_name, days_limit, num_of_reviews
|
|
| 17 |
|
| 18 |
with gr.Blocks() as demo:
|
| 19 |
gr.Markdown("### Bright Data dataset fetch")
|
| 20 |
-
dataset = gr.Dropdown(choices=
|
| 21 |
-
url = gr.Textbox(label="URL", placeholder="https://...")
|
| 22 |
-
keyword = gr.Textbox(label="Keyword")
|
| 23 |
-
first_name = gr.Textbox(label="First name")
|
| 24 |
-
last_name = gr.Textbox(label="Last name")
|
| 25 |
-
days_limit = gr.Textbox(label="Days limit (e.g. 3)")
|
| 26 |
-
num_of_reviews = gr.Textbox(label="Number of reviews")
|
| 27 |
-
num_of_comments = gr.Textbox(label="Number of comments")
|
| 28 |
-
run_btn = gr.Button("Run")
|
| 29 |
-
output = gr.Textbox(label="Output", lines=12)
|
| 30 |
-
run_btn.click(
|
| 31 |
-
run,
|
| 32 |
-
inputs=[dataset, url, keyword, first_name, last_name, days_limit, num_of_reviews, num_of_comments],
|
| 33 |
-
outputs=output,
|
| 34 |
-
)
|
| 35 |
-
|
| 36 |
-
demo.launch()
|
|
|
|
| 17 |
|
| 18 |
with gr.Blocks() as demo:
|
| 19 |
gr.Markdown("### Bright Data dataset fetch")
|
| 20 |
+
dataset = gr.Dropdown(choices=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
gradio
|
| 2 |
requests
|
| 3 |
smolagents
|
| 4 |
-
|
|
|
|
| 1 |
gradio
|
| 2 |
requests
|
| 3 |
smolagents
|
| 4 |
+
tool
|
tool.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
from typing import Any, Optional
|
| 2 |
from smolagents.tools import Tool
|
| 3 |
-
import requests
|
| 4 |
-
import time
|
| 5 |
import os
|
|
|
|
|
|
|
| 6 |
import json
|
| 7 |
|
| 8 |
class BrightDataDatasetTool(Tool):
|
|
@@ -200,13 +200,14 @@ class BrightDataDatasetTool(Tool):
|
|
| 200 |
instead of a long text field. Kept minimal: single-select dropdown,
|
| 201 |
rest are simple text boxes.
|
| 202 |
"""
|
|
|
|
|
|
|
| 203 |
choices = sorted(self.datasets.keys())
|
| 204 |
-
|
| 205 |
-
return f"""\
|
| 206 |
import gradio as gr
|
| 207 |
-
from
|
| 208 |
|
| 209 |
-
tool =
|
| 210 |
|
| 211 |
def run(dataset, url, keyword, first_name, last_name, days_limit, num_of_reviews, num_of_comments):
|
| 212 |
return tool(
|
|
@@ -222,21 +223,4 @@ class BrightDataDatasetTool(Tool):
|
|
| 222 |
|
| 223 |
with gr.Blocks() as demo:
|
| 224 |
gr.Markdown("### Bright Data dataset fetch")
|
| 225 |
-
dataset = gr.Dropdown(choices=
|
| 226 |
-
url = gr.Textbox(label="URL", placeholder="https://...")
|
| 227 |
-
keyword = gr.Textbox(label="Keyword")
|
| 228 |
-
first_name = gr.Textbox(label="First name")
|
| 229 |
-
last_name = gr.Textbox(label="Last name")
|
| 230 |
-
days_limit = gr.Textbox(label="Days limit (e.g. 3)")
|
| 231 |
-
num_of_reviews = gr.Textbox(label="Number of reviews")
|
| 232 |
-
num_of_comments = gr.Textbox(label="Number of comments")
|
| 233 |
-
run_btn = gr.Button("Run")
|
| 234 |
-
output = gr.Textbox(label="Output", lines=12)
|
| 235 |
-
run_btn.click(
|
| 236 |
-
run,
|
| 237 |
-
inputs=[dataset, url, keyword, first_name, last_name, days_limit, num_of_reviews, num_of_comments],
|
| 238 |
-
outputs=output,
|
| 239 |
-
)
|
| 240 |
-
|
| 241 |
-
demo.launch()
|
| 242 |
-
"""
|
|
|
|
| 1 |
from typing import Any, Optional
|
| 2 |
from smolagents.tools import Tool
|
|
|
|
|
|
|
| 3 |
import os
|
| 4 |
+
import time
|
| 5 |
+
import requests
|
| 6 |
import json
|
| 7 |
|
| 8 |
class BrightDataDatasetTool(Tool):
|
|
|
|
| 200 |
instead of a long text field. Kept minimal: single-select dropdown,
|
| 201 |
rest are simple text boxes.
|
| 202 |
"""
|
| 203 |
+
# NOTE: Keep the import literal (no f-strings) so the requirements scanner
|
| 204 |
+
# in smolagents doesn't accidentally treat {tool_module_name} as a package.
|
| 205 |
choices = sorted(self.datasets.keys())
|
| 206 |
+
return """\
|
|
|
|
| 207 |
import gradio as gr
|
| 208 |
+
from tool import BrightDataDatasetTool
|
| 209 |
|
| 210 |
+
tool = BrightDataDatasetTool()
|
| 211 |
|
| 212 |
def run(dataset, url, keyword, first_name, last_name, days_limit, num_of_reviews, num_of_comments):
|
| 213 |
return tool(
|
|
|
|
| 223 |
|
| 224 |
with gr.Blocks() as demo:
|
| 225 |
gr.Markdown("### Bright Data dataset fetch")
|
| 226 |
+
dataset = gr.Dropdown(choices="""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|