feat: update message template

#11
Files changed (4) hide show
  1. .gitignore +2 -1
  2. app.py +2 -2
  3. merchs/merch.py +9 -11
  4. utils_tools.py +2 -2
.gitignore CHANGED
@@ -4,4 +4,5 @@ __pycache__/
4
  .venv/
5
  .vscode/
6
  data/
7
- local/
 
 
4
  .venv/
5
  .vscode/
6
  data/
7
+ local/
8
+ .gradio/
app.py CHANGED
@@ -113,9 +113,9 @@ class SocialMediaCrew:
113
  def _create_post_task(self, analyze_product_task: Task, merchant, main_cupom: str, cupom_1: str, store_name: str) -> Task:
114
  template = merchant.get_template(main_cupom, cupom_1, store=store_name)
115
  return Task(
116
- description=(f"Based on the product analysis, create a CONCISE and DIRECT social media post in Portuguese, suitable for a WhatsApp group. \n If the input you receive is 'INVALID_URL' or 'MISSING_PRODUCT_INFO', you MUST stop and output only that same message.\n The post should strictly follow this template:\n {template}\n\nEnsure a URL is always present in the output. Include a clear call to action and a MAXIMUM of 2 relevant emojis. DO NOT include hashtags. Keep it short and impactful and does not forget to include the backticks around the last paragraph.\n\n If the input you receive is 'INVALID_URL', you MUST stop and output only 'INVALID_URL'."),
117
  agent=self.social_media_copywriter,
118
- expected_output="A short, direct, and impactful social media post in Portuguese for WhatsApp, strictly following the provided template, including the FINAL PRICE, any DISCOUNT, the SHORT SHAREABLE URL, a call to action, and up to 2 emojis, one in the Title and another in the Description. No hashtags should be present. A URL must always be present in the final output, OR the message 'INVALID_URL' or 'MISSING_PRODUCT_INFO' if the page was not found or product info is missing.",
119
  context=[analyze_product_task]
120
  )
121
 
 
113
  def _create_post_task(self, analyze_product_task: Task, merchant, main_cupom: str, cupom_1: str, store_name: str) -> Task:
114
  template = merchant.get_template(main_cupom, cupom_1, store=store_name)
115
  return Task(
116
+ description=(f"Based on the product analysis, create a CONCISE and DIRECT social media post in Portuguese, using Brazilian currency format, add one space after R$, like R$ 99,99, suitable for a WhatsApp group. \n If the input you receive is 'INVALID_URL' or 'MISSING_PRODUCT_INFO', you MUST stop and output only that same message.\n The post should strictly follow this template:\n {template}\n\n. Do not add backticks to response. Ensure a URL is always present in the output. Include a clear and short call to action and a MAXIMUM of 1 relevant emoji. DO NOT include hashtags. Keep it short and impactful and does not forget to include the backticks around the last paragraph.\n\n If the input you receive is 'INVALID_URL', you MUST stop and output only 'INVALID_URL'."),
117
  agent=self.social_media_copywriter,
118
+ expected_output="A short, direct, and impactful social media post in Portuguese for WhatsApp, strictly following the provided template, dont include triple backticks, including the FINAL PRICE, any DISCOUNT with no decimal cases, the SHORT SHAREABLE URL, a call to action, and up to 1 emoji, In the Title or in the Description. Description should be one sentence only. Description should stay before the title, as the template. No hashtags should be present. A URL must always be present in the final output, OR the message 'INVALID_URL' or 'MISSING_PRODUCT_INFO' if the page was not found or product info is missing.",
119
  context=[analyze_product_task]
120
  )
121
 
merchs/merch.py CHANGED
@@ -25,14 +25,14 @@ class NaturaMerchant(Merchant):
25
  def get_template(self, main_cupom, cupom_1, store = None) -> str:
