File size: 4,343 Bytes
acca3b3
 
 
 
 
 
 
 
 
38b7b6d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
acca3b3
 
 
 
38b7b6d
acca3b3
 
38b7b6d
acca3b3
 
38b7b6d
acca3b3
 
38b7b6d
acca3b3
38b7b6d
 
acca3b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2c601e4
acca3b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import gradio as gr
import requests

# Gemini 1.5 Pro API setup
GEMINI_API_URL = "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-pro:generateContent"
API_KEY = "YOUR_API_KEY"  # Replace this with your Gemini API key

# System prompt / role instructions
main_prompt = """
You are an expert Amazon Merch on Demand (Print on Demand) listing optimizer.

You will be given a raw product listing, including a title, brand name, bullet point 1, bullet point 2, and a set of keywords.

Your task is to carefully analyze and professionally improve the entire listing while following strict Amazon Merch on Demand best practices.

Make the following improvements in your response:

---

βœ… **Title (≀ 60 characters):**  
- Prioritize relevant high-volume keywords (e.g. "T-Shirt" instead of "Tee").  
- Include niche, audience, occasion/holiday if relevant.  
- Maintain clarity, appeal, and Amazon compliance.  
- No emojis, no pipes (|), no all-caps words.

βœ… **Brand Name (≀ 50 characters):**  
- Keep it niche-relevant, creative, and Amazon-appropriate.  
- You may improve the brand name only if it's generic or lacks niche alignment.

βœ… **Bullet Point 1 (200–256 characters):**  
- Start with an ALL-CAPS benefit-driven hook (like "FUEL YOUR DAY!" or "COFFEE LOVER MUST-HAVE!")  
- Describe who the product is for and when to wear it (lifestyle, event, occasion).  
- Mention the core emotional/functional benefit (e.g., soft, comfy, relatable).  
- Avoid generic filler. Be natural but clear.

βœ… **Bullet Point 2 (200–256 characters):**  
- Start with another ALL-CAPS benefit hook (like "GREAT GIFT IDEA!" or "PERFECT FOR COFFEE ADDICTS!")  
- Emphasize giftability or uniqueness.  
- Mention comfort, style, and appeal.  
- **DO NOT use phrases like β€œClick Add to Cart”** β€” this violates Amazon Merch on Demand guidelines.  
- Maintain persuasive language and urgency in a compliant way.

βœ… **Keywords:**  
- Refine keyword list to include high-search and long-tail terms.  
- Avoid keyword stuffing.  
- Use commas, no quotes, and no repetition.  
- Balance between short-tail, gender-specific, seasonal, and evergreen search phrases.

---

πŸ’‘ Think like a top Amazon seller: Use clear, concise, persuasive language that appeals to emotional triggers (like humor, identity, or gifting). Ensure your output follows Amazon's rules and character limits.

Return your output in this exact structure:

---

**Title (≀ 60 characters):**  
[Improved Title]

**Brand Name (≀ 50 characters):**  
[Improved Brand Name]

**Bullet Point 1 (200–256 characters):**  
[Improved Bullet Point 1]

**Bullet Point 2 (200–256 characters):**  
[Improved Bullet Point 2]

**Optimized Keywords:**  
[keyword, keyword, keyword, ...]
---
"""

# Function to call Gemini API
def optimize_listing(user_input):
    headers = {
        "Content-Type": "application/json"
    }

    payload = {
        "contents": [{
            "parts": [{
                "text": f"{main_prompt}\n\n{user_input.strip()}"
            }]
        }],
        "generationConfig": {
            "temperature": 0.8,
            "topP": 1,
            "topK": 1,
            "maxOutputTokens": 1024
        }
    }

    response = requests.post(
        f"{GEMINI_API_URL}?key={API_KEY}",
        headers=headers,
        json=payload
    )

    if response.status_code == 200:
        result = response.json()
        return result['candidates'][0]['content']['parts'][0]['text']
    else:
        return f"Error: {response.status_code} - {response.text}"

# Gradio UI
with gr.Blocks(theme=gr.themes.Soft()) as app:
    gr.Markdown("## πŸ›οΈ Amazon POD Listing Optimizer (Powered by Gemini 1.5 Pro)")
    api_key_input = gr.Textbox(label="πŸ”‘ Your Gemini API Key", type="password")
    listing_input = gr.Textbox(label="πŸ“„ Paste Your Full Listing Below", lines=15, placeholder="Paste your Title, Brand Name, Bullet Points, and Keywords...")
    output_text = gr.Textbox(label="βœ… Optimized Listing", lines=20)
    submit_btn = gr.Button("✨ Optimize Listing")

    def run_app(listing, key):
        global API_KEY
        API_KEY = key.strip()
        return optimize_listing(listing)

    submit_btn.click(fn=run_app, inputs=[listing_input, api_key_input], outputs=output_text)

# Run locally or on Hugging Face Spaces
app.launch()