From 36345e416ab21a0edb7727a8aea5b3e34a73ec6e Mon Sep 17 00:00:00 2001 From: UnCLAS-Prommer Date: Wed, 17 Sep 2025 21:21:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DImages.id=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chat/utils/utils_image.py | 5 ++--- src/common/database/database_model.py | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/chat/utils/utils_image.py b/src/chat/utils/utils_image.py index 50e9734d..94565b78 100644 --- a/src/chat/utils/utils_image.py +++ b/src/chat/utils/utils_image.py @@ -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)}") diff --git a/src/common/database/database_model.py b/src/common/database/database_model.py index 48ee5b0b..eff1eeee 100644 --- a/src/common/database/database_model.py +++ b/src/common/database/database_model.py @@ -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() \ No newline at end of file