26
  return f"""
27
  ###Template:
28
- {{Title}}
29
-
30
- {{Description}}
31
-
32
  Preço original: ~{{ORIGINAL PRICE}}~
33
  *HOJE: {{CUPOM DISCOUNTED PRICE}} — {{TOTAL DISCOUNT PERCENTAGE}}% OFF*
34
 
35
- 🎟️ CUPOM: {main_cupom} {'ou ' + cupom_1 if cupom_1 else ''}
36
  🛒 Compre aqui: {{short_url}}
37
 
38
  ⚠️ Faça login com o mesmo email e senha que já usa para comprar na Natura!
@@ -50,16 +50,14 @@ class MercadoLivreMerchant(Merchant):
50
  def get_template(self, main_cupom, cupom_1, store = None) -> str:
51
  return f"""
52
  ###Template:
53
- {{Title}}
54
-
55
- (MERCADO LIVRE - {store.upper()} OFICIAL)
56
-
57
- {{Description}}
58
 
 
 
59
  Preço original: ~{{ORIGINAL PRICE}}~
60
  *HOJE: {{CUPOM DISCOUNTED PRICE}} — {{TOTAL DISCOUNT PERCENTAGE}}% OFF*
61
 
62
- 🎟️ CUPOM: {main_cupom}
63
  🛒 Compre aqui: {{short_url}}
64
 
65
  ⚠️ Selecione a loja oficial {store.upper()}
 
25
  def get_template(self, main_cupom, cupom_1, store = None) -> str:
26
  return f"""
27
  ###Template:
28
+ {{Description}}. {{Title}}
29
+
30
+ (ENTREGA FEITA PELA PRÓPRIA NATURA)
31
+
32
  Preço original: ~{{ORIGINAL PRICE}}~
33
  *HOJE: {{CUPOM DISCOUNTED PRICE}} — {{TOTAL DISCOUNT PERCENTAGE}}% OFF*
34
 
35
+ 🎟️ CUPOM: {main_cupom.upper()} {'ou ' + cupom_1.upper() if cupom_1.upper() else ''}
36
  🛒 Compre aqui: {{short_url}}
37
 
38
  ⚠️ Faça login com o mesmo email e senha que já usa para comprar na Natura!
 
50
  def get_template(self, main_cupom, cupom_1, store = None) -> str:
51
  return f"""
52
  ###Template:
53
+ {{Description}}. {{Title}}
 
 
 
 
54
 
55
+ (MERCADO LIVRE - {store.upper()} OFICIAL)
56
+
57
  Preço original: ~{{ORIGINAL PRICE}}~
58
  *HOJE: {{CUPOM DISCOUNTED PRICE}} — {{TOTAL DISCOUNT PERCENTAGE}}% OFF*
59
 
60
+ 🎟️ CUPOM: {main_cupom.upper()}
61
  🛒 Compre aqui: {{short_url}}
62
 
63
  ⚠️ Selecione a loja oficial {store.upper()}
utils_tools.py CHANGED
@@ -43,7 +43,7 @@ class CalculateDiscountValueTool(BaseTool):
43
  name: str = "Calculate Discount Value Tool"
44
  description: str = "Calculates the discount value after comparing two values."
45
 
46
- def _run(self, original_price: float, final_price: float) -> float:
47
 
48
  """Calculates the total discounted amount give the original and final price.
49
 
@@ -63,7 +63,7 @@ class CalculateDiscountValueTool(BaseTool):
63
 
64
  discount_value = original_price - final_price
65
  discount_percentage = (discount_value / original_price) * 100
66
- return round(discount_percentage, 0)
67
 
68
  class GetImageUrlTool(BaseTool):
69
  """
 
43
  name: str = "Calculate Discount Value Tool"
44
  description: str = "Calculates the discount value after comparing two values."
45
 
46
+ def _run(self, original_price: float, final_price: float) -> int:
47
 
48
  """Calculates the total discounted amount give the original and final price.
49
 
 
63
 
64
  discount_value = original_price - final_price
65
  discount_percentage = (discount_value / original_price) * 100
66
+ return int(discount_percentage)
67
 
68
  class GetImageUrlTool(BaseTool):
69
  """