ibombonato commited on
Commit
dcaeb19
·
verified ·
1 Parent(s): c8e9bca

chore: update templates

Browse files
Files changed (3) hide show
  1. app.py +2 -2
  2. merchs/merch.py +7 -15
  3. social_media_crew.py +2 -2
app.py CHANGED
@@ -105,7 +105,7 @@ with gr.Blocks() as demo:
105
  url_input = gr.Textbox(label="Product URL", placeholder="Enter product URL here...")
106
  store_name_input = gr.Textbox(label="Store Name (e.g., O Boticário)", placeholder="Enter store name...")
107
 
108
- main_cupom_input = gr.Textbox(label="Main Cupom (e.g., PRIMEIRACOMPRA)", value="MINHALOJATAON")
109
  main_cupom_discount_percentage_input = gr.Number(label="Main Cupom Discount Percentage (e.g., 20 for 20%)", value=15, minimum=0, maximum=100)
110
  cupom_1_input = gr.Textbox(label="Cupom 1 (e.g., AMIGO15)", placeholder="Enter first coupon code...")
111
  original_price_input = gr.Number(label="Original Price (Optional)", value=0, minimum=0)
@@ -155,7 +155,7 @@ with gr.Blocks() as demo:
155
  openai_key_input = gr.Textbox(label="OPENAI_API_KEY", type="password", value=os.getenv("OPENAI_API_KEY", ""))
156
  natura_token_input = gr.Textbox(label="NATURA_API_TOKEN", type="password", value=os.getenv("NATURA_API_TOKEN", ""))
157
  openai_base_url_input = gr.Textbox(label="OPENAI_BASE_URL", value=os.getenv("OPENAI_BASE_URL", "https://llm-openai-ibombonato.openai.azure.com/openai/deployments/gpt-4.1-mini/chat/completions?api-version=2025-01-01-preview"))
158
- openai_model_name_input = gr.Textbox(label="OPENAI_MODEL_NAME", value=os.getenv("OPENAI_MODEL_NAME", "azure/gpt-5-mini"))
159
 
160
  clean_env_vars()
161
  # No save button needed as keys are passed directly
 
105
  url_input = gr.Textbox(label="Product URL", placeholder="Enter product URL here...")
106
  store_name_input = gr.Textbox(label="Store Name (e.g., O Boticário)", placeholder="Enter store name...")
107
 
108
+ main_cupom_input = gr.Textbox(label="Main Cupom (e.g., PRIMEIRACOMPRA)", value="NOVEMBRO")
109
  main_cupom_discount_percentage_input = gr.Number(label="Main Cupom Discount Percentage (e.g., 20 for 20%)", value=15, minimum=0, maximum=100)
110
  cupom_1_input = gr.Textbox(label="Cupom 1 (e.g., AMIGO15)", placeholder="Enter first coupon code...")
111
  original_price_input = gr.Number(label="Original Price (Optional)", value=0, minimum=0)
 
155
  openai_key_input = gr.Textbox(label="OPENAI_API_KEY", type="password", value=os.getenv("OPENAI_API_KEY", ""))
156
  natura_token_input = gr.Textbox(label="NATURA_API_TOKEN", type="password", value=os.getenv("NATURA_API_TOKEN", ""))
157
  openai_base_url_input = gr.Textbox(label="OPENAI_BASE_URL", value=os.getenv("OPENAI_BASE_URL", "https://llm-openai-ibombonato.openai.azure.com/openai/deployments/gpt-4.1-mini/chat/completions?api-version=2025-01-01-preview"))
158
+ openai_model_name_input = gr.Textbox(label="OPENAI_MODEL_NAME", value=os.getenv("OPENAI_MODEL_NAME", "azure/gpt-4.1-mini"))
159
 
160
  clean_env_vars()
161
  # No save button needed as keys are passed directly
merchs/merch.py CHANGED
@@ -33,17 +33,13 @@ class NaturaMerchant(Merchant):
33
  def get_template(self, main_cupom, cupom_1, store = None) -> str:
