feat(v3): PR 3 — prompt_layer package (base, video_prompt, search_query, visual_vocabulary)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
sinmb79
2026-03-29 11:43:15 +09:00
parent 4484fd1cfc
commit 33b0bbd5ee
5 changed files with 369 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
"""
bots/prompt_layer/search_query.py
Compose stock video/image search queries from Korean concepts.
"""
from .base import BaseComposer, ComposedPrompt
from .visual_vocabulary import CONCEPT_TO_VISUAL, VISUAL_STYLE_MODIFIERS
import re
class StockSearchQueryComposer(BaseComposer):
"""
Korean concept -> English visual search terms.
Used to search Pexels/Pixabay/Unsplash for stock footage.
"""
def compose(self, input_data: dict, engine: str = 'pexels') -> ComposedPrompt:
"""
input_data: {
'sentence': str, # Korean sentence to find visuals for
'platform': str, # 'pexels' | 'pixabay' | 'kling' | 'veo'
'count': int, # number of search queries to return (default 3)
}
Returns ComposedPrompt with queries list
"""
sentence = input_data.get('sentence', '')
count = input_data.get('count', 3)
queries = self._sentence_to_queries(sentence, count)
return ComposedPrompt(
queries=queries,
metadata={'sentence': sentence, 'engine': engine}
)
def _sentence_to_queries(self, sentence: str, count: int) -> list[str]:
"""Extract Korean concepts from sentence and map to visual search terms."""
# Find matching concepts from vocabulary
matched_visuals = []
for concept, visuals in CONCEPT_TO_VISUAL.items():
if concept in sentence:
matched_visuals.extend(visuals)
# If no matches, use generic professional stock footage terms
if not matched_visuals:
matched_visuals = ['professional business', 'modern lifestyle', 'technology future']
# Return up to count unique queries
seen = set()
unique = []
for v in matched_visuals:
if v not in seen:
seen.add(v)
unique.append(v)
return unique[:count]