Spaces:
Sleeping
Sleeping
Create logic_seo.py
Browse files- logic_seo.py +56 -0
logic_seo.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import time
|
| 2 |
+
from google.genai import types
|
| 3 |
+
from config_style import THUMBNAIL_STRATEGIES
|
| 4 |
+
|
| 5 |
+
def get_youtube_planner_prompt(text):
|
| 6 |
+
return f"""
|
| 7 |
+
๋น์ ์ ๋ํ๋ฏผ๊ตญ ์ต๊ณ ์ ์ ํ๋ธ ์๊ณ ๋ฆฌ์ฆ ์ ๋ฌธ๊ฐ์ด์ ๋ฐ์ด๋ด ๋ง์ผํ
์ฒ์ฌ์
๋๋ค.
|
| 8 |
+
์๋ ๋๋ณธ์ ๋ถ์ํด์, ํด๋ฆญ๋ฅ (CTR)๊ณผ ์์ฒญ ์ง์ ์๊ฐ์ ๊ทน๋ํํ ์ ์๋ '์์ ํจํค์ง'์ ๊ธฐํํ์ธ์.
|
| 9 |
+
|
| 10 |
+
[๋๋ณธ ๋ด์ฉ]
|
| 11 |
+
{text}
|
| 12 |
+
|
| 13 |
+
[์๊ตฌ์ฌํญ]
|
| 14 |
+
1. **์ ๋ชฉ (5๊ฐ):** - ํธ๊ธฐ์ฌ ์๊ทน, ์ถฉ๊ฒฉ, ๋ฐ์ , ์ง๋ฌธํ ๋ฑ ๊ฐ๋ ฅํ ํํน ๋ฉํธ ์ฌ์ฉ.
|
| 15 |
+
2. **์ค๋ช
๋:** - ์ฒซ 2์ค์ ๊ฐ๋ ฅํ ํํน. SEO ํค์๋ ํฌํจ.
|
| 16 |
+
3. **ํ๊ทธ:** - ๊ฒ์๋ ๋ง์ ํค์๋ + ๋กฑํ
์ผ ํค์๋ 15๊ฐ ๋ด์ธ (์ผํ๋ก ๊ตฌ๋ถ).
|
| 17 |
+
|
| 18 |
+
[์ถ๋ ฅ ํ์]
|
| 19 |
+
---TITLE---
|
| 20 |
+
(์ ๋ชฉ ๋ด์ฉ๋ค)
|
| 21 |
+
---DESC---
|
| 22 |
+
(์ค๋ช
๋ด์ฉ๋ค)
|
| 23 |
+
---TAGS---
|
| 24 |
+
(ํ๊ทธ1, ํ๊ทธ2, ํ๊ทธ3)
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
def get_thumbnail_prompt_gen(text, strategy_name, strategy_prompt):
|
| 28 |
+
return f"""
|
| 29 |
+
Act as a Professional Thumbnail Designer.
|
| 30 |
+
Analyze the script and generate an Image Generation Prompt based on the specific strategy below.
|
| 31 |
+
|
| 32 |
+
[Script]
|
| 33 |
+
{text[:1500]}...
|
| 34 |
+
|
| 35 |
+
[Strategy: {strategy_name}]
|
| 36 |
+
{strategy_prompt}
|
| 37 |
+
|
| 38 |
+
**EXTREMELY IMPORTANT RULES:**
|
| 39 |
+
1. **TEXT LANGUAGE:** Any text that appears INSIDE the image (e.g., 'text: "..."') **MUST BE IN KOREAN**.
|
| 40 |
+
- Do NOT translate the catchy phrases from the script into English.
|
| 41 |
+
- The prompt description itself is in English, but the *content of the text overlay* is Korean.
|
| 42 |
+
|
| 43 |
+
2. **STYLE:** Adhere strictly to the visual style (Realistic vs 2D vs Hybrid).
|
| 44 |
+
|
| 45 |
+
**Task:**
|
| 46 |
+
Write the FINAL English prompt that will be fed into an AI Image Generator.
|
| 47 |
+
DO NOT include explanations. JUST the prompt.
|
| 48 |
+
"""
|
| 49 |
+
|
| 50 |
+
def generate_planning_task(key, strategy_prompt, script_input, client, model_id):
|
| 51 |
+
try:
|
| 52 |
+
sys_msg = get_thumbnail_prompt_gen(script_input, key, strategy_prompt)
|
| 53 |
+
resp = client.models.generate_content(model=model_id, contents=sys_msg)
|
| 54 |
+
return key, resp.text.strip()
|
| 55 |
+
except Exception as e:
|
| 56 |
+
return key, f"Error: {str(e)}"
|