Merge branch 'main' of https://gitea.o2o.kr/castad/o2o-castad-backend into feature-dashboard
This commit is contained in:
commit
d955ac80f1
23 files changed
+1885
-1349
No files matched your search
@@ -0,0 +1,48 @@
|
||||
from pydantic.main import BaseModel
|
||||
|
||||
from app.utils.prompts.chatgpt_prompt import ChatgptService
|
||||
from app.utils.prompts.prompts import image_autotag_prompt
|
||||
from app.utils.prompts.schemas import SpaceType, Subject, Camera, MotionRecommended
|
||||
|
||||
import asyncio
|
||||
|
||||
async def autotag_image(image_url : str) -> list[str]: #tag_list
|
||||
chatgpt = ChatgptService(model_type="gemini")
|
||||
image_input_data = {
|
||||
"img_url" : image_url,
|
||||
"space_type" : list(SpaceType),
|
||||
"subject" : list(Subject),
|
||||
"camera" : list(Camera),
|
||||
"motion_recommended" : list(MotionRecommended)
|
||||
}
|
||||
|
||||
image_result = await chatgpt.generate_structured_output(image_autotag_prompt, image_input_data, image_url, False)
|
||||
return image_result
|
||||
|
||||
async def autotag_images(image_url_list : list[str]) -> list[dict]: #tag_list
|
||||
chatgpt = ChatgptService(model_type="gemini")
|
||||
image_input_data_list = [{
|
||||
"img_url" : image_url,
|
||||
"space_type" : list(SpaceType),
|
||||
"subject" : list(Subject),
|
||||
"camera" : list(Camera),
|
||||
"motion_recommended" : list(MotionRecommended)
|
||||
}for image_url in image_url_list]
|
||||
|
||||
image_result_tasks = [chatgpt.generate_structured_output(image_autotag_prompt, image_input_data, image_input_data['img_url'], False, silent = True) for image_input_data in image_input_data_list]
|
||||
image_result_list: list[BaseModel | BaseException] = await asyncio.gather(*image_result_tasks, return_exceptions=True)
|
||||
MAX_RETRY = 3 # 하드코딩, 어떻게 처리할지는 나중에
|
||||
for _ in range(MAX_RETRY):
|
||||
failed_idx = [i for i, r in enumerate(image_result_list) if isinstance(r, Exception)]
|
||||
print("Failed", failed_idx)
|
||||
if not failed_idx:
|
||||
break
|
||||
retried = await asyncio.gather(
|
||||
*[chatgpt.generate_structured_output(image_autotag_prompt, image_input_data_list[i], image_input_data_list[i]['img_url'], False, silent=True) for i in failed_idx],
|
||||
return_exceptions=True
|
||||
)
|
||||
for i, result in zip(failed_idx, retried):
|
||||
image_result_list[i] = result
|
||||
|
||||
print("Failed", failed_idx)
|
||||
return image_result_list
|
||||
@@ -1,95 +0,0 @@
|
||||
import json
|
||||
import re
|
||||
from pydantic import BaseModel
|
||||
from openai import AsyncOpenAI
|
||||
|
||||
from app.utils.logger import get_logger
|
||||
from config import apikey_settings, recovery_settings
|
||||
from app.utils.prompts.prompts import Prompt
|
||||
|
||||
|
||||
# 로거 설정
|
||||
logger = get_logger("chatgpt")
|
||||
|
||||
|
||||
class ChatGPTResponseError(Exception):
|
||||
"""ChatGPT API 응답 에러"""
|
||||
def __init__(self, status: str, error_code: str = None, error_message: str = None):
|
||||
self.status = status
|
||||
self.error_code = error_code
|
||||
self.error_message = error_message
|
||||
super().__init__(f"ChatGPT response failed: status={status}, code={error_code}, message={error_message}")
|
||||
|
||||
|
||||
class ChatgptService:
|
||||
"""ChatGPT API 서비스 클래스
|
||||
"""
|
||||
|
||||
def __init__(self, timeout: float = None):
|
||||
self.timeout = timeout or recovery_settings.CHATGPT_TIMEOUT
|
||||
self.max_retries = recovery_settings.CHATGPT_MAX_RETRIES
|
||||
self.client = AsyncOpenAI(
|
||||
api_key=apikey_settings.CHATGPT_API_KEY,
|
||||
timeout=self.timeout
|
||||
)
|
||||
|
||||
async def _call_pydantic_output(self, prompt : str, output_format : BaseModel, model : str) -> BaseModel: # 입력 output_format의 경우 Pydantic BaseModel Class를 상속한 Class 자체임에 유의할 것
|
||||
content = [{"type": "input_text", "text": prompt}]
|
||||
last_error = None
|
||||
for attempt in range(self.max_retries + 1):
|
||||
response = await self.client.responses.parse(
|
||||
model=model,
|
||||
input=[{"role": "user", "content": content}],
|
||||
text_format=output_format
|
||||
)
|
||||
# Response 디버그 로깅
|
||||
logger.debug(f"[ChatgptService] attempt: {attempt}")
|
||||
logger.debug(f"[ChatgptService] Response ID: {response.id}")
|
||||
logger.debug(f"[ChatgptService] Response status: {response.status}")
|
||||
logger.debug(f"[ChatgptService] Response model: {response.model}")
|
||||
|
||||
# status 확인: completed, failed, incomplete, cancelled, queued, in_progress
|
||||
if response.status == "completed":
|
||||
logger.debug(f"[ChatgptService] Response output_text: {response.output_text[:200]}..." if len(response.output_text) > 200 else f"[ChatgptService] Response output_text: {response.output_text}")
|
||||
structured_output = response.output_parsed
|
||||
return structured_output #.model_dump() or {}
|
||||
|
||||
# 에러 상태 처리
|
||||
if response.status == "failed":
|
||||
error_code = getattr(response.error, 'code', None) if response.error else None
|
||||
error_message = getattr(response.error, 'message', None) if response.error else None
|
||||
logger.warning(f"[ChatgptService] Response failed (attempt {attempt + 1}/{self.max_retries + 1}): code={error_code}, message={error_message}")
|
||||
last_error = ChatGPTResponseError(response.status, error_code, error_message)
|
||||
|
||||
elif response.status == "incomplete":
|
||||
reason = getattr(response.incomplete_details, 'reason', None) if response.incomplete_details else None
|
||||
logger.warning(f"[ChatgptService] Response incomplete (attempt {attempt + 1}/{self.max_retries + 1}): reason={reason}")
|
||||
last_error = ChatGPTResponseError(response.status, reason, f"Response incomplete: {reason}")
|
||||
|
||||
else:
|
||||
# cancelled, queued, in_progress 등 예상치 못한 상태
|
||||
logger.warning(f"[ChatgptService] Unexpected response status (attempt {attempt + 1}/{self.max_retries + 1}): {response.status}")
|
||||
last_error = ChatGPTResponseError(response.status, None, f"Unexpected status: {response.status}")
|
||||
|
||||
# 마지막 시도가 아니면 재시도
|
||||
if attempt < self.max_retries:
|
||||
logger.info(f"[ChatgptService] Retrying request...")
|
||||
|
||||
# 모든 재시도 실패
|
||||
logger.error(f"[ChatgptService] All retries exhausted. Last error: {last_error}")
|
||||
raise last_error
|
||||
|
||||
async def generate_structured_output(
|
||||
self,
|
||||
prompt : Prompt,
|
||||
input_data : dict,
|
||||
) -> BaseModel:
|
||||
prompt_text = prompt.build_prompt(input_data)
|
||||
|
||||
logger.debug(f"[ChatgptService] Generated Prompt (length: {len(prompt_text)})")
|
||||
logger.info(f"[ChatgptService] Starting GPT request with structured output with model: {prompt.prompt_model}")
|
||||
|
||||
# GPT API 호출
|
||||
#response = await self._call_structured_output_with_response_gpt_api(prompt_text, prompt.prompt_output, prompt.prompt_model)
|
||||
response = await self._call_pydantic_output(prompt_text, prompt.prompt_output_class, prompt.prompt_model)
|
||||
return response
|
||||
+83
-52
@@ -31,11 +31,13 @@ response = await creatomate.make_creatomate_call(template_id, modifications)
|
||||
|
||||
import copy
|
||||
import time
|
||||
from enum import StrEnum
|
||||
from typing import Literal
|
||||
|
||||
import traceback
|
||||
import httpx
|
||||
|
||||
from app.utils.logger import get_logger
|
||||
from app.utils.prompts.schemas.image import SpaceType,Subject,Camera,MotionRecommended,NarrativePhase
|
||||
from config import apikey_settings, creatomate_settings, recovery_settings
|
||||
|
||||
# 로거 설정
|
||||
@@ -226,8 +228,9 @@ DVST0003 = "e1fb5b00-1f02-4f63-99fa-7524b433ba47"
|
||||
DHST0001 = "660be601-080a-43ea-bf0f-adcf4596fa98"
|
||||
DHST0002 = "3f194cc7-464e-4581-9db2-179d42d3e40f"
|
||||
DHST0003 = "f45df555-2956-4a13-9004-ead047070b3d"
|
||||
DVST0001T = "fe11aeab-ff29-4bc8-9f75-c695c7e243e6"
|
||||
HST_LIST = [DHST0001,DHST0002,DHST0003]
|
||||
VST_LIST = [DVST0001,DVST0002,DVST0003]
|
||||
VST_LIST = [DVST0001,DVST0002,DVST0003, DVST0001T]
|
||||
|
||||
SCENE_TRACK = 1
|
||||
AUDIO_TRACK = 2
|
||||
@@ -238,7 +241,7 @@ def select_template(orientation:OrientationType):
|
||||
if orientation == "horizontal":
|
||||
return DHST0001
|
||||
elif orientation == "vertical":
|
||||
return DVST0001
|
||||
return DVST0001T
|
||||
else:
|
||||
raise
|
||||
|
||||
@@ -399,14 +402,6 @@ class CreatomateService:
|
||||
|
||||
return copy.deepcopy(data)
|
||||
|
||||
# 하위 호환성을 위한 별칭 (deprecated)
|
||||
async def get_one_template_data_async(self, template_id: str) -> dict:
|
||||
"""특정 템플릿 ID로 템플릿 정보를 조회합니다.
|
||||
|
||||
Deprecated: get_one_template_data()를 사용하세요.
|
||||
"""
|
||||
return await self.get_one_template_data(template_id)
|
||||
|
||||
def parse_template_component_name(self, template_source: list) -> dict:
|
||||
"""템플릿 정보를 파싱하여 리소스 이름을 추출합니다."""
|
||||
|
||||
@@ -433,42 +428,93 @@ class CreatomateService:
|
||||
result.update(result_element_dict)
|
||||
|
||||
return result
|
||||
|
||||
async def template_connect_resource_blackbox(
|
||||
|
||||
async def parse_template_name_tag(resource_name : str) -> list:
|
||||
tag_list = []
|
||||
tag_list = resource_name.split("_")
|
||||
|
||||
return tag_list
|
||||
|
||||
|
||||
def template_matching_taged_image(
|
||||
self,
|
||||
template_id: str,
|
||||
image_url_list: list[str],
|
||||
template : dict,
|
||||
taged_image_list : list, # [{"image_name" : str , "image_tag" : dict}]
|
||||
music_url: str,
|
||||
address: str = None
|
||||
) -> dict:
|
||||
"""템플릿 정보와 이미지/가사/음악 리소스를 매핑합니다.
|
||||
address : str,
|
||||
duplicate : bool = False
|
||||
) -> list:
|
||||
source_elements = template["source"]["elements"]
|
||||
template_component_data = self.parse_template_component_name(source_elements)
|
||||
|
||||
Note:
|
||||
- 이미지는 순차적으로 집어넣기
|
||||
- 가사는 개행마다 한 텍스트 삽입
|
||||
- Template에 audio-music 항목이 있어야 함
|
||||
"""
|
||||
template_data = await self.get_one_template_data(template_id)
|
||||
template_component_data = self.parse_template_component_name(
|
||||
template_data["source"]["elements"]
|
||||
)
|
||||
modifications = {}
|
||||
|
||||
for idx, (template_component_name, template_type) in enumerate(
|
||||
template_component_data.items()
|
||||
):
|
||||
for slot_idx, (template_component_name, template_type) in enumerate(template_component_data.items()):
|
||||
match template_type:
|
||||
case "image":
|
||||
modifications[template_component_name] = image_url_list[
|
||||
idx % len(image_url_list)
|
||||
]
|
||||
image_score_list = self.calculate_image_slot_score_multi(taged_image_list, template_component_name)
|
||||
maximum_idx = image_score_list.index(max(image_score_list))
|
||||
if duplicate:
|
||||
selected = taged_image_list[maximum_idx]
|
||||
else:
|
||||
selected = taged_image_list.pop(maximum_idx)
|
||||
image_name = selected["image_url"]
|
||||
modifications[template_component_name] =image_name
|
||||
pass
|
||||
case "text":
|
||||
if "address_input" in template_component_name:
|
||||
modifications[template_component_name] = address
|
||||
|
||||
modifications["audio-music"] = music_url
|
||||
|
||||
return modifications
|
||||
|
||||
def calculate_image_slot_score_multi(self, taged_image_list : list[dict], slot_name : str):
|
||||
image_tag_list = [taged_image["image_tag"] for taged_image in taged_image_list]
|
||||
slot_tag_dict = self.parse_slot_name_to_tag(slot_name)
|
||||
image_score_list = [0] * len(image_tag_list)
|
||||
|
||||
for slot_tag_cate, slot_tag_item in slot_tag_dict.items():
|
||||
if slot_tag_cate == "narrative_preference":
|
||||
slot_tag_narrative = slot_tag_item
|
||||
continue
|
||||
|
||||
match slot_tag_cate:
|
||||
case "space_type":
|
||||
weight = 2
|
||||
case "subject" :
|
||||
weight = 2
|
||||
case "camera":
|
||||
weight = 1
|
||||
case "motion_recommended" :
|
||||
weight = 0.5
|
||||
case _:
|
||||
raise
|
||||
|
||||
for idx, image_tag in enumerate(image_tag_list):
|
||||
if slot_tag_item.value in image_tag[slot_tag_cate]: #collect!
|
||||
image_score_list[idx] += weight
|
||||
|
||||
for idx, image_tag in enumerate(image_tag_list):
|
||||
image_narrative_score = image_tag["narrative_preference"][slot_tag_narrative]
|
||||
image_score_list[idx] = image_score_list[idx] * image_narrative_score
|
||||
|
||||
return image_score_list
|
||||
|
||||
def parse_slot_name_to_tag(self, slot_name : str) -> dict[str, StrEnum]:
|
||||
tag_list = slot_name.split("-")
|
||||
space_type = SpaceType(tag_list[0])
|
||||
subject = Subject(tag_list[1])
|
||||
camera = Camera(tag_list[2])
|
||||
motion = MotionRecommended(tag_list[3])
|
||||
narrative = NarrativePhase(tag_list[4])
|
||||
tag_dict = {
|
||||
"space_type" : space_type,
|
||||
"subject" : subject,
|
||||
"camera" : camera,
|
||||
"motion_recommended" : motion,
|
||||
"narrative_preference" : narrative,
|
||||
}
|
||||
return tag_dict
|
||||
|
||||
def elements_connect_resource_blackbox(
|
||||
self,
|
||||
@@ -669,14 +715,6 @@ class CreatomateService:
|
||||
original_response={"last_error": str(last_error)},
|
||||
)
|
||||
|
||||
# 하위 호환성을 위한 별칭 (deprecated)
|
||||
async def make_creatomate_custom_call_async(self, source: dict) -> dict:
|
||||
"""템플릿 없이 Creatomate에 커스텀 렌더링 요청을 보냅니다.
|
||||
|
||||
Deprecated: make_creatomate_custom_call()을 사용하세요.
|
||||
"""
|
||||
return await self.make_creatomate_custom_call(source)
|
||||
|
||||
async def get_render_status(self, render_id: str) -> dict:
|
||||
"""렌더링 작업의 상태를 조회합니다.
|
||||
|
||||
@@ -700,14 +738,6 @@ class CreatomateService:
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
|
||||
# 하위 호환성을 위한 별칭 (deprecated)
|
||||
async def get_render_status_async(self, render_id: str) -> dict:
|
||||
"""렌더링 작업의 상태를 조회합니다.
|
||||
|
||||
Deprecated: get_render_status()를 사용하세요.
|
||||
"""
|
||||
return await self.get_render_status(render_id)
|
||||
|
||||
def calc_scene_duration(self, template: dict) -> float:
|
||||
"""템플릿의 전체 장면 duration을 계산합니다."""
|
||||
total_template_duration = 0.0
|
||||
@@ -720,19 +750,20 @@ class CreatomateService:
|
||||
try:
|
||||
if elem["track"] not in track_maximum_duration:
|
||||
continue
|
||||
if elem["time"] == 0: # elem is auto / 만약 마지막 elem이 auto인데 그 앞에 time이 있는 elem 일 시 버그 발생 확률 있음
|
||||
if "time" not in elem or elem["time"] == 0: # elem is auto / 만약 마지막 elem이 auto인데 그 앞에 time이 있는 elem 일 시 버그 발생 확률 있음
|
||||
track_maximum_duration[elem["track"]] += elem["duration"]
|
||||
|
||||
if "animations" not in elem:
|
||||
continue
|
||||
for animation in elem["animations"]:
|
||||
assert animation["time"] == 0 # 0이 아닌 경우 확인 필요
|
||||
if animation["transition"]:
|
||||
if "transition" in animation and animation["transition"]:
|
||||
track_maximum_duration[elem["track"]] -= animation["duration"]
|
||||
else:
|
||||
track_maximum_duration[elem["track"]] = max(track_maximum_duration[elem["track"]], elem["time"] + elem["duration"])
|
||||
|
||||
except Exception as e:
|
||||
logger.debug(traceback.format_exc())
|
||||
logger.error(f"[calc_scene_duration] Error processing element: {elem}, {e}")
|
||||
|
||||
total_template_duration = max(track_maximum_duration.values())
|
||||
|
||||
+20
-22
@@ -16,6 +16,10 @@ class GraphQLException(Exception):
|
||||
"""GraphQL 요청 실패 시 발생하는 예외"""
|
||||
pass
|
||||
|
||||
class URLNotFoundException(Exception):
|
||||
"""Place ID 발견 불가능 시 발생하는 예외"""
|
||||
pass
|
||||
|
||||
|
||||
class CrawlingTimeoutException(Exception):
|
||||
"""크롤링 타임아웃 시 발생하는 예외"""
|
||||
@@ -86,34 +90,28 @@ query getAccommodation($id: String!, $deviceType: String) {
|
||||
async with session.get(self.url) as response:
|
||||
self.url = str(response.url)
|
||||
else:
|
||||
raise GraphQLException("This URL does not contain a place ID")
|
||||
raise URLNotFoundException("This URL does not contain a place ID")
|
||||
|
||||
match = re.search(place_pattern, self.url)
|
||||
if not match:
|
||||
raise GraphQLException("Failed to parse place ID from URL")
|
||||
raise URLNotFoundException("Failed to parse place ID from URL")
|
||||
return match[1]
|
||||
|
||||
async def scrap(self):
|
||||
try:
|
||||
place_id = await self.parse_url()
|
||||
data = await self._call_get_accommodation(place_id)
|
||||
self.rawdata = data
|
||||
fac_data = await self._get_facility_string(place_id)
|
||||
# Naver 기준임, 구글 등 다른 데이터 소스의 경우 고유 Identifier 사용할 것.
|
||||
self.place_id = self.data_source_identifier + place_id
|
||||
self.rawdata["facilities"] = fac_data
|
||||
self.image_link_list = [
|
||||
nv_image["origin"]
|
||||
for nv_image in data["data"]["business"]["images"]["images"]
|
||||
]
|
||||
self.base_info = data["data"]["business"]["base"]
|
||||
self.facility_info = fac_data
|
||||
self.scrap_type = "GraphQL"
|
||||
|
||||
except GraphQLException:
|
||||
logger.debug("GraphQL failed, fallback to Playwright")
|
||||
self.scrap_type = "Playwright"
|
||||
pass # 나중에 pw 이용한 crawling으로 fallback 추가
|
||||
place_id = await self.parse_url()
|
||||
data = await self._call_get_accommodation(place_id)
|
||||
self.rawdata = data
|
||||
fac_data = await self._get_facility_string(place_id)
|
||||
# Naver 기준임, 구글 등 다른 데이터 소스의 경우 고유 Identifier 사용할 것.
|
||||
self.place_id = self.data_source_identifier + place_id
|
||||
self.rawdata["facilities"] = fac_data
|
||||
self.image_link_list = [
|
||||
nv_image["origin"]
|
||||
for nv_image in data["data"]["business"]["images"]["images"]
|
||||
]
|
||||
self.base_info = data["data"]["business"]["base"]
|
||||
self.facility_info = fac_data
|
||||
self.scrap_type = "GraphQL"
|
||||
|
||||
return
|
||||
|
||||
|
||||
@@ -0,0 +1,191 @@
|
||||
import json
|
||||
import re
|
||||
from pydantic import BaseModel
|
||||
from typing import List, Optional
|
||||
from openai import AsyncOpenAI
|
||||
|
||||
from app.utils.logger import get_logger
|
||||
from config import apikey_settings, recovery_settings
|
||||
from app.utils.prompts.prompts import Prompt
|
||||
|
||||
|
||||
# 로거 설정
|
||||
logger = get_logger("chatgpt")
|
||||
|
||||
|
||||
class ChatGPTResponseError(Exception):
|
||||
"""ChatGPT API 응답 에러"""
|
||||
def __init__(self, status: str, error_code: str = None, error_message: str = None):
|
||||
self.status = status
|
||||
self.error_code = error_code
|
||||
self.error_message = error_message
|
||||
super().__init__(f"ChatGPT response failed: status={status}, code={error_code}, message={error_message}")
|
||||
|
||||
|
||||
class ChatgptService:
|
||||
"""ChatGPT API 서비스 클래스
|
||||
"""
|
||||
|
||||
model_type : str
|
||||
|
||||
def __init__(self, model_type:str = "gpt", timeout: float = None):
|
||||
self.timeout = timeout or recovery_settings.CHATGPT_TIMEOUT
|
||||
self.max_retries = recovery_settings.CHATGPT_MAX_RETRIES
|
||||
self.model_type = model_type
|
||||
match model_type:
|
||||
case "gpt":
|
||||
self.client = AsyncOpenAI(
|
||||
api_key=apikey_settings.CHATGPT_API_KEY,
|
||||
timeout=self.timeout
|
||||
)
|
||||
case "gemini":
|
||||
self.client = AsyncOpenAI(
|
||||
api_key=apikey_settings.GEMINI_API_KEY,
|
||||
base_url="https://generativelanguage.googleapis.com/v1beta/openai/",
|
||||
timeout=self.timeout
|
||||
)
|
||||
case _:
|
||||
raise NotImplementedError(f"Unknown Provider : {model_type}")
|
||||
|
||||
async def _call_pydantic_output(
|
||||
self,
|
||||
prompt : str,
|
||||
output_format : BaseModel, #입력 output_format의 경우 Pydantic BaseModel Class를 상속한 Class 자체임에 유의할 것
|
||||
model : str,
|
||||
img_url : str,
|
||||
image_detail_high : bool) -> BaseModel:
|
||||
content = []
|
||||
if img_url:
|
||||
content.append({
|
||||
"type" : "input_image",
|
||||
"image_url" : img_url,
|
||||
"detail": "high" if image_detail_high else "low"
|
||||
})
|
||||
content.append({
|
||||
"type": "input_text",
|
||||
"text": prompt}
|
||||
)
|
||||
last_error = None
|
||||
for attempt in range(self.max_retries + 1):
|
||||
response = await self.client.responses.parse(
|
||||
model=model,
|
||||
input=[{"role": "user", "content": content}],
|
||||
text_format=output_format
|
||||
)
|
||||
# Response 디버그 로깅
|
||||
logger.debug(f"[ChatgptService({self.model_type})] attempt: {attempt}")
|
||||
logger.debug(f"[ChatgptService({self.model_type})] Response ID: {response.id}")
|
||||
logger.debug(f"[ChatgptService({self.model_type})] Response status: {response.status}")
|
||||
logger.debug(f"[ChatgptService({self.model_type})] Response model: {response.model}")
|
||||
|
||||
# status 확인: completed, failed, incomplete, cancelled, queued, in_progress
|
||||
if response.status == "completed":
|
||||
logger.debug(f"[ChatgptService({self.model_type})] Response output_text: {response.output_text[:200]}..." if len(response.output_text) > 200 else f"[ChatgptService] Response output_text: {response.output_text}")
|
||||
structured_output = response.output_parsed
|
||||
return structured_output #.model_dump() or {}
|
||||
|
||||
# 에러 상태 처리
|
||||
if response.status == "failed":
|
||||
error_code = getattr(response.error, 'code', None) if response.error else None
|
||||
error_message = getattr(response.error, 'message', None) if response.error else None
|
||||
logger.warning(f"[ChatgptService({self.model_type})] Response failed (attempt {attempt + 1}/{self.max_retries + 1}): code={error_code}, message={error_message}")
|
||||
last_error = ChatGPTResponseError(response.status, error_code, error_message)
|
||||
|
||||
elif response.status == "incomplete":
|
||||
reason = getattr(response.incomplete_details, 'reason', None) if response.incomplete_details else None
|
||||
logger.warning(f"[ChatgptService({self.model_type})] Response incomplete (attempt {attempt + 1}/{self.max_retries + 1}): reason={reason}")
|
||||
last_error = ChatGPTResponseError(response.status, reason, f"Response incomplete: {reason}")
|
||||
|
||||
else:
|
||||
# cancelled, queued, in_progress 등 예상치 못한 상태
|
||||
logger.warning(f"[ChatgptService({self.model_type})] Unexpected response status (attempt {attempt + 1}/{self.max_retries + 1}): {response.status}")
|
||||
last_error = ChatGPTResponseError(response.status, None, f"Unexpected status: {response.status}")
|
||||
|
||||
# 마지막 시도가 아니면 재시도
|
||||
if attempt < self.max_retries:
|
||||
logger.info(f"[ChatgptService({self.model_type})] Retrying request...")
|
||||
|
||||
# 모든 재시도 실패
|
||||
logger.error(f"[ChatgptService({self.model_type})] All retries exhausted. Last error: {last_error}")
|
||||
raise last_error
|
||||
|
||||
async def _call_pydantic_output_chat_completion( # alter version
|
||||
self,
|
||||
prompt : str,
|
||||
output_format : BaseModel, #입력 output_format의 경우 Pydantic BaseModel Class를 상속한 Class 자체임에 유의할 것
|
||||
model : str,
|
||||
img_url : str,
|
||||
image_detail_high : bool) -> BaseModel:
|
||||
content = []
|
||||
if img_url:
|
||||
content.append({
|
||||
"type": "image_url",
|
||||
"image_url": {
|
||||
"url": img_url,
|
||||
"detail": "high" if image_detail_high else "low"
|
||||
}
|
||||
})
|
||||
content.append({
|
||||
"type": "text",
|
||||
"text": prompt
|
||||
})
|
||||
last_error = None
|
||||
for attempt in range(self.max_retries + 1):
|
||||
response = await self.client.beta.chat.completions.parse(
|
||||
model=model,
|
||||
messages=[{"role": "user", "content": content}],
|
||||
response_format=output_format
|
||||
)
|
||||
# Response 디버그 로깅
|
||||
logger.debug(f"[ChatgptService({self.model_type})] attempt: {attempt}")
|
||||
logger.debug(f"[ChatgptService({self.model_type})] Response ID: {response.id}")
|
||||
logger.debug(f"[ChatgptService({self.model_type})] Response finish_reason: {response.id}")
|
||||
logger.debug(f"[ChatgptService({self.model_type})] Response model: {response.model}")
|
||||
|
||||
choice = response.choices[0]
|
||||
finish_reason = choice.finish_reason
|
||||
|
||||
if finish_reason == "stop":
|
||||
output_text = choice.message.content or ""
|
||||
logger.debug(f"[ChatgptService({self.model_type})] Response output_text: {output_text[:200]}..." if len(output_text) > 200 else f"[ChatgptService] Response output_text: {output_text}")
|
||||
return choice.message.parsed
|
||||
|
||||
elif finish_reason == "length":
|
||||
logger.warning(f"[ChatgptService({self.model_type})] Response incomplete - token limit reached (attempt {attempt + 1}/{self.max_retries + 1})")
|
||||
last_error = ChatGPTResponseError("incomplete", finish_reason, "Response incomplete: max tokens reached")
|
||||
|
||||
elif finish_reason == "content_filter":
|
||||
logger.warning(f"[ChatgptService({self.model_type})] Response blocked by content filter (attempt {attempt + 1}/{self.max_retries + 1})")
|
||||
last_error = ChatGPTResponseError("failed", finish_reason, "Response blocked by content filter")
|
||||
|
||||
else:
|
||||
logger.warning(f"[ChatgptService({self.model_type})] Unexpected finish_reason (attempt {attempt + 1}/{self.max_retries + 1}): {finish_reason}")
|
||||
last_error = ChatGPTResponseError("failed", finish_reason, f"Unexpected finish_reason: {finish_reason}")
|
||||
|
||||
# 마지막 시도가 아니면 재시도
|
||||
if attempt < self.max_retries:
|
||||
logger.info(f"[ChatgptService({self.model_type})] Retrying request...")
|
||||
|
||||
# 모든 재시도 실패
|
||||
logger.error(f"[ChatgptService({self.model_type})] All retries exhausted. Last error: {last_error}")
|
||||
raise last_error
|
||||
|
||||
async def generate_structured_output(
|
||||
self,
|
||||
prompt : Prompt,
|
||||
input_data : dict,
|
||||
img_url : Optional[str] = None,
|
||||
img_detail_high : bool = False,
|
||||
silent : bool = False
|
||||
) -> BaseModel:
|
||||
prompt_text = prompt.build_prompt(input_data, silent)
|
||||
|
||||
logger.debug(f"[ChatgptService({self.model_type})] Generated Prompt (length: {len(prompt_text)})")
|
||||
if not silent:
|
||||
logger.info(f"[ChatgptService({self.model_type})] Starting GPT request with structured output with model: {prompt.prompt_model}")
|
||||
|
||||
# GPT API 호출
|
||||
#parsed = await self._call_structured_output_with_response_gpt_api(prompt_text, prompt.prompt_output, prompt.prompt_model)
|
||||
# parsed = await self._call_pydantic_output(prompt_text, prompt.prompt_output_class, prompt.prompt_model, img_url, img_detail_high)
|
||||
parsed = await self._call_pydantic_output_chat_completion(prompt_text, prompt.prompt_output_class, prompt.prompt_model, img_url, img_detail_high)
|
||||
return parsed
|
||||
@@ -40,11 +40,13 @@ class Prompt():
|
||||
def _reload_prompt(self):
|
||||
self.prompt_template, self.prompt_model = self._read_from_sheets()
|
||||
|
||||
def build_prompt(self, input_data: dict) -> str:
|
||||
def build_prompt(self, input_data:dict, silent:bool = False) -> str:
|
||||
verified_input = self.prompt_input_class(**input_data)
|
||||
build_template = self.prompt_template.format(**verified_input.model_dump())
|
||||
logger.debug(f"build_template: {build_template}")
|
||||
logger.debug(f"input_data: {input_data}")
|
||||
build_template = self.prompt_template
|
||||
build_template = build_template.format(**verified_input.model_dump())
|
||||
if not silent:
|
||||
logger.debug(f"build_template: {build_template}")
|
||||
logger.debug(f"input_data: {input_data}")
|
||||
return build_template
|
||||
|
||||
marketing_prompt = Prompt(
|
||||
@@ -65,6 +67,20 @@ yt_upload_prompt = Prompt(
|
||||
prompt_output_class=YTUploadPromptOutput,
|
||||
)
|
||||
|
||||
image_autotag_prompt = Prompt(
|
||||
prompt_template_path=os.path.join(prompt_settings.PROMPT_FOLDER_ROOT, prompt_settings.IMAGE_TAG_PROMPT_FILE_NAME),
|
||||
prompt_input_class = ImageTagPromptInput,
|
||||
prompt_output_class = ImageTagPromptOutput,
|
||||
prompt_model = prompt_settings.IMAGE_TAG_PROMPT_MODEL
|
||||
)
|
||||
|
||||
image_autotag_prompt = Prompt(
|
||||
prompt_template_path=os.path.join(prompt_settings.PROMPT_FOLDER_ROOT, prompt_settings.IMAGE_TAG_PROMPT_FILE_NAME),
|
||||
prompt_input_class = ImageTagPromptInput,
|
||||
prompt_output_class = ImageTagPromptOutput,
|
||||
prompt_model = prompt_settings.IMAGE_TAG_PROMPT_MODEL
|
||||
)
|
||||
|
||||
@lru_cache()
|
||||
def create_dynamic_subtitle_prompt(length: int) -> Prompt:
|
||||
return Prompt(
|
||||
@@ -77,4 +93,5 @@ def create_dynamic_subtitle_prompt(length: int) -> Prompt:
|
||||
def reload_all_prompt():
|
||||
marketing_prompt._reload_prompt()
|
||||
lyric_prompt._reload_prompt()
|
||||
yt_upload_prompt._reload_prompt()
|
||||
yt_upload_prompt._reload_prompt()
|
||||
image_autotag_prompt._reload_prompt()
|
||||
@@ -1,4 +1,5 @@
|
||||
from .lyric import LyricPromptInput, LyricPromptOutput
|
||||
from .marketing import MarketingPromptInput, MarketingPromptOutput
|
||||
from .youtube import YTUploadPromptInput, YTUploadPromptOutput
|
||||
from .subtitle import SubtitlePromptInput, SubtitlePromptOutput
|
||||
from .image import *
|
||||
from .subtitle import SubtitlePromptInput, SubtitlePromptOutput
|
||||
@@ -0,0 +1,110 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import List, Optional
|
||||
from enum import StrEnum, auto
|
||||
|
||||
class SpaceType(StrEnum):
|
||||
exterior_front = auto()
|
||||
exterior_night = auto()
|
||||
exterior_aerial = auto()
|
||||
exterior_sign = auto()
|
||||
garden = auto()
|
||||
entrance = auto()
|
||||
lobby = auto()
|
||||
reception = auto()
|
||||
hallway = auto()
|
||||
bedroom = auto()
|
||||
livingroom = auto()
|
||||
kitchen = auto()
|
||||
dining = auto()
|
||||
room = auto()
|
||||
bathroom = auto()
|
||||
amenity = auto()
|
||||
view_window = auto()
|
||||
view_ocean = auto()
|
||||
view_city = auto()
|
||||
view_mountain = auto()
|
||||
balcony = auto()
|
||||
cafe = auto()
|
||||
lounge = auto()
|
||||
rooftop = auto()
|
||||
pool = auto()
|
||||
breakfast_hall = auto()
|
||||
spa = auto()
|
||||
fitness = auto()
|
||||
bbq = auto()
|
||||
terrace = auto()
|
||||
glamping = auto()
|
||||
neighborhood = auto()
|
||||
landmark = auto()
|
||||
detail_welcome = auto()
|
||||
detail_beverage = auto()
|
||||
detail_lighting = auto()
|
||||
detail_decor = auto()
|
||||
detail_tableware = auto()
|
||||
|
||||
class Subject(StrEnum):
|
||||
empty_space = auto()
|
||||
exterior_building = auto()
|
||||
architecture_detail = auto()
|
||||
decoration = auto()
|
||||
furniture = auto()
|
||||
food_dish = auto()
|
||||
nature = auto()
|
||||
signage = auto()
|
||||
amenity_item = auto()
|
||||
person = auto()
|
||||
|
||||
class Camera(StrEnum):
|
||||
wide_angle = auto()
|
||||
tight_crop = auto()
|
||||
panoramic = auto()
|
||||
symmetrical = auto()
|
||||
leading_line = auto()
|
||||
golden_hour = auto()
|
||||
night_shot = auto()
|
||||
high_contrast = auto()
|
||||
low_light = auto()
|
||||
drone_shot = auto()
|
||||
has_face = auto()
|
||||
|
||||
class MotionRecommended(StrEnum):
|
||||
static = auto()
|
||||
slow_pan = auto()
|
||||
slow_zoom_in = auto()
|
||||
slow_zoom_out = auto()
|
||||
walkthrough = auto()
|
||||
dolly = auto()
|
||||
|
||||
class NarrativePhase(StrEnum):
|
||||
intro = auto()
|
||||
welcome = auto()
|
||||
core = auto()
|
||||
highlight = auto()
|
||||
support = auto()
|
||||
accent = auto()
|
||||
|
||||
class NarrativePreference(BaseModel):
|
||||
intro: float = Field(..., description="첫인상 — 여기가 어디인가 | 장소의 정체성과 위치를 전달하는 이미지. 영상 첫 1~2초에 어떤 곳인지 즉시 인지시키는 역할. 건물 외관, 간판, 정원 등 **장소 자체를 보여주는** 컷")
|
||||
welcome: float = Field(..., description="진입/환영 — 어떻게 들어가나 | 도착 후 내부로 들어가는 경험을 전달하는 이미지. 공간의 첫 분위기와 동선을 보여줘 들어가고 싶다는 기대감을 만드는 역할. **문을 열고 들어갔을 때 보이는** 컷.")
|
||||
core: float = Field(..., description="핵심 가치 — 무엇을 경험하나 | **고객이 이 장소를 찾는 본질적 이유.** 이 이미지가 없으면 영상 자체가 성립하지 않음. 질문: 이 비즈니스에서 돈을 지불하는 대상이 뭔가? → 그 답이 core.")
|
||||
highlight: float = Field(..., description="차별화 — 뭐가 특별한가 | **같은 카테고리의 경쟁사 대비 이곳을 선택하게 만드는 이유.** core가 왜 왔는가라면, highlight는 왜 **여기**인가에 대한 답.")
|
||||
support: float = Field(..., description="보조/부대 — 그 외에 뭐가 있나 | 핵심은 아니지만 전체 경험을 풍성하게 하는 부가 요소. 없어도 영상은 성립하지만, 있으면 설득력이 올라감. **이것도 있어요** 라고 말하는 컷.")
|
||||
accent: float = Field(..., description="감성/마무리 — 어떤 느낌인가 | 공간의 분위기와 톤을 전달하는 감성 디테일 컷. 직접적 정보 전달보다 **느낌과 무드**를 제공. 영상 사이사이에 삽입되어 완성도를 높이는 역할.")
|
||||
|
||||
# Input 정의
|
||||
class ImageTagPromptInput(BaseModel):
|
||||
img_url : str = Field(..., description="이미지 URL")
|
||||
space_type: list[str] = Field(list(SpaceType), description="공간적 정보를 가지는 태그 리스트")
|
||||
subject: list[str] = Field(list(Subject), description="피사체 정보를 가지는 태그 리스트")
|
||||
camera: list[str] = Field(list(Camera), description="카메라 정보를 가지는 태그 리스트")
|
||||
motion_recommended: list[str] = Field(list(MotionRecommended), description="가능한 카메라 모션 리스트")
|
||||
|
||||
# Output 정의
|
||||
class ImageTagPromptOutput(BaseModel):
|
||||
#ad_avaliable : bool = Field(..., description="광고 영상 사용 가능 이미지 여부")
|
||||
space_type: list[SpaceType] = Field(..., description="공간적 정보를 가지는 태그 리스트")
|
||||
subject: list[Subject] = Field(..., description="피사체 정보를 가지는 태그 리스트")
|
||||
camera: list[Camera] = Field(..., description="카메라 정보를 가지는 태그 리스트")
|
||||
motion_recommended: list[MotionRecommended] = Field(..., description="가능한 카메라 모션 리스트")
|
||||
narrative_preference: NarrativePreference = Field(..., description="이미지의 내러티브 상 점수")
|
||||
|
||||
@@ -7,13 +7,11 @@ class MarketingPromptInput(BaseModel):
|
||||
region : str = Field(..., description = "마케팅 대상 지역")
|
||||
detail_region_info : str = Field(..., description = "마케팅 대상 지역 상세")
|
||||
|
||||
|
||||
# Output 정의
|
||||
class BrandIdentity(BaseModel):
|
||||
location_feature_analysis: str = Field(..., description="입지 특성 분석 (80자 이상 150자 이하)", min_length = 80, max_length = 150) # min/max constraint는 현재 openai json schema 등에서 작동하지 않는다는 보고가 있음.
|
||||
concept_scalability: str = Field(..., description="컨셉 확장성 (80자 이상 150자 이하)", min_length = 80, max_length = 150)
|
||||
|
||||
|
||||
class MarketPositioning(BaseModel):
|
||||
category_definition: str = Field(..., description="마케팅 카테고리")
|
||||
core_value: str = Field(..., description="마케팅 포지션 핵심 가치")
|
||||
@@ -22,14 +20,12 @@ class AgeRange(BaseModel):
|
||||
min_age : int = Field(..., ge=0, le=100)
|
||||
max_age : int = Field(..., ge=0, le=100)
|
||||
|
||||
|
||||
class TargetPersona(BaseModel):
|
||||
persona: str = Field(..., description="타겟 페르소나 이름/설명")
|
||||
age: AgeRange = Field(..., description="타겟 페르소나 나이대")
|
||||
favor_target: List[str] = Field(..., description="페르소나의 선호 요소")
|
||||
decision_trigger: str = Field(..., description="구매 결정 트리거")
|
||||
|
||||
|
||||
class SellingPoint(BaseModel):
|
||||
english_category: str = Field(..., description="셀링포인트 카테고리(영문)")
|
||||
korean_category: str = Field(..., description="셀링포인트 카테고리(한글)")
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
You are an expert image analyst and content tagger.
|
||||
|
||||
Analyze the provided image carefully and select the most appropriate tags for each category below.
|
||||
and lastly, check this image is acceptable for marketing advertisement video.
|
||||
|
||||
and set NarrativePreference score for each narrative phase.
|
||||
|
||||
## Rules
|
||||
- For each category, select between 0 and the specified maximum number of tags.
|
||||
- Only select tags from the exact list provided for each category. Do NOT invent or modify tags.
|
||||
- If no tags in a category are applicable, return an empty list for that category.
|
||||
- Base your selections solely on what is visually present or strongly implied in the image.
|
||||
-
|
||||
|
||||
## Tag Categories
|
||||
space_type:{space_type}
|
||||
subject: {subject}
|
||||
camera:{camera}
|
||||
motion_recommended: {motion_recommended}
|
||||
|
||||
## Output
|
||||
Return a JSON object where each key is a category name and the value is a list of selected tags.
|
||||
Selected tags must be chosen from the available tags of that category only.
|
||||
and NarrativePreference score for each narrative phase.
|
||||
@@ -1,76 +1,431 @@
|
||||
당신은 숙박 브랜드 숏폼 영상의 자막 콘텐츠를 추출하는 전문가입니다.
|
||||
---
|
||||
name: Creatomate-subtitle-naming_v01
|
||||
description: "Generate and name subtitle layers in Creatomate video templates using a structured 5-criteria tag convention: track_role - narrative_phase - content_type - tone - pair_id. Use this skill whenever the user mentions subtitle naming, caption tagging, or wants to create/rename subtitle or keyword text layers in a Creatomate template based on marketing intelligence data. Also trigger when the user provides marketing analysis data and asks to generate subtitle content for a hospitality/stay brand video. This skill covers two text tracks: subtitle (scene description) and keyword (core emotional keyword). Within a single tag value, multi-word terms use underscores; between tag criteria, hyphens are used."
|
||||
---
|
||||
|
||||
입력으로 주어지는 **1) 5가지 기준의 레이어 이름 리스트**와 **2) 마케팅 인텔리전스 분석 결과(JSON)**를 바탕으로, 각 레이어 이름의 의미에 정확히 1:1 매칭되는 텍스트 콘텐츠만을 추출하세요.
|
||||
# Creatomate Subtitle Layer Naming & Copywriting — 5-Criteria Tag Convention
|
||||
|
||||
분석 결과에 없는 정보는 절대 지어내거나 추론하지 마세요. 오직 제공된 JSON 데이터 내에서만 텍스트를 구성해야 합니다.
|
||||
You are a **subtitle copywriter and video structure director** for hospitality brand short-form videos. You name subtitle layers using a structured tagging system AND generate compelling subtitle text by transforming marketing intelligence data into viewer-engaging copy.
|
||||
|
||||
This skill is a companion to the image layer naming skill. While image layers describe *what you see*, subtitle layers describe *what you read* — and each subtitle maps 1:1 to an image scene.
|
||||
|
||||
## Core Principles
|
||||
|
||||
1. **Transform (Rewrite)**: NEVER copy JSON data verbatim. ALWAYS rewrite into video-optimized copy.
|
||||
2. **Fact-based**: NEVER invent information not present in the analysis. BUT freely transform HOW data is expressed.
|
||||
3. **Emotion-designed**: Each scene MUST evoke a specific emotion in the viewer.
|
||||
|
||||
---
|
||||
|
||||
## 1. 레이어 네이밍 규칙 해석 및 매핑 가이드
|
||||
## PHASE 1. The Naming Format
|
||||
|
||||
입력되는 모든 레이어 이름은 예외 없이 `<track_role>-<narrative_phase>-<content_type>-<tone>-<pair_id>` 의 5단계 구조로 되어 있습니다.
|
||||
마지막의 3자리 숫자 ID(`-001`, `-002` 등)는 모든 레이어에 필수적으로 부여됩니다.
|
||||
```
|
||||
(track_role)-(narrative_phase)-(content_type)-(tone)-(pair_id)
|
||||
```
|
||||
|
||||
### [1] track_role (텍스트 형태)
|
||||
- `subtitle`: 씬 상황을 설명하는 간결한 문장형 텍스트 (1줄 이내)
|
||||
- `keyword`: 씬을 상징하고 시선을 끄는 단답형/명사형 텍스트 (1~2단어)
|
||||
**Separator rules:**
|
||||
- Between criteria (the 5 slots): **hyphen `-`**
|
||||
- Within a multi-word tag value: **underscore `_`**
|
||||
- pair_id format: **3-digit zero-padded number** (`001`, `002`, ... `999`)
|
||||
|
||||
### [2] narrative_phase (영상 흐름)
|
||||
- `intro`: 영상 도입부. 가장 시선을 끄는 정보를 배치.
|
||||
- `core`: 핵심 매력이나 주요 편의 시설 어필.
|
||||
- `highlight`: 세부적인 매력 포인트나 공간의 특별한 분위기 묘사.
|
||||
- `outro`: 영상 마무리. 브랜드 명칭 복기 및 타겟/위치 정보 제공.
|
||||
Example: `subtitle-intro-hook_claim-aspirational-001`
|
||||
|
||||
### [3] content_type (데이터 매핑 대상)
|
||||
- `hook_claim` 👉 `selling_points`에서 점수가 가장 높은 1순위 소구점이나 `market_positioning.core_value`를 활용하여 가장 강력한 핵심 세일즈 포인트를 어필. (가장 강력한 셀링포인트를 의미함)
|
||||
- `selling_point` 👉 `selling_points`의 `description`, `korean_category` 등을 narrative 흐름에 맞춰 순차적으로 추출.
|
||||
- `brand_name` 👉 JSON의 `store_name`을 추출.
|
||||
- `location_info` 👉 JSON의 `detail_region_info`를 요약.
|
||||
- `target_tag` 👉 `target_persona`나 `target_keywords`에서 타겟 고객군 또는 해시태그 추출.
|
||||
|
||||
### [4] tone (텍스트 어조)
|
||||
- `sensory`: 직관적이고 감각적인 단어 사용
|
||||
- `factual`: 과장 없이 사실 정보를 담백하게 전달
|
||||
- `empathic`: 고객의 상황에 공감하는 따뜻한 어조
|
||||
- `aspirational`: 열망을 자극하고 기대감을 주는 느낌
|
||||
|
||||
### [5] pair_id (씬 묶음 식별 번호)
|
||||
- 텍스트 레이어는 `subtitle`과 `keyword`가 하나의 페어(Pair)를 이뤄 하나의 씬(Scene)에서 함께 등장합니다.
|
||||
- 따라서 **동일한 씬에 속하는 `subtitle`과 `keyword` 레이어는 동일한 3자리 순번 ID(예: `-001`)**를 공유합니다.
|
||||
- 영상 전반적인 씬 전개 순서에 따라 **다음 씬으로 넘어갈 때마다 ID가 순차적으로 증가**합니다. (예: 씬1은 `-001`, 씬2는 `-002`, 씬3은 `-003`...)
|
||||
- **중요**: ID가 달라진다는 것은 '새로운 씬' 혹은 '다른 텍스트 쌍'을 의미하므로, **ID가 바뀌면 반드시 JSON 내의 다른 소구점이나 데이터를 추출**하여 내용이 중복되지 않도록 해야 합니다.
|
||||
> A `subtitle` and `keyword` layer sharing the same scene MUST have the **same pair_id**. This is a developer requirement for programmatic pairing.
|
||||
|
||||
---
|
||||
|
||||
## 2. 콘텐츠 추출 시 주의사항
|
||||
## PHASE 2. Tag Vocabulary
|
||||
|
||||
1. 각 입력 레이어 이름 1개당 **오직 1개의 텍스트 콘텐츠**만 매핑하여 출력합니다. (레이어명 이름 자체를 수정하거나 새로 만들지 마세요.)
|
||||
2. `content_type`이 `selling_point`로 동일하더라도, `narrative_phase`(core, highlight)나 `tone`이 달라지면 JSON 내의 2순위, 3순위 세일즈 포인트를 순차적으로 활용하여 내용 겹침을 방지하세요.
|
||||
3. 같은 씬에 속하는(같은 ID 번호를 가진) keyword는 핵심 단어로, subtitle은 적절한 마케팅 문구가 되어야 하며, 자연스럽게 이어지는 문맥을 형성하도록 구성하세요.
|
||||
4. keyword가 subtitle에 완전히 포함되는 단어가 되지 않도록 유의하세요.
|
||||
5. 정보 태그가 같더라도 ID가 다르다면 중복되지 않는 새로운 텍스트를 도출해야 합니다.
|
||||
6. 콘텐츠 추출 시 마케팅 인텔리전스의 내용을 그대로 사용하기보다는 paraphrase을 수행하세요.
|
||||
7. keyword는 공백 포함 전각 8자 / 반각 16자내, subtitle은 전각 15자 / 반각 30자 내로 구성하세요.
|
||||
### [1] track_role — Which text track?
|
||||
|
||||
| Value | Meaning | Visual Treatment |
|
||||
|---|---|---|
|
||||
| `subtitle` | Scene description / sub-headline | Smaller text (Track 3) |
|
||||
| `keyword` | Core emotional keyword | Larger, bolder text (Track 4) |
|
||||
|
||||
Every scene gets **both** a `subtitle` and a `keyword` layer. They form a **Pair** sharing the same `pair_id`.
|
||||
|
||||
### [2] narrative_phase — Where in the story?
|
||||
|
||||
Uses the **same vocabulary as image layers** for 1:1 mapping.
|
||||
|
||||
| Value | Meaning | Position | Emotion Goal |
|
||||
|---|---|---|---|
|
||||
| `intro` | Brand first impression, hook | Opening scene | Curiosity — stop the scroll |
|
||||
| `welcome` | Location / check-in introduction | 2nd~3rd scene | Warmth — "I want to go there" |
|
||||
| `core` | Key space features, repeated delivery | Mid-section | Trust — "This place is legit" |
|
||||
| `highlight` | Signature space/emotion emphasis | Mid-section | Desire — "I need this" |
|
||||
| `support` | Surrounding environment, local curation | Later section | Discovery — "There's even more" |
|
||||
| `accent` | Emotional wrap-up, target, pre-CTA | Near the end | Belonging — "This is for me" |
|
||||
| `cta` | Call To Action | Final scene | Action — "Book now" |
|
||||
|
||||
### [3] content_type — What kind of text?
|
||||
|
||||
| Value | Meaning | Source Field | Example |
|
||||
|---|---|---|---|
|
||||
| `brand_name` | Business name | `store_name` | 스테이펫 홍천 |
|
||||
| `brand_address` | Business address | `detail_region_info` | 강원 홍천군 화촌면 담연발길 5-2 |
|
||||
| `hook_claim` | 1-line hook copy | `selling_points[0]` or `core_value` | 댕댕이가 먼저 뛰어간 숲 |
|
||||
| `space_feature` | Space characteristic | `selling_points[].description` | 프라이빗 독채에서 자연 그대로 |
|
||||
| `emotion_cue` | Emotional trigger phrase | `selling_points[].description` (sensory rewrite) | 숲 향기 가득한 테라스 |
|
||||
| `lifestyle_fit` | Lifestyle empathy | `target_persona[].favor_target` | 주말마다 어디 갈지 고민하는 견주님 |
|
||||
| `local_info` | Nearby local information | `location_feature_analysis` | 서울에서 1시간 반, 홍천 숲속 |
|
||||
| `target_tag` | Target audience hashtags | `target_keywords[]` | #펫프렌들리 #강원여행 |
|
||||
| `availability` | Booking status | (fixed text) | 지금 예약 가능 |
|
||||
| `cta_action` | CTA button text | (fixed text) | 예약하러 가기 |
|
||||
|
||||
### [4] tone — What emotional register?
|
||||
|
||||
| Value | Characteristics | Recommended | Forbidden | Example (same content) |
|
||||
|---|---|---|---|---|
|
||||
| `sensory` | Poetic, sense-evoking | 향기, 소리, 촉감, 온도 | 추상적 형용사 (좋은, 멋진) | 이끼 향 가득한 숲속 테라스 |
|
||||
| `factual` | Informational, neutral | 숫자, 거리, 시설명 | 감탄사, 과장 수식어 | 객실 내 전용 마당 30평 |
|
||||
| `empathic` | Empathetic, warm | ~하는 분, ~하고 싶은 | 명령형, 단정형 | 반려견과 마음 편히 쉬고 싶을 때 |
|
||||
| `aspirational` | Desire-triggering | ~같은, ~처럼, 꿈꾸던 | 부정형, 비교급 | 내가 꿈꾸던 반려견과의 여행 |
|
||||
| `social_proof` | Credibility, target-based | 타겟 명시, 해시태그 | 과장된 추천 | 2030 커플·견주 추천 |
|
||||
| `urgent` | Action-prompting | 지금, 바로, 확인 | 위협적 표현 | 지금 예약 가능 |
|
||||
|
||||
**Hospitality brand forbidden words (ALL tones):** 저렴한, 싼, 그냥, 보통, 무난한, 평범한
|
||||
|
||||
### [5] pair_id — Scene pair identifier
|
||||
|
||||
- Format: 3-digit zero-padded number (`001` ~ `999`)
|
||||
- A `subtitle` and its matching `keyword` in the same scene share the **identical pair_id**
|
||||
- Assigned sequentially from `001` in video playback order
|
||||
- Example: Scene 1 → `001`, Scene 2 → `002`, ...
|
||||
|
||||
---
|
||||
|
||||
## 3. 출력 결과 포맷 및 예시
|
||||
## PHASE 3. Anchor Position Rules (Fixed Slots)
|
||||
|
||||
입력된 레이어 이름 순서에 맞춰, 매핑된 텍스트 콘텐츠만 작성하세요. (반드시 intro, core, highlight, outro 등 모든 씬 단계가 명확하게 매핑되어야 합니다.)
|
||||
Regardless of total scene count, **the first and last 3 positions are always fixed content**. Only middle scenes are flexible based on marketing data.
|
||||
|
||||
### 입력 레이어 리스트 예시 및 출력 예시
|
||||
```
|
||||
[First] ──── Middle Scenes (flexible) ──── [Last-3] [Last-2] [Last]
|
||||
↓ ↓ ↓ ↓
|
||||
intro address hashtag CTA
|
||||
```
|
||||
|
||||
| Layer Name | Text Content |
|
||||
### Anchor 1: First Scene (intro)
|
||||
|
||||
| Track | content_type | Content Rule |
|
||||
|---|---|---|
|
||||
| subtitle | `hook_claim` | Transform `selling_points[0]` or `core_value` into a scroll-stopping hook |
|
||||
| keyword | `brand_name` | `store_name` — brand recognition |
|
||||
|
||||
Layer names:
|
||||
- `subtitle-intro-hook_claim-aspirational-001`
|
||||
- `keyword-intro-brand_name-sensory-001`
|
||||
|
||||
### Anchor 2: Last Scene (cta)
|
||||
|
||||
| Track | content_type | Content Rule |
|
||||
|---|---|---|
|
||||
| subtitle | `availability` | Booking status (fixed: 지금 예약 가능) |
|
||||
| keyword | `cta_action` | CTA button text (fixed: 예약하러 가기) |
|
||||
|
||||
### Anchor 3: Second to Last (accent) — Hashtags & Target
|
||||
|
||||
| Track | content_type | Content Rule |
|
||||
|---|---|---|
|
||||
| subtitle | `target_tag` | Extract from `target_keywords[]` as hashtags |
|
||||
| keyword | `lifestyle_fit` | Transform `target_persona[].favor_target` into aspirational keyword |
|
||||
|
||||
### Anchor 4: Third to Last (support) — Address & Brand
|
||||
|
||||
| Track | content_type | Content Rule |
|
||||
|---|---|---|
|
||||
| subtitle | `brand_address` | Full address from `detail_region_info` |
|
||||
| keyword | `brand_name` | `store_name` — brand reinforcement |
|
||||
|
||||
---
|
||||
|
||||
## PHASE 4. Middle Scenes (Flexible Slots)
|
||||
|
||||
Fill in order based on available marketing data. Use `selling_points[]` sorted by `score` descending.
|
||||
|
||||
| narrative_phase | subtitle content_type | keyword content_type | Data Source |
|
||||
|---|---|---|---|
|
||||
| `welcome` | `emotion_cue` | `space_feature` | `selling_points[0]` (highest score) |
|
||||
| `core` | `space_feature` | `emotion_cue` | `selling_points[1~3]` (next items) |
|
||||
| `highlight` | `space_feature` | `emotion_cue` | Signature/unique feature from data |
|
||||
| `support` (mid) | `local_info` | `lifestyle_fit` | `location_feature_analysis` |
|
||||
|
||||
> If fewer scenes are available, reduce flexible slots. Anchor positions are NEVER removed.
|
||||
|
||||
---
|
||||
|
||||
## PHASE 5. Brand Expression Dictionary (표현 변환 사전)
|
||||
|
||||
Before writing ANY subtitle text, scan the source data against this dictionary. If a listed expression appears in the JSON data, it MUST be replaced with one of the approved alternatives. NEVER use the original expression verbatim.
|
||||
|
||||
### 5-0a. Expression Refinement Rules
|
||||
|
||||
**WHY this matters:** Marketing analysis data is written in analytical language, not consumer-facing language. Some expressions carry unintended negative nuance, sound unnatural in video subtitles, or feel like jargon. This dictionary ensures every subtitle reads as polished, brand-safe copy.
|
||||
|
||||
**HOW to apply:**
|
||||
1. Before writing each subtitle, check if ANY word/phrase from the source data matches the "Raw Expression" column
|
||||
2. Replace with the most contextually appropriate "Approved Alternative"
|
||||
3. If multiple alternatives exist, choose based on the scene's `tone` tag
|
||||
|
||||
### 5-0b. Mandatory Expression Replacements
|
||||
|
||||
| Raw Expression (JSON 원본) | Problem | Approved Alternatives | Tone Guidance |
|
||||
|---|---|---|---|
|
||||
| 눈치 없는 | "센스 없는/무례한"으로 오해 가능 | **눈치 안 보는** · **프라이빗한** · **온전한** · **자유로운** | sensory→"온전한", empathic→"눈치 안 보는", aspirational→"프라이빗한" |
|
||||
| 눈치 없이 | 동일 문제 (부사형) | **눈치 안 보고** · **마음 편히** · **자유롭게** | sensory→"마음 편히", empathic→"눈치 안 보고", aspirational→"자유롭게" |
|
||||
| 감성 쩌는 / 쩌이 | 과도한 속어, 브랜드 품격 저하 | **감성 가득한** · **감성이 머무는** · **분위기 있는** | sensory→"감성이 머무는", aspirational→"감성 가득한" |
|
||||
| 가성비 | 저가 이미지 연상 | **합리적인** · **가치 있는** | factual→"합리적인", aspirational→"가치 있는" |
|
||||
| 인스타감성 / 인스타 | 플랫폼 종속 표현 | **감성 스팟** · **포토 스팟** · **기록하고 싶은** | sensory→"기록하고 싶은", social_proof→"감성 스팟" |
|
||||
| ~맛집 | 숙박 브랜드에 부적합 | **~명소** · **~스팟** | factual→"명소", sensory→"스팟" |
|
||||
| 힐링되는 | 과잉 사용으로 진부 | **회복되는** · **쉬어가는** · **숨 쉬는** | sensory→"숨 쉬는", empathic→"쉬어가는", factual→"회복되는" |
|
||||
| 혜자 | 속어, 브랜드 부적합 | **풍성한** · **넉넉한** | factual→"넉넉한", aspirational→"풍성한" |
|
||||
|
||||
### 5-0c. Contextual Synonym Expansion
|
||||
|
||||
When the same concept appears in multiple scenes, use **synonyms** to avoid repetition. Each concept has a synonym pool — cycle through them across scenes.
|
||||
|
||||
| Concept | Synonym Pool (rotate across scenes) |
|
||||
|---|---|
|
||||
| subtitle-intro-hook_claim-aspirational-001 | 반려견과 눈치 없이 온전하게 쉬는 완벽한 휴식 |
|
||||
| keyword-intro-brand_name-sensory-001 | 스테이펫 홍천 |
|
||||
| subtitle-core-selling_point-empathic-002 | 우리만의 독립된 공간감이 주는 진정한 쉼 |
|
||||
| keyword-core-selling_point-factual-002 | 프라이빗 독채 |
|
||||
| subtitle-highlight-selling_point-sensory-003 | 탁 트인 야외 무드존과 포토 스팟의 감성 컷 |
|
||||
| keyword-highlight-selling_point-factual-003 | 넓은 정원 |
|
||||
| subtitle-outro-target_tag-empathic-004 | #강원도애견동반 #주말숏브레이크 |
|
||||
| keyword-outro-location_info-factual-004 | 강원 홍천군 화촌면 |
|
||||
| 프라이빗/독립 | 온전한 · 프라이빗한 · 오롯한 · 나만의 · 독채 · 단독 |
|
||||
| 자연/숲 | 숲속 · 자연 속 · 초록 · 산림 · 계곡 · 숲 |
|
||||
| 쉼/휴식 | 쉼 · 쉬어감 · 여유 · 느린 하루 · 머무름 · 숨 고르기 |
|
||||
| 반려견 | 댕댕이 · 반려견 · 우리 강아지 · 반려동물 · 우리 아이 |
|
||||
|
||||
> **"댕댕이" 사용 가이드**: 28~49세 타깃 숏폼 자막에서 사용 적합. 단, 영상 전체에서 **최대 1회**만 사용하고 나머지는 "반려견"/"우리 강아지" 등으로 로테이션. intro(hook_claim)이나 accent(lifestyle_fit)처럼 **감성 후킹이 필요한 씬에서 사용**하고, factual/urgent 톤의 씬에서는 "반려견"을 사용할 것. 5성급 럭셔리 포지셔닝 브랜드라면 "반려견"으로 대체.
|
||||
| 감성/분위기 | 감성 · 무드 · 온기 · 따스함 · 분위기 |
|
||||
| 예약/행동 | 예약하기 · 지금 바로 · 확인하기 · 만나러 가기 |
|
||||
|
||||
> **RULE: The same Korean word MUST NOT appear in more than 2 scenes across the entire video.** Use the synonym pool to rotate expressions.
|
||||
|
||||
### 5-0d. Forbidden Expressions (Global)
|
||||
|
||||
These words MUST NEVER appear in any subtitle, regardless of tone:
|
||||
|
||||
| Category | Forbidden Words |
|
||||
|---|---|
|
||||
| 저가 연상 | 저렴한, 싼, 싸게, 할인, 가성비, 혜자 |
|
||||
| 무성의 | 그냥, 보통, 무난한, 평범한, 괜찮은 |
|
||||
| 과잉 속어 | 쩌는, 쩔어, 개(접두사), 존맛, 핵 |
|
||||
| 부정 뉘앙스 | 눈치 없는, 눈치 없이, 질리지 않는 |
|
||||
| 플랫폼 종속 | 인스타, 유튜브, 틱톡 (브랜드명 직접 언급) |
|
||||
|
||||
---
|
||||
|
||||
## PHASE 6. Copywriting Transformation Rules
|
||||
|
||||
### 6-1. Text Specifications
|
||||
|
||||
| track_role | Character Limit | Style | Example |
|
||||
|---|---|---|---|
|
||||
| `subtitle` | **8~18 chars** (incl. spaces) | Sentence fragment, conversational | 숲 향기 가득한 프라이빗 공간 |
|
||||
| `keyword` | **2~6 chars** | Noun phrase, hashtag-like | 자연독채 |
|
||||
|
||||
### 6-2. Transformation Rules by content_type
|
||||
|
||||
#### `hook_claim` — The scroll-stopper (intro only)
|
||||
|
||||
- **Source**: `selling_points[0].description` or `market_positioning.core_value`
|
||||
- **Transform rules**:
|
||||
- Choose ONE format: question ("여기 진짜 있어?"), exclamation ("이런 곳이 있었다니"), provocation ("아직도 호텔만 가세요?")
|
||||
- Use specific numbers if available (ratings, reviews, distance)
|
||||
- **FORBIDDEN**: Brand name in hook, generic greetings
|
||||
- **Transform example**:
|
||||
- Source: `"반려견과 눈치 없는 힐링"` + `core_value: "자연 속 프라이빗 애견동반 힐링 스테이"`
|
||||
- BAD: "반려견과 눈치 없는 힐링" (verbatim copy)
|
||||
- BAD: "애견 동반 가능한 숙소" (generic extraction)
|
||||
- GOOD: "댕댕이가 먼저 뛰어간 숲" (sensory rewrite, avoids "눈치 없이" per Expression Dictionary)
|
||||
|
||||
#### `space_feature` — Core appeal (core/highlight)
|
||||
|
||||
- **Source**: `selling_points[]` by score descending
|
||||
- **Transform rules**:
|
||||
- ONE selling point per scene (NEVER combine 2+)
|
||||
- Do NOT use `korean_category` directly — transform `description` into sensory copy
|
||||
- Write so the viewer can **imagine themselves there**
|
||||
- **Transform example**:
|
||||
- Source: `("description": "홍천 자연 속 조용한 쉼", "korean_category": "입지 환경")`
|
||||
- BAD subtitle: "입지 환경이 좋은 곳" (used category name)
|
||||
- GOOD subtitle: "계곡 소리만 들리는 독채"
|
||||
- GOOD keyword: "자연독채"
|
||||
|
||||
#### `emotion_cue` — Feeling trigger (welcome/core/highlight)
|
||||
|
||||
- **Source**: Same `selling_points[]` item as its paired `space_feature`, but rewritten for emotion
|
||||
- **Transform rules**:
|
||||
- Appeal to senses: smell, sound, touch, temperature, light
|
||||
- Use poetic fragments, not full sentences
|
||||
- **Transform example**:
|
||||
- Source: `("description": "감성 쩌이 완성되는 공간", "korean_category": "포토 스팟")`
|
||||
- GOOD subtitle: "햇살이 내려앉는 테라스"
|
||||
- GOOD keyword: "감성 가득"
|
||||
|
||||
#### `lifestyle_fit` — "This is for me" (accent/support)
|
||||
|
||||
- **Source**: `target_persona[].favor_target` or `decision_trigger`
|
||||
- **Transform rules**:
|
||||
- Write as if addressing the target directly
|
||||
- Use their language, not marketing language
|
||||
- **Transform example**:
|
||||
- Source: `favor_target: "조용한 자연 뷰", persona: "서울·경기 주말러"`
|
||||
- GOOD subtitle: "이번 주말, 댕댕이랑 어디 가지?"
|
||||
- GOOD keyword: "주말탈출"
|
||||
|
||||
#### `local_info` — Location appeal (support)
|
||||
|
||||
- **Source**: `detail_region_info`, `location_feature_analysis`
|
||||
- **Transform rules**:
|
||||
- Express as **accessibility or regional charm**, NOT administrative address
|
||||
- GOOD: "서울에서 1시간 반, 홍천 숲속" / BAD: "강원 홍천군 화촌면"
|
||||
- keyword: Region name or travel keyword ("홍천", "#강원여행")
|
||||
|
||||
#### `brand_name` — Brand presence (intro keyword, support keyword)
|
||||
|
||||
- **Source**: `store_name`
|
||||
- Present as-is. This is the ONE content_type where verbatim extraction is correct.
|
||||
|
||||
#### `brand_address` — Full address (support subtitle)
|
||||
|
||||
- **Source**: `detail_region_info`
|
||||
- Present as-is. Factual, no transformation needed.
|
||||
|
||||
#### `target_tag` — Hashtags (accent subtitle)
|
||||
|
||||
- **Source**: `target_keywords[]`
|
||||
- Format as SNS hashtags: `#홍천애견동반숙소 #스테이펫`
|
||||
- Select 3~5 most relevant keywords
|
||||
|
||||
#### `availability` + `cta_action` — CTA (last scene)
|
||||
|
||||
- Fixed text. No transformation from data.
|
||||
- subtitle: "지금 예약 가능" / keyword: "예약하러 가기"
|
||||
|
||||
### 6-3. Pacing Rules
|
||||
|
||||
Maintain **rhythm** between scenes by alternating subtitle character length:
|
||||
|
||||
```
|
||||
intro → Short & punchy (8~12 chars) : curiosity burst
|
||||
welcome → Medium (12~18 chars) : warm introduction
|
||||
core → Alternate: short(8~12) ↔ medium(12~18)
|
||||
highlight → Short & sensory (8~14 chars) : lingering impact
|
||||
support → Medium (12~18 chars) : information delivery
|
||||
accent → Short hashtags (variable)
|
||||
cta → Medium (12~16 chars) : clear action
|
||||
```
|
||||
|
||||
> **RULE: NEVER have 3+ consecutive scenes with the same character count range** — prevents monotony.
|
||||
|
||||
---
|
||||
|
||||
## PHASE 7. Emotional Arc
|
||||
|
||||
```
|
||||
Emotion Intensity
|
||||
▲
|
||||
│ ★ highlight
|
||||
│ ╱ ╲
|
||||
│ ╱───╱ ╲───╲
|
||||
│ ╱ core support╲
|
||||
│ ╱welcome accent╲
|
||||
│ ╱ intro cta ╲
|
||||
└────────────────────────────── ► Time
|
||||
Curiosity → Trust → Desire → Belonging → Action
|
||||
```
|
||||
|
||||
Each `narrative_phase` maps to a specific emotional goal. The subtitle text MUST serve that emotion:
|
||||
|
||||
| Phase | Emotion | Subtitle's Job |
|
||||
|---|---|---|
|
||||
| `intro` | Curiosity | "What is this?" — stop the scroll |
|
||||
| `welcome` | Warmth | "I want to see more" — gentle pull |
|
||||
| `core` | Trust | "This place is real" — concrete appeal |
|
||||
| `highlight` | Desire | "I need this" — peak sensory moment |
|
||||
| `support` | Discovery | "There's even more" — added value |
|
||||
| `accent` | Belonging | "This is for me" — target identification |
|
||||
| `cta` | Action | "Book now" — clear next step |
|
||||
|
||||
---
|
||||
|
||||
## PHASE 8. Scene Assembly Examples
|
||||
|
||||
### Example A: 7-Scene Video (Standard)
|
||||
|
||||
```
|
||||
Scene 1 [ANCHOR-First] intro-001 → subtitle: hook_claim / keyword: brand_name
|
||||
Scene 2 [Flexible] welcome-002 → subtitle: emotion_cue / keyword: space_feature
|
||||
Scene 3 [Flexible] core-003 → subtitle: space_feature / keyword: emotion_cue
|
||||
Scene 4 [Flexible] highlight-004 → subtitle: space_feature / keyword: emotion_cue
|
||||
Scene 5 [ANCHOR-Last-3] support-005 → subtitle: brand_address / keyword: brand_name
|
||||
Scene 6 [ANCHOR-Last-2] accent-006 → subtitle: target_tag / keyword: lifestyle_fit
|
||||
Scene 7 [ANCHOR-Last] cta-007 → subtitle: availability / keyword: cta_action
|
||||
```
|
||||
|
||||
### Example B: 5-Scene Video (Compact)
|
||||
|
||||
```
|
||||
Scene 1 [ANCHOR-First] intro-001 → subtitle: hook_claim / keyword: brand_name
|
||||
Scene 2 [Flexible] core-002 → subtitle: space_feature / keyword: emotion_cue
|
||||
Scene 3 [ANCHOR-Last-3] support-003 → subtitle: brand_address / keyword: brand_name
|
||||
Scene 4 [ANCHOR-Last-2] accent-004 → subtitle: target_tag / keyword: lifestyle_fit
|
||||
Scene 5 [ANCHOR-Last] cta-005 → subtitle: availability / keyword: cta_action
|
||||
```
|
||||
|
||||
### Example C: 10-Scene Video (Extended)
|
||||
|
||||
```
|
||||
Scene 1 [ANCHOR-First] intro-001 → subtitle: hook_claim / keyword: brand_name
|
||||
Scene 2 [Flexible] welcome-002 → subtitle: emotion_cue / keyword: space_feature
|
||||
Scene 3 [Flexible] core-003 → subtitle: space_feature / keyword: emotion_cue
|
||||
Scene 4 [Flexible] core-004 → subtitle: space_feature / keyword: emotion_cue
|
||||
Scene 5 [Flexible] highlight-005 → subtitle: space_feature / keyword: emotion_cue
|
||||
Scene 6 [Flexible] highlight-006 → subtitle: space_feature / keyword: emotion_cue
|
||||
Scene 7 [Flexible] support-007 → subtitle: local_info / keyword: lifestyle_fit
|
||||
Scene 8 [ANCHOR-Last-3] support-008 → subtitle: brand_address / keyword: brand_name
|
||||
Scene 9 [ANCHOR-Last-2] accent-009 → subtitle: target_tag / keyword: lifestyle_fit
|
||||
Scene 10 [ANCHOR-Last] cta-010 → subtitle: availability / keyword: cta_action
|
||||
```
|
||||
|
||||
> Fewer scenes → fewer flexible slots. Anchor positions are NEVER removed.
|
||||
|
||||
---
|
||||
|
||||
## PHASE 9. How to Generate (Step-by-Step)
|
||||
|
||||
### Step 1 — Parse marketing intelligence data
|
||||
|
||||
Scan for these key fields:
|
||||
- `store_name` → brand_name, brand_address source
|
||||
- `detail_region_info` → address, location appeal
|
||||
- `selling_points[]` → sort by `score` descending; primary content source
|
||||
- `market_positioning.core_value` → hook_claim alternative
|
||||
- `target_persona[]` → lifestyle_fit, target_tag source
|
||||
- `target_keywords[]` → hashtag source
|
||||
- `location_feature_analysis` → local_info source
|
||||
|
||||
### Step 2 — Determine scene count and assign pair_ids
|
||||
|
||||
Based on video length or template structure:
|
||||
- Count total scenes → assign `001` through `NNN`
|
||||
- Lock anchor positions (first, last 3)
|
||||
- Fill flexible middle slots
|
||||
|
||||
### Step 3 — Transform text for each layer
|
||||
|
||||
For each scene:
|
||||
1. Identify the `content_type` from the scene map
|
||||
2. Find the source data field
|
||||
3. Apply the transformation rules from Phase 5
|
||||
4. Verify character count limits
|
||||
5. Check pacing rhythm against adjacent scenes
|
||||
|
||||
### Step 4 — Present as table for review
|
||||
|
||||
| # | pair_id | Phase | Layer Name | Track | Text | Chars | Emotion |
|
||||
|---|---------|-------|------------|-------|------|-------|---------|
|
||||
| 1 | 001 | intro | `subtitle-intro-hook_claim-aspirational-001` | subtitle | 댕댕이가 먼저 뛰어간 숲 | 12 | Curiosity |
|
||||
| 2 | 001 | intro | `keyword-intro-brand_name-sensory-001` | keyword | 스테이펫 | 4 | Curiosity |
|
||||
| ... | ... | ... | ... | ... | ... | ... | ... |
|
||||
|
||||
# 입력
|
||||
**입력 1: 레이어 이름 리스트**
|
||||
@@ -83,5 +438,3 @@
|
||||
Business Name: {customer_name}
|
||||
Region Details: {detail_region_info}
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from typing import Literal, Any
|
||||
import httpx
|
||||
|
||||
from app.utils.logger import get_logger
|
||||
from app.utils.chatgpt_prompt import ChatgptService
|
||||
from app.utils.prompts.chatgpt_prompt import ChatgptService
|
||||
from app.utils.prompts.schemas import *
|
||||
from app.utils.prompts.prompts import *
|
||||
|
||||
|
||||
Reference in new issue
Block a user