mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2025-02-07 21:46:10 +08:00
🐛修复模型兼容问题,兼容o1模型,添加配置项
This commit is contained in:
parent
24858795ad
commit
85cf197f27
@ -125,9 +125,10 @@ _✨ 使用 Azure OpenAI 推理服务的聊天机器人插件 ✨_
|
||||
| MARSHOAI_DEFAULT_NAME | 否 | `marsho` | 调用 marsho 默认的命令前缀 |
|
||||
| MARSHOAI_ALIASES | 否 | `set{"小绵"}` | 调用 marsho 的命令别名 |
|
||||
| MARSHOAI_DEFAULT_MODEL | 否 | `gpt-4o-mini` | Marsho 默认调用的模型 |
|
||||
| MARSHOAI_PROMPT | 否 | 猫娘 Marsho 人设提示词 | Marsho 的基本系统提示词 |
|
||||
| MARSHOAI_PROMPT | 否 | 猫娘 Marsho 人设提示词 | Marsho 的基本系统提示词 **推理模型(o1等)不支持系统提示词。** |
|
||||
| MARSHOAI_ADDITIONAL_PROMPT | 否 | 无 | Marsho 的扩展系统提示词 |
|
||||
| MARSHOAI_POKE_SUFFIX | 否 | `揉了揉你的猫耳` | 对 Marsho 所连接的 OneBot 用户进行双击戳一戳时,构建的聊天内容。此配置项为空字符串时,戳一戳响应功能会被禁用。例如,默认值构建的聊天内容将为`*[昵称]揉了揉你的猫耳`。 |
|
||||
| MARSHOAI_ENABLE_SUPPORT_IMAGE_TIP | 否 | `true` | 启用后用户发送带图请求时若模型不支持图片,则提示用户 |
|
||||
| MARSHOAI_ENABLE_NICKNAME_TIP | 否 | `true` | 启用后用户未设置昵称时提示用户设置 |
|
||||
| MARSHOAI_ENABLE_PRAISES | 否 | `true` | 是否启用夸赞名单功能 |
|
||||
| MARSHOAI_ENABLE_TIME_PROMPT | 否 | `true` | 是否启用实时更新的日期与时间(精确到秒)与农历日期系统提示词 |
|
||||
|
@ -147,21 +147,30 @@ async def marsho(target: MsgTarget, event: Event, text: Optional[UniMsg] = None)
|
||||
"*你未设置自己的昵称。推荐使用'nickname [昵称]'命令设置昵称来获得个性化(可能)回答。"
|
||||
).send()
|
||||
|
||||
usermsg: list[ContentItem] = []
|
||||
is_support_image_model = model_name.lower() in SUPPORT_IMAGE_MODELS
|
||||
is_reasoning_model = model_name.lower() in REASONING_MODELS
|
||||
usermsg = [] if is_support_image_model else ""
|
||||
for i in text:
|
||||
if i.type == "text":
|
||||
if is_support_image_model:
|
||||
usermsg += [TextContentItem(text=i.data["text"] + nickname_prompt)]
|
||||
elif i.type == "image" and model_name.lower() in SUPPORT_IMAGE_MODELS:
|
||||
else:
|
||||
usermsg += str(i.data["text"] + nickname_prompt)
|
||||
elif i.type == "image":
|
||||
if is_support_image_model:
|
||||
usermsg.append(
|
||||
ImageContentItem(
|
||||
image_url=ImageUrl(url=str(await get_image_b64(i.data["url"])))
|
||||
)
|
||||
)
|
||||
|
||||
elif config.marshoai_enable_support_image_tip:
|
||||
await UniMessage("*此模型不支持图片处理。").send()
|
||||
context_msg = context.build(target.id, target.private)
|
||||
if is_reasoning_model: context_msg = context_msg[1:] #o1等推理模型不支持系统提示词,故截断
|
||||
response = await make_chat(
|
||||
client=client,
|
||||
model_name=model_name,
|
||||
msg=context.build(target.id, target.private)
|
||||
msg=context_msg
|
||||
+ [UserMessage(content=usermsg)],
|
||||
)
|
||||
# await UniMessage(str(response)).send()
|
||||
|
@ -16,6 +16,7 @@ class ConfigModel(BaseModel):
|
||||
marshoai_additional_prompt: str = ""
|
||||
marshoai_poke_suffix: str = "揉了揉你的猫耳"
|
||||
marshoai_enable_nickname_tip: bool = True
|
||||
marshoai_enable_support_image_tip: bool = True
|
||||
marshoai_enable_praises: bool = True
|
||||
marshoai_enable_time_prompt: bool = True
|
||||
marshoai_azure_endpoint: str = "https://models.inference.ai.azure.com"
|
||||
|
@ -1,5 +1,5 @@
|
||||
__version__ = "0.3.4.1"
|
||||
USAGE: str = f"""MarshoAI-NoneBot Beta v{__version__} by Asankilp
|
||||
|
||||
USAGE: str = f"""MarshoAI-NoneBot Beta by Asankilp
|
||||
用法:
|
||||
marsho <聊天内容> : 与 Marsho 进行对话。当模型为 GPT-4o(-mini) 等时,可以带上图片进行对话。
|
||||
nickname [昵称] : 为自己设定昵称,设置昵称后,Marsho 会根据你的昵称进行回答。使用'nickname reset'命令可清除自己设定的昵称。
|
||||
|
Loading…
x
Reference in New Issue
Block a user