Update to use simple scrape for simples adds

#9
by ibombonato - opened
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -5,6 +5,7 @@ import base64
5
  from io import BytesIO
6
  from PIL import Image
7
  from crewai import Agent, Task, Crew, Process, LLM
 
8
  from dotenv import load_dotenv
9
  from stealth_scrape_tool import StealthScrapeTool
10
  from image_generator_tool import GenerateImageTool
@@ -19,7 +20,7 @@ class SocialMediaCrew:
19
  self.natura_api_token = natura_api_token
20
  self.openai_base_url = openai_base_url
21
  self.openai_model_name = openai_model_name
22
- self.scrape_tool = StealthScrapeTool() #ScrapeWebsiteTool()
23
  self.calculate_discounted_price_tool = CalculateDiscountedPriceTool()
24
  self.calculate_discount_value_tool = CalculateDiscountValueTool()
25
  self.image_generator_tool = GenerateImageTool()
@@ -88,7 +89,7 @@ class SocialMediaCrew:
88
  return merchant, css_selector, short_url
89
 
90
  def _create_analyze_product_task(self, product_url: str, css_selector: str, main_cupom_discount_percentage: float, short_url: str, original_price: float, discounted_price: float) -> Task:
91
- task_description = (f"1. Scrape the content of the URL: {product_url} using the 'scrape_tool' with css_element = '{css_selector}'.\n"
92
  "2. Extract the product name, key characteristics, and any other relevant DISCOUNT available.\n")
93
 
94
  if original_price is not None and original_price > 0 and discounted_price is not None and discounted_price > 0:
@@ -329,4 +330,4 @@ with gr.Blocks() as demo:
329
  base64_debug_output.change(fn=None, inputs=[base64_debug_output], js=js_share_logic)
330
 
331
  if __name__ == "__main__":
332
- demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
 
5
  from io import BytesIO
6
  from PIL import Image
7
  from crewai import Agent, Task, Crew, Process, LLM
8
+ from crewai_tools import ScrapeWebsiteTool
9
  from dotenv import load_dotenv
10
  from stealth_scrape_tool import StealthScrapeTool
11
  from image_generator_tool import GenerateImageTool
 
20
  self.natura_api_token = natura_api_token
21
  self.openai_base_url = openai_base_url
22
  self.openai_model_name = openai_model_name
23
+ self.scrape_tool = ScrapeWebsiteTool()
24
  self.calculate_discounted_price_tool = CalculateDiscountedPriceTool()
25
  self.calculate_discount_value_tool = CalculateDiscountValueTool()
26
  self.image_generator_tool = GenerateImageTool()
 
89
  return merchant, css_selector, short_url
90
 
91
  def _create_analyze_product_task(self, product_url: str, css_selector: str, main_cupom_discount_percentage: float, short_url: str, original_price: float, discounted_price: float) -> Task:
92
+ task_description = (f"1. Scrape the content of the URL: {product_url} using the 'scrape_tool'.\n"
93
  "2. Extract the product name, key characteristics, and any other relevant DISCOUNT available.\n")
94
 
95
  if original_price is not None and original_price > 0 and discounted_price is not None and discounted_price > 0:
 
330
  base64_debug_output.change(fn=None, inputs=[base64_debug_output], js=js_share_logic)
331
 
332
  if __name__ == "__main__":
333
+ demo.launch(server_name="0.0.0.0", server_port=7860)