遵循s指导
This commit is contained in:
@@ -239,7 +239,7 @@ class EmojiManager:
|
|||||||
|
|
||||||
image_bytes = base64.b64decode(image_base64)
|
image_bytes = base64.b64decode(image_base64)
|
||||||
image_hash = hashlib.md5(image_bytes).hexdigest()
|
image_hash = hashlib.md5(image_bytes).hexdigest()
|
||||||
image_format = Image.open(io.BytesIO(image_bytes)).format
|
image_format = Image.open(io.BytesIO(image_bytes)).format.lower()
|
||||||
# 检查是否已经注册过
|
# 检查是否已经注册过
|
||||||
existing_emoji = self.db['emoji'].find_one({'filename': filename})
|
existing_emoji = self.db['emoji'].find_one({'filename': filename})
|
||||||
description = None
|
description = None
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ class ImageManager:
|
|||||||
|
|
||||||
# 计算哈希值
|
# 计算哈希值
|
||||||
image_hash = hashlib.md5(image_bytes).hexdigest()
|
image_hash = hashlib.md5(image_bytes).hexdigest()
|
||||||
image_format = Image.open(io.BytesIO(image_bytes)).format
|
image_format = Image.open(io.BytesIO(image_bytes)).format.lower()
|
||||||
|
|
||||||
# 查重
|
# 查重
|
||||||
existing = self.db.images.find_one({'hash': image_hash})
|
existing = self.db.images.find_one({'hash': image_hash})
|
||||||
@@ -241,7 +241,7 @@ class ImageManager:
|
|||||||
# 计算图片哈希
|
# 计算图片哈希
|
||||||
image_bytes = base64.b64decode(image_base64)
|
image_bytes = base64.b64decode(image_base64)
|
||||||
image_hash = hashlib.md5(image_bytes).hexdigest()
|
image_hash = hashlib.md5(image_bytes).hexdigest()
|
||||||
image_format = Image.open(io.BytesIO(image_bytes)).format
|
image_format = Image.open(io.BytesIO(image_bytes)).format.lower()
|
||||||
|
|
||||||
# 查询缓存的描述
|
# 查询缓存的描述
|
||||||
cached_description = self._get_description_from_db(image_hash, 'emoji')
|
cached_description = self._get_description_from_db(image_hash, 'emoji')
|
||||||
@@ -296,7 +296,7 @@ class ImageManager:
|
|||||||
# 计算图片哈希
|
# 计算图片哈希
|
||||||
image_bytes = base64.b64decode(image_base64)
|
image_bytes = base64.b64decode(image_base64)
|
||||||
image_hash = hashlib.md5(image_bytes).hexdigest()
|
image_hash = hashlib.md5(image_bytes).hexdigest()
|
||||||
image_format = Image.open(io.BytesIO(image_bytes)).format
|
image_format = Image.open(io.BytesIO(image_bytes)).format.lower()
|
||||||
|
|
||||||
# 查询缓存的描述
|
# 查询缓存的描述
|
||||||
cached_description = self._get_description_from_db(image_hash, 'image')
|
cached_description = self._get_description_from_db(image_hash, 'image')
|
||||||
|
|||||||
@@ -393,7 +393,7 @@ class LLM_request:
|
|||||||
)
|
)
|
||||||
return content, reasoning_content
|
return content, reasoning_content
|
||||||
|
|
||||||
async def generate_response_for_image(self, prompt: str, image_base64: str, image_format: str) -> Tuple[str, str, str]:
|
async def generate_response_for_image(self, prompt: str, image_base64: str, image_format: str) -> Tuple[str, str]:
|
||||||
"""根据输入的提示和图片生成模型的异步响应"""
|
"""根据输入的提示和图片生成模型的异步响应"""
|
||||||
|
|
||||||
content, reasoning_content = await self._execute_request(
|
content, reasoning_content = await self._execute_request(
|
||||||
|
|||||||
Reference in New Issue
Block a user