Add Bright Data Dataset Tool
Browse files- app.py +19 -2
- requirements.txt +1 -3
- tool.py +25 -9
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
| 3 |
|
|
|
|
| 4 |
tool = BrightDataDatasetTool()
|
| 5 |
|
| 6 |
def run(dataset, url, keyword, first_name, last_name, days_limit, num_of_reviews, num_of_comments):
|
|
@@ -17,4 +18,20 @@ 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=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import importlib
|
| 3 |
|
| 4 |
+
BrightDataDatasetTool = importlib.import_module("tool").BrightDataDatasetTool
|
| 5 |
tool = BrightDataDatasetTool()
|
| 6 |
|
| 7 |
def run(dataset, url, keyword, first_name, last_name, days_limit, num_of_reviews, num_of_comments):
|
|
|
|
| 18 |
|
| 19 |
with gr.Blocks() as demo:
|
| 20 |
gr.Markdown("### Bright Data dataset fetch")
|
| 21 |
+
dataset = gr.Dropdown(choices=['amazon_product', 'amazon_product_reviews', 'amazon_product_search', 'apple_app_store', 'bestbuy_products', 'booking_hotel_listings', 'crunchbase_company', 'ebay_product', 'etsy_products', 'facebook_company_reviews', 'facebook_events', 'facebook_marketplace_listings', 'facebook_posts', 'github_repository_file', 'google_maps_reviews', 'google_play_store', 'google_shopping', 'homedepot_products', 'instagram_comments', 'instagram_posts', 'instagram_profiles', 'instagram_reels', 'linkedin_company_profile', 'linkedin_job_listings', 'linkedin_people_search', 'linkedin_person_profile', 'linkedin_posts', 'reddit_posts', 'reuter_news', 'tiktok_comments', 'tiktok_posts', 'tiktok_profiles', 'tiktok_shop', 'walmart_product', 'walmart_seller', 'x_posts', 'yahoo_finance_business', 'youtube_comments', 'youtube_profiles', 'youtube_videos', 'zara_products', 'zillow_properties_listing', 'zoominfo_company_profile'], label="Dataset", multiselect=False)
|
| 22 |
+
url = gr.Textbox(label="URL", placeholder="https://...")
|
| 23 |
+
keyword = gr.Textbox(label="Keyword")
|
| 24 |
+
first_name = gr.Textbox(label="First name")
|
| 25 |
+
last_name = gr.Textbox(label="Last name")
|
| 26 |
+
days_limit = gr.Textbox(label="Days limit (e.g. 3)")
|
| 27 |
+
num_of_reviews = gr.Textbox(label="Number of reviews")
|
| 28 |
+
num_of_comments = gr.Textbox(label="Number of comments")
|
| 29 |
+
run_btn = gr.Button("Run")
|
| 30 |
+
output = gr.Textbox(label="Output", lines=12)
|
| 31 |
+
run_btn.click(
|
| 32 |
+
run,
|
| 33 |
+
inputs=[dataset, url, keyword, first_name, last_name, days_limit, num_of_reviews, num_of_comments],
|
| 34 |
+
outputs=output,
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
demo.launch()
|
requirements.txt
CHANGED
|
@@ -1,4 +1,2 @@
|
|
| 1 |
-
gradio
|
| 2 |
requests
|
| 3 |
-
smolagents
|
| 4 |
-
tool
|
|
|
|
|
|
|
| 1 |
requests
|
| 2 |
+
smolagents
|
|
|
tool.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 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):
|
| 9 |
name = "brightdata_dataset_fetch"
|
|
@@ -200,13 +200,12 @@ class BrightDataDatasetTool(Tool):
|
|
| 200 |
instead of a long text field. Kept minimal: single-select dropdown,
|
| 201 |
rest are simple text boxes.
|
| 202 |
"""
|
| 203 |
-
|
| 204 |
-
#
|
| 205 |
-
|
| 206 |
-
|
| 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):
|
|
@@ -223,4 +222,21 @@ class BrightDataDatasetTool(Tool):
|
|
| 223 |
|
| 224 |
with gr.Blocks() as demo:
|
| 225 |
gr.Markdown("### Bright Data dataset fetch")
|
| 226 |
-
dataset = gr.Dropdown(choices=""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from typing import Any, Optional
|
| 2 |
from smolagents.tools import Tool
|
|
|
|
|
|
|
| 3 |
import requests
|
| 4 |
+
import os
|
| 5 |
import json
|
| 6 |
+
import time
|
| 7 |
|
| 8 |
class BrightDataDatasetTool(Tool):
|
| 9 |
name = "brightdata_dataset_fetch"
|
|
|
|
| 200 |
instead of a long text field. Kept minimal: single-select dropdown,
|
| 201 |
rest are simple text boxes.
|
| 202 |
"""
|
| 203 |
+
choices = repr(sorted(self.datasets.keys()))
|
| 204 |
+
# Avoid `from tool import ...` so requirement scanning doesn't add a fake package.
|
| 205 |
+
return f"""import gradio as gr
|
| 206 |
+
import importlib
|
|
|
|
|
|
|
| 207 |
|
| 208 |
+
BrightDataDatasetTool = importlib.import_module("tool").BrightDataDatasetTool
|
| 209 |
tool = BrightDataDatasetTool()
|
| 210 |
|
| 211 |
def run(dataset, url, keyword, first_name, last_name, days_limit, num_of_reviews, num_of_comments):
|
|
|
|
| 222 |
|
| 223 |
with gr.Blocks() as demo:
|
| 224 |
gr.Markdown("### Bright Data dataset fetch")
|
| 225 |
+
dataset = gr.Dropdown(choices={choices}, label="Dataset", multiselect=False)
|
| 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 |
+
"""
|