|
@@ -25,19 +25,23 @@ PROXY_ADDR = 'http://localhost:1081'
|
|
|
CACHE_DIR = '/app/cache/' if ENV == 'prod' else os.path.expanduser('~/Downloads/')
|
|
|
SAMPLE_DATA = {
|
|
|
"一、基础信息": {
|
|
|
- "视觉/音乐/文字": "",
|
|
|
+ "关键维度": "",
|
|
|
"内容选题": "",
|
|
|
- "视频主题": ""
|
|
|
+ "视频主题": "",
|
|
|
+ "视频关键词":""
|
|
|
},
|
|
|
"二、主体和场景": {
|
|
|
"视频主体": "",
|
|
|
"视频场景": []
|
|
|
},
|
|
|
- "三、情感与风格": {},
|
|
|
- "四、视频传播性与观众": {
|
|
|
+ "三、情感与风格": {
|
|
|
+ "情感倾向":"",
|
|
|
+ "视频风格":""
|
|
|
+ },
|
|
|
+ "四、视频传播性与画像": {
|
|
|
"片尾引导": {},
|
|
|
"传播性判断": "",
|
|
|
- "观众画像": {}
|
|
|
+ "视频用户画像": {}
|
|
|
},
|
|
|
"五、音画细节": {
|
|
|
"音频细节": {},
|
|
@@ -45,15 +49,24 @@ SAMPLE_DATA = {
|
|
|
"视频字幕": {},
|
|
|
"视频口播": ""
|
|
|
},
|
|
|
- "六、人物与场景": {
|
|
|
- "知名人物": {},
|
|
|
- "人物年龄段": "",
|
|
|
- "场景描述": []
|
|
|
+ "六、封面信息": {
|
|
|
+ "封面主体": "",
|
|
|
+ "人物个数": "",
|
|
|
+ "文字数量": "",
|
|
|
+ "文字关键字":[],
|
|
|
+ "封面主题":""
|
|
|
+ },
|
|
|
+ "七、人物与场景": {
|
|
|
+ "知名人物":"",
|
|
|
+ "人物年龄段":"",
|
|
|
+ "场景描述": ""
|
|
|
},
|
|
|
- "七、时效性与分类": {
|
|
|
- "时效性": {},
|
|
|
+ "八、时效性与分类": {
|
|
|
+ "时效性":"",
|
|
|
"视频一级分类": "",
|
|
|
"二级分类": ["品类- 、分数-", "品类- 、分数-", "品类- 、分数-"]
|
|
|
+ },
|
|
|
+ "九、标题理解": {
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -131,16 +144,25 @@ def create_model_cache(redis_task) -> Optional[genai.GenerativeModel]:
|
|
|
return
|
|
|
|
|
|
|
|
|
-def analyze_video(model: genai.GenerativeModel, google_file: File, prompt: str, redis_task) -> Optional[GenerateContentResponse]:
|
|
|
+def analyze_video(model: genai.GenerativeModel, google_file: File, prompt: str, redis_task, title) -> Optional[GenerateContentResponse]:
|
|
|
try:
|
|
|
session = model.start_chat(history=[])
|
|
|
- content = {
|
|
|
- 'parts': [
|
|
|
- google_file,
|
|
|
- f'{prompt}\n输出返回格式样例:\n{SAMPLE_DATA}',
|
|
|
- ],
|
|
|
- }
|
|
|
- return session.send_message(content=content)
|
|
|
+ if title:
|
|
|
+ content = {
|
|
|
+ 'parts': [
|
|
|
+ google_file,
|
|
|
+ f'{prompt}\n输出返回格式样例:\n{SAMPLE_DATA}',
|
|
|
+ ],
|
|
|
+ }
|
|
|
+ return session.send_message(content=content)
|
|
|
+ else:
|
|
|
+ content = {
|
|
|
+ 'parts': [
|
|
|
+ google_file,
|
|
|
+ f'{prompt}\n标题理解:请对"{title}"进行分析概括3~5个词[]":\n输出返回格式样例:\n{SAMPLE_DATA}',
|
|
|
+ ],
|
|
|
+ }
|
|
|
+ return session.send_message(content=content)
|
|
|
except Exception as e:
|
|
|
AliyunLogger.logging( str( redis_task['video_id'] ), redis_task['title'], redis_task['video_path'], '',
|
|
|
redis_task['type'], redis_task['partition'], f"[+] 视频处理请求失败: {e}" )
|
|
@@ -199,7 +221,7 @@ def run():
|
|
|
genai.delete_file(google_file)
|
|
|
return
|
|
|
|
|
|
- response = analyze_video(model=model, google_file=google_file, prompt=prompt, redis_task=redis_task)
|
|
|
+ response = analyze_video(model=model, google_file=google_file, prompt=prompt, redis_task=redis_task, title=redis_task['title'])
|
|
|
if isinstance(response, str):
|
|
|
logger.error('[+] 获取模型响应失败, 跳过任务')
|
|
|
genai.delete_file(google_file)
|