This commit is contained in:
Windpicker-owo
2025-11-08 22:17:25 +08:00
4 changed files with 8 additions and 5 deletions

View File

@@ -254,7 +254,8 @@ class ChineseTypoGenerator:
all_combinations = itertools.product(*candidates)
# 获取rjieba词典和词频信息
dict_path = os.path.join(os.path.dirname(rjieba.__file__), "dict.txt")
base_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
dict_path = os.path.join(base_dir, "depends-data", "dict.txt")
valid_words = {} # 改用字典存储词语及其频率
with open(dict_path, encoding="utf-8") as f:
for line in f:

View File

@@ -6,7 +6,7 @@
import asyncio
import base64
import datetime
import imghdr
import filetype
from collections.abc import Callable
import aiohttp
@@ -238,11 +238,11 @@ class ContentService:
continue
image_bytes = await resp.read()
image_format = imghdr.what(None, image_bytes)
if not image_format:
kind = filetype.guess(image_bytes)
if kind is None:
logger.error(f"无法识别图片格式: {image_url}")
return None
image_format = kind.extension
image_base64 = base64.b64encode(image_bytes).decode("utf-8")
vision_model_name = self.get_config("models.vision_model", "vlm")