BrightData commited on
Commit
4a45c21
·
verified ·
1 Parent(s): b3ecc7a

Add Bright Data Dataset Tool

Browse files
Files changed (3) hide show
  1. app.py +1 -17
  2. requirements.txt +1 -1
  3. 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=['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)
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
- {tool_module_name}
 
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
- class_name = self.__class__.__name__
205
- return f"""\
206
  import gradio as gr
207
- from {tool_module_name} import {class_name}
208
 
209
- tool = {class_name}()
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={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
- """
 
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="""