34
  return f"""
35
  ###Template:
36
- {{Description}}. {{Title}}
37
 
38
- (ENTREGA FEITA PELA PRÓPRIA NATURA)
39
-
40
- Preço original: ~{{ORIGINAL PRICE}}~
41
- *HOJE: {{CUPOM DISCOUNTED PRICE}} — {{TOTAL DISCOUNT PERCENTAGE}}% OFF*
42
 
43
  🎟️ CUPOM: {main_cupom.upper()} {'ou ' + cupom_1.upper() if cupom_1.upper() else ''}
44
  🛒 Compre aqui: {{short_url}}
45
-
46
- ⚠️ Faça login com o mesmo email e senha que já usa para comprar na Natura!
47
  ###End Template
48
  """
49
 
@@ -58,17 +54,13 @@ class MercadoLivreMerchant(Merchant):
58
  def get_template(self, main_cupom, cupom_1, store = None) -> str:
59
  return f"""
60
  ###Template:
61
- {{Description}}. {{Title}}
62
-
63
- (MERCADO LIVRE - {store.upper()} OFICIAL)
64
 
65
- Preço original: ~{{ORIGINAL PRICE}}~
66
- *HOJE: {{CUPOM DISCOUNTED PRICE}} — {{TOTAL DISCOUNT PERCENTAGE}}% OFF*
67
 
68
- 🎟️ CUPOM: {main_cupom.upper()}
69
  🛒 Compre aqui: {{short_url}}
70
-
71
- ⚠️ Selecione a loja oficial {store.upper()}
72
  ###End Template
73
  """
74
 
 
33
  def get_template(self, main_cupom, cupom_1, store = None) -> str:
34
  return f"""
35
  ###Template:
36
+ {{Title}}
37
 
38
+ De: ~{{ORIGINAL PRICE}}~
39
+ 🔥*POR: {{CUPOM DISCOUNTED PRICE}} — {{TOTAL DISCOUNT PERCENTAGE}}% OFF*
 
 
40
 
41
  🎟️ CUPOM: {main_cupom.upper()} {'ou ' + cupom_1.upper() if cupom_1.upper() else ''}
42
  🛒 Compre aqui: {{short_url}}
 
 
43
  ###End Template
44
  """
45
 
 
54
  def get_template(self, main_cupom, cupom_1, store = None) -> str:
55
  return f"""
56
  ###Template:
57
+ {{Title}}
 
 
58
 
59
+ De: ~{{ORIGINAL PRICE}}~
60
+ 🔥 *Por: {{CUPOM DISCOUNTED PRICE}} — {{TOTAL DISCOUNT PERCENTAGE}}% OFF*
61
 
62
+ 🎟️ CUPOM: {main_cupom.upper()} {'ou ' + cupom_1.upper() if cupom_1.upper() else ''}
63
  🛒 Compre aqui: {{short_url}}
 
 
64
  ###End Template
65
  """
66
 
social_media_crew.py CHANGED
@@ -103,9 +103,9 @@ class SocialMediaCrew:
103
  def _create_post_task(self, analyze_product_task: Task, merchant, main_cupom: str, cupom_1: str, store_name: str) -> Task:
104
  template = merchant.get_template(main_cupom, cupom_1, store=store_name)
105
  return Task(
106
- 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'."),
107
  agent=self.social_media_copywriter,
108
- 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 one 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.",
109
  context=[analyze_product_task]
110
  )
111
 
 
103
  def _create_post_task(self, analyze_product_task: Task, merchant, main_cupom: str, cupom_1: str, store_name: str) -> Task:
104
  template = merchant.get_template(main_cupom, cupom_1, store=store_name)
105
  return Task(
106
+ 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. The title should contains ONLY the product name. 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'."),
107
  agent=self.social_media_copywriter,
108
+ expected_output="A short, template guided 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, one emoji in the Title.. If a field is not presented in the template, dont include it. 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.",
109
  context=[analyze_product_task]
110
  )
111