자막생성 재시도 로직 추가
This commit is contained in:
1 parent
5f3e8ec341
commit
73e5da3f08
3 files changed
+87
-51
No files matched your search
+20
-1
@@ -10,11 +10,20 @@ from app.utils.prompts.chatgpt_prompt import ChatgptService
|
||||
from app.utils.prompts.schemas import *
|
||||
from app.utils.prompts.prompts import *
|
||||
|
||||
logger = get_logger("subtitle")
|
||||
|
||||
class SubtitleContentsGenerator():
|
||||
def __init__(self):
|
||||
self.chatgpt_service = ChatgptService()
|
||||
self.chatgpt_service = ChatgptService(timeout=60.0)
|
||||
|
||||
async def generate_subtitle_contents(self, marketing_intelligence : dict[str, Any], pitching_label_list : list[Any], customer_name : str, detail_region_info : str) -> SubtitlePromptOutput:
|
||||
start = time.perf_counter()
|
||||
logger.info(
|
||||
f"[SubtitleContentsGenerator] START - customer: {customer_name}, "
|
||||
f"pitching_count: {len(pitching_label_list)}, "
|
||||
f"labels: {pitching_label_list}"
|
||||
)
|
||||
|
||||
dynamic_subtitle_prompt = create_dynamic_subtitle_prompt(len(pitching_label_list))
|
||||
pitching_label_string = "\n".join(pitching_label_list)
|
||||
marketing_intel_string = json.dumps(marketing_intelligence, ensure_ascii=False)
|
||||
@@ -24,7 +33,17 @@ class SubtitleContentsGenerator():
|
||||
"customer_name" : customer_name,
|
||||
"detail_region_info" : detail_region_info,
|
||||
}
|
||||
|
||||
logger.info(
|
||||
f"[SubtitleContentsGenerator] GPT 호출 시작 - model: {dynamic_subtitle_prompt.prompt_model}"
|
||||
)
|
||||
output_data = await self.chatgpt_service.generate_structured_output(dynamic_subtitle_prompt, input_data)
|
||||
|
||||
elapsed = (time.perf_counter() - start) * 1000
|
||||
logger.info(
|
||||
f"[SubtitleContentsGenerator] DONE - 소요시간: {elapsed:.0f}ms, "
|
||||
f"결과: {[r.pitching_tag for r in output_data.pitching_results]}"
|
||||
)
|
||||
return output_data
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user