mirror of https://github.com/Mai-with-u/MaiBot.git
修复Images.id问题
parent
05d62208ac
commit
36345e416a
|
|
@ -174,9 +174,7 @@ class ImageManager:
|
|||
|
||||
# 使用较低温度确保输出稳定
|
||||
emotion_llm = LLMRequest(model_set=model_config.model_task_config.utils, request_type="emoji")
|
||||
emotion_result, _ = await emotion_llm.generate_response_async(
|
||||
emotion_prompt, temperature=0.3
|
||||
)
|
||||
emotion_result, _ = await emotion_llm.generate_response_async(emotion_prompt, temperature=0.3)
|
||||
|
||||
if not emotion_result:
|
||||
logger.warning("LLM未能生成情感标签,使用详细描述的前几个词")
|
||||
|
|
@ -228,6 +226,7 @@ class ImageManager:
|
|||
type="emoji",
|
||||
description=detailed_description, # 保存详细描述
|
||||
timestamp=current_timestamp,
|
||||
vlm_processed=True,
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"保存表情包文件或元数据失败: {str(e)}")
|
||||
|
|
|
|||
|
|
@ -725,7 +725,21 @@ def check_field_constraints():
|
|||
logger.exception(f"检查字段约束时出错: {e}")
|
||||
|
||||
return inconsistencies
|
||||
|
||||
def fix_image_id():
|
||||
"""
|
||||
修复表情包的 image_id 字段
|
||||
"""
|
||||
import uuid
|
||||
try:
|
||||
with db:
|
||||
for img in Images.select():
|
||||
if not img.image_id:
|
||||
img.image_id = str(uuid.uuid4())
|
||||
img.save()
|
||||
logger.info(f"已为表情包 {img.id} 生成新的 image_id: {img.image_id}")
|
||||
except Exception as e:
|
||||
logger.exception(f"修复 image_id 时出错: {e}")
|
||||
|
||||
# 模块加载时调用初始化函数
|
||||
initialize_database(sync_constraints=True)
|
||||
fix_image_id()
|
||||
Loading…
Reference in New Issue