diff --git a/main.py b/main.py index f14967e..19c357e 100644 --- a/main.py +++ b/main.py @@ -29,7 +29,11 @@ def main(): image_path = Path(root_folder) / image if check_emoji(emoji_uuid): - description = gen.process_single_image(str(image_path)) + try: + description = gen.process_single_image(str(image_path)) + except AttributeError: + logger.warning("AI模型未响应,请检查是否欠费!") + break update_description(emoji_uuid, description) if description: logger.info(f"图片 {emoji_file} 的描述词生成完毕,序号:{i + 1}, 其 description 为: {description}") diff --git a/models/generator.py b/models/generator.py index c6c7f2d..865cdaa 100644 --- a/models/generator.py +++ b/models/generator.py @@ -37,6 +37,8 @@ class Generator: return None + except AttributeError as e: + raise AttributeError(e) except Exception as e: logger.error(f"API调用失败: {e}") return None