범용 프롬프트 적용
This commit is contained in:
1 parent
8415e1c3a7
commit
04d8614919
18 files changed
+140
-85
No files matched your search
+14
-1
@@ -30,6 +30,7 @@ response = await creatomate.make_creatomate_call(template_id, modifications)
|
||||
"""
|
||||
|
||||
import copy
|
||||
import random
|
||||
import time
|
||||
from enum import StrEnum
|
||||
from typing import Literal
|
||||
@@ -470,10 +471,20 @@ class CreatomateService:
|
||||
match template_type:
|
||||
case "image":
|
||||
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:
|
||||
# 이미지 부족(슬롯 수 > 이미지 수): 재사용이 불가피하므로 슬롯에 가장 적합한 이미지(최고점) 선택
|
||||
maximum_idx = image_score_list.index(max(image_score_list))
|
||||
selected = taged_image_list[maximum_idx]
|
||||
else:
|
||||
# 이미지 충분(슬롯 수 <= 이미지 수): 상위 3장 중 점수 비례 확률로 선택해 영상 다양화
|
||||
# 동일 요청을 반복할 때 매번 같은 영상이 생성되는 문제 방지
|
||||
sorted_indices = sorted(range(len(image_score_list)), key=lambda i: image_score_list[i], reverse=True)
|
||||
top_indices = sorted_indices[:min(3, len(sorted_indices))]
|
||||
weights = [image_score_list[i] for i in top_indices]
|
||||
if sum(weights) > 0:
|
||||
maximum_idx = random.choices(top_indices, weights=weights, k=1)[0]
|
||||
else:
|
||||
maximum_idx = random.choice(top_indices)
|
||||
selected = taged_image_list.pop(maximum_idx)
|
||||
image_name = selected["image_url"]
|
||||
modifications[template_component_name] =image_name
|
||||
@@ -679,6 +690,8 @@ class CreatomateService:
|
||||
"""
|
||||
url = f"{self.BASE_URL}/v2/renders"
|
||||
|
||||
source["frame_rate"] = 30
|
||||
|
||||
last_error: Exception | None = None
|
||||
|
||||
for attempt in range(recovery_settings.CREATOMATE_MAX_RETRIES + 1):
|
||||
|
||||
Reference in new issue
Block a user