mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2025-09-24 15:36:23 +00:00
🐛 处理可能的意外 application/octet-stream ,兼容matcha
This commit is contained in:
@ -83,6 +83,8 @@ async def get_image_raw_and_type(
|
|||||||
content_type = response.headers.get("Content-Type")
|
content_type = response.headers.get("Content-Type")
|
||||||
if not content_type:
|
if not content_type:
|
||||||
content_type = mimetypes.guess_type(url)[0]
|
content_type = mimetypes.guess_type(url)[0]
|
||||||
|
if content_type == "application/octet-stream": # matcha 兼容
|
||||||
|
content_type = "image/jpeg"
|
||||||
# image_format = content_type.split("/")[1] if content_type else "jpeg"
|
# image_format = content_type.split("/")[1] if content_type else "jpeg"
|
||||||
return response.content, str(content_type)
|
return response.content, str(content_type)
|
||||||
else:
|
else:
|
||||||
@ -125,7 +127,7 @@ async def make_chat_openai(
|
|||||||
model_name: 指定AI模型名
|
model_name: 指定AI模型名
|
||||||
tools: 工具列表
|
tools: 工具列表
|
||||||
"""
|
"""
|
||||||
print(msg)
|
# print(msg)
|
||||||
return await client.chat.completions.create( # type: ignore
|
return await client.chat.completions.create( # type: ignore
|
||||||
messages=msg,
|
messages=msg,
|
||||||
model=model_name,
|
model=model_name,
|
||||||
|
Reference in New Issue
Block a user