mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2024-11-23 01:27:38 +08:00
🐱v0.3.4,优化marsho命令参数的获取,自我介绍文本更新
This commit is contained in:
parent
eba300cdd1
commit
1eb1ad3c8e
@ -136,4 +136,4 @@ _✨ 使用 Azure OpenAI 推理服务的聊天机器人插件 ✨_
|
||||
## 🕊️ TODO
|
||||
- [x] 对聊天发起者的认知(认出是谁在问 Marsho)(初步实现)
|
||||
- [ ] 上下文通过数据库持久化存储
|
||||
- [ ] [Melobot](https://github.com/Meloland/melobot) 实现
|
||||
- [ ] [Melobot](https://github.com/Meloland/melobot) 实现(施工中)
|
||||
|
@ -11,6 +11,7 @@ import contextlib
|
||||
from azure.ai.inference.aio import ChatCompletionsClient
|
||||
from azure.ai.inference.models import UserMessage, AssistantMessage, TextContentItem, ImageContentItem, ImageUrl, CompletionsFinishReason
|
||||
from azure.core.credentials import AzureKeyCredential
|
||||
from typing import Optional
|
||||
from .__init__ import __plugin_meta__
|
||||
from .config import config
|
||||
from .models import MarshoContext
|
||||
@ -109,15 +110,14 @@ async def nickname(
|
||||
async def marsho(
|
||||
target: MsgTarget,
|
||||
event: Event,
|
||||
message: UniMsg,
|
||||
text = None
|
||||
text: Optional[UniMsg] = None
|
||||
):
|
||||
if not text:
|
||||
await UniMessage(
|
||||
__plugin_meta__.usage+"\n当前使用的模型:"+model_name).send()
|
||||
await marsho_cmd.finish(INTRODUCTION)
|
||||
return
|
||||
# await UniMessage(str(text)).send()
|
||||
|
||||
try:
|
||||
is_support_image_model = model_name.lower() in SUPPORT_IMAGE_MODELS
|
||||
usermsg = [] if is_support_image_model else ""
|
||||
@ -129,8 +129,7 @@ async def marsho(
|
||||
else:
|
||||
nickname_prompt = ""
|
||||
await UniMessage("*你未设置自己的昵称。推荐使用'nickname [昵称]'命令设置昵称来获得个性化(可能)回答。").send()
|
||||
marsho_string_removed = False
|
||||
for i in message:
|
||||
for i in text:
|
||||
if i.type == "image":
|
||||
if is_support_image_model:
|
||||
imgurl = i.data["url"]
|
||||
@ -141,12 +140,7 @@ async def marsho(
|
||||
else:
|
||||
await UniMessage("*此模型不支持图片处理。").send()
|
||||
elif i.type == "text":
|
||||
if not marsho_string_removed:
|
||||
# 去掉最前面的"marsho "字符串
|
||||
clean_text = i.data["text"].lstrip("marsho ")
|
||||
marsho_string_removed = True # 标记文本已处理
|
||||
else:
|
||||
clean_text = i.data["text"]
|
||||
clean_text = i.data["text"]
|
||||
if is_support_image_model:
|
||||
usermsg.append(TextContentItem(text=clean_text+nickname_prompt))
|
||||
else:
|
||||
|
@ -1,4 +1,4 @@
|
||||
__version__ = "0.3.3"
|
||||
__version__ = "0.3.4"
|
||||
USAGE: str = f"""MarshoAI Beta v{__version__} by Asankilp
|
||||
用法:
|
||||
marsho <聊天内容> : 与 Marsho 进行对话。当模型为 GPT-4o(-mini) 等时,可以带上图片进行对话。
|
||||
@ -21,4 +21,6 @@ INTRODUCTION: str = """你好喵~我是一只可爱的猫娘AI,名叫小棉~
|
||||
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai
|
||||
|
||||
也可以关注一下还在成长中的 Melobot 酱喵~↓↓↓
|
||||
https://github.com/Meloland/melobot"""
|
||||
https://github.com/Meloland/melobot
|
||||
我与 Melobot 酱贴贴的代码在这里喵~↓↓↓
|
||||
https://github.com/LiteyukiStudio/marshoai-melo"""
|
||||
|
@ -30,13 +30,13 @@ async def get_image_b64(url):
|
||||
return None
|
||||
|
||||
async def make_chat(client: ChatCompletionsClient, msg, model_name: str):
|
||||
return await client.complete(
|
||||
messages=msg,
|
||||
model=model_name,
|
||||
temperature=config.marshoai_temperature,
|
||||
max_tokens=config.marshoai_max_tokens,
|
||||
top_p=config.marshoai_top_p
|
||||
)
|
||||
return await client.complete(
|
||||
messages=msg,
|
||||
model=model_name,
|
||||
temperature=config.marshoai_temperature,
|
||||
max_tokens=config.marshoai_max_tokens,
|
||||
top_p=config.marshoai_top_p
|
||||
)
|
||||
def get_praises():
|
||||
praises_file = store.get_plugin_data_file("praises.json") # 夸赞名单文件使用localstore存储
|
||||
if not os.path.exists(praises_file):
|
||||
|
Loading…
Reference in New Issue
Block a user