mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2024-11-30 09:14:52 +08:00
v0.3.3,动态版本号与版本号输出
This commit is contained in:
parent
2eaf719ec9
commit
eba300cdd1
@ -25,7 +25,7 @@ _✨ 使用 Azure OpenAI 推理服务的聊天机器人插件 ✨_
|
|||||||
插件内置了猫娘小棉(Marsho)的人物设定,可以进行可爱的聊天!
|
插件内置了猫娘小棉(Marsho)的人物设定,可以进行可爱的聊天!
|
||||||
*谁不喜欢回复消息快又可爱的猫娘呢?*
|
*谁不喜欢回复消息快又可爱的猫娘呢?*
|
||||||
**※对 Azure AI Studio等的支持待定。对 OneBot 以外的适配器支持未经过完全验证。**
|
**※对 Azure AI Studio等的支持待定。对 OneBot 以外的适配器支持未经过完全验证。**
|
||||||
|
[Melobot 实现(施工中)](https://github.com/LiteyukiStudio/marshoai-melo)
|
||||||
## 🐱 设定
|
## 🐱 设定
|
||||||
#### 基本信息
|
#### 基本信息
|
||||||
|
|
||||||
|
@ -4,28 +4,14 @@ require("nonebot_plugin_localstore")
|
|||||||
from .azure import *
|
from .azure import *
|
||||||
from nonebot import get_driver, logger
|
from nonebot import get_driver, logger
|
||||||
from .config import ConfigModel, config
|
from .config import ConfigModel, config
|
||||||
|
from .constants import USAGE
|
||||||
import nonebot_plugin_localstore as store
|
import nonebot_plugin_localstore as store
|
||||||
usage = """MarshoAI Beta by Asankilp
|
|
||||||
用法:
|
|
||||||
marsho <聊天内容> : 与 Marsho 进行对话。当模型为 GPT-4o(-mini) 等时,可以带上图片进行对话。
|
|
||||||
nickname [昵称] : 为自己设定昵称,设置昵称后,Marsho 会根据你的昵称进行回答。使用'nickname reset'命令可清除自己设定的昵称。
|
|
||||||
reset : 重置当前会话的上下文。 ※需要加上命令前缀使用(默认为'/')。
|
|
||||||
超级用户命令(均需要加上命令前缀使用):
|
|
||||||
changemodel <模型名> : 切换全局 AI 模型。
|
|
||||||
contexts : 返回当前会话的上下文列表。 ※当上下文包含图片时,不要使用此命令。
|
|
||||||
praises : 返回夸赞名单的提示词。
|
|
||||||
usermsg <消息> : 往当前会话添加用户消息(UserMessage)。
|
|
||||||
assistantmsg <消息> : 往当前会话添加助手消息(AssistantMessage)。
|
|
||||||
savecontext <文件名> : 保存当前会话的上下文至插件数据目录下的contexts/<文件名>.json里。
|
|
||||||
loadcontext <文件名> : 从插件数据目录下的contexts/<文件名>.json里读取上下文并覆盖到当前会话。
|
|
||||||
※本AI的回答"按原样"提供,不提供任何担保。AI也会犯错,请仔细甄别回答的准确性。"""
|
|
||||||
|
|
||||||
|
|
||||||
__author__ = "Asankilp"
|
__author__ = "Asankilp"
|
||||||
__plugin_meta__ = PluginMetadata(
|
__plugin_meta__ = PluginMetadata(
|
||||||
name="Marsho AI插件",
|
name="Marsho AI插件",
|
||||||
description="接入Azure服务的AI聊天插件",
|
description="接入Azure服务的AI聊天插件",
|
||||||
usage=usage,
|
usage=USAGE,
|
||||||
type="application",
|
type="application",
|
||||||
config=ConfigModel,
|
config=ConfigModel,
|
||||||
homepage="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai",
|
homepage="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai",
|
||||||
@ -43,4 +29,4 @@ async def _():
|
|||||||
logger.warning("token 未配置。可能无法进行聊天。")
|
logger.warning("token 未配置。可能无法进行聊天。")
|
||||||
else:
|
else:
|
||||||
logger.info("token 已配置~!🐾")
|
logger.info("token 已配置~!🐾")
|
||||||
pass
|
logger.info("マルショは、高性能ですから!")
|
||||||
|
@ -163,17 +163,9 @@ async def marsho(
|
|||||||
elif choice["finish_reason"] == CompletionsFinishReason.CONTENT_FILTERED:
|
elif choice["finish_reason"] == CompletionsFinishReason.CONTENT_FILTERED:
|
||||||
await UniMessage("*已被内容过滤器过滤。请调整聊天内容后重试。").send(reply_to=True)
|
await UniMessage("*已被内容过滤器过滤。请调整聊天内容后重试。").send(reply_to=True)
|
||||||
return
|
return
|
||||||
#await UniMessage(str(choice)).send()
|
|
||||||
await UniMessage(str(choice.message.content)).send(reply_to=True)
|
await UniMessage(str(choice.message.content)).send(reply_to=True)
|
||||||
#requests_limit = response.headers.get('x-ratelimit-limit-requests')
|
|
||||||
#request_id = response.headers.get('x-request-id')
|
|
||||||
#remaining_requests = response.headers.get('x-ratelimit-remaining-requests')
|
|
||||||
#remaining_tokens = response.headers.get('x-ratelimit-remaining-tokens')
|
|
||||||
#await UniMessage(f""" 剩余token:{remaining_tokens}"""
|
|
||||||
# ).send()
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await UniMessage(str(e)+suggest_solution(str(e))).send()
|
await UniMessage(str(e)+suggest_solution(str(e))).send()
|
||||||
# await UniMessage(str(e.reason)).send()
|
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from nonebot import on_type, message
|
from nonebot import on_type
|
||||||
from nonebot.rule import to_me
|
from nonebot.rule import to_me
|
||||||
from nonebot.adapters.onebot.v11 import PokeNotifyEvent
|
from nonebot.adapters.onebot.v11 import PokeNotifyEvent
|
||||||
poke_notify = on_type(
|
poke_notify = on_type(
|
||||||
|
@ -1,7 +1,24 @@
|
|||||||
|
__version__ = "0.3.3"
|
||||||
|
USAGE: str = f"""MarshoAI Beta v{__version__} by Asankilp
|
||||||
|
用法:
|
||||||
|
marsho <聊天内容> : 与 Marsho 进行对话。当模型为 GPT-4o(-mini) 等时,可以带上图片进行对话。
|
||||||
|
nickname [昵称] : 为自己设定昵称,设置昵称后,Marsho 会根据你的昵称进行回答。使用'nickname reset'命令可清除自己设定的昵称。
|
||||||
|
reset : 重置当前会话的上下文。 ※需要加上命令前缀使用(默认为'/')。
|
||||||
|
超级用户命令(均需要加上命令前缀使用):
|
||||||
|
changemodel <模型名> : 切换全局 AI 模型。
|
||||||
|
contexts : 返回当前会话的上下文列表。 ※当上下文包含图片时,不要使用此命令。
|
||||||
|
praises : 返回夸赞名单的提示词。
|
||||||
|
usermsg <消息> : 往当前会话添加用户消息(UserMessage)。
|
||||||
|
assistantmsg <消息> : 往当前会话添加助手消息(AssistantMessage)。
|
||||||
|
savecontext <文件名> : 保存当前会话的上下文至插件数据目录下的contexts/<文件名>.json里。
|
||||||
|
loadcontext <文件名> : 从插件数据目录下的contexts/<文件名>.json里读取上下文并覆盖到当前会话。
|
||||||
|
※本AI的回答"按原样"提供,不提供任何担保。AI也会犯错,请仔细甄别回答的准确性。"""
|
||||||
|
|
||||||
SUPPORT_IMAGE_MODELS: list = ["gpt-4o","gpt-4o-mini","llama-3.2-90b-vision-instruct","llama-3.2-11b-vision-instruct"]
|
SUPPORT_IMAGE_MODELS: list = ["gpt-4o","gpt-4o-mini","llama-3.2-90b-vision-instruct","llama-3.2-11b-vision-instruct"]
|
||||||
REASONING_MODELS: list = ["o1-preview","o1-mini"]
|
REASONING_MODELS: list = ["o1-preview","o1-mini"]
|
||||||
INTRODUCTION: str = """你好喵~我是一只可爱的猫娘AI,名叫小棉~🐾!
|
INTRODUCTION: str = """你好喵~我是一只可爱的猫娘AI,名叫小棉~🐾!
|
||||||
我的代码在这里哦~↓↓↓
|
我的代码在这里哦~↓↓↓
|
||||||
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai
|
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai
|
||||||
|
|
||||||
也可以关注一下还在成长中的 Melobot 酱喵~↓↓↓ https://github.com/Meloland/melobot """
|
也可以关注一下还在成长中的 Melobot 酱喵~↓↓↓
|
||||||
|
https://github.com/Meloland/melobot"""
|
||||||
|
@ -6,9 +6,8 @@ import httpx
|
|||||||
import nonebot_plugin_localstore as store
|
import nonebot_plugin_localstore as store
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from zhDateTime import DateTime
|
from zhDateTime import DateTime
|
||||||
from pathlib import Path
|
|
||||||
from azure.ai.inference.aio import ChatCompletionsClient
|
from azure.ai.inference.aio import ChatCompletionsClient
|
||||||
from azure.ai.inference.models import SystemMessage, UserMessage
|
from azure.ai.inference.models import SystemMessage
|
||||||
from .config import config
|
from .config import config
|
||||||
async def get_image_b64(url):
|
async def get_image_b64(url):
|
||||||
headers = {
|
headers = {
|
||||||
@ -80,10 +79,10 @@ async def set_nickname(user_id: str, name: str):
|
|||||||
if not os.path.exists(filename):
|
if not os.path.exists(filename):
|
||||||
data = {}
|
data = {}
|
||||||
else:
|
else:
|
||||||
with open(filename,'r') as f:
|
with open(filename,'r', encoding='utf-8') as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
data[user_id] = name
|
data[user_id] = name
|
||||||
with open(filename, 'w') as f:
|
with open(filename, 'w', encoding='utf-8') as f:
|
||||||
json.dump(data, f, ensure_ascii=False, indent=4)
|
json.dump(data, f, ensure_ascii=False, indent=4)
|
||||||
|
|
||||||
async def get_nicknames():
|
async def get_nicknames():
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "nonebot-plugin-marshoai"
|
name = "nonebot-plugin-marshoai"
|
||||||
version = "0.3.2"
|
dynamic = ["version"]
|
||||||
description = "Nonebot2插件,调用Azure OpenAI服务实现猫娘聊天"
|
description = "Nonebot2插件,调用Azure OpenAI服务实现猫娘聊天"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = "<4.0,>=3.9"
|
requires-python = "<4.0,>=3.9"
|
||||||
@ -22,15 +22,13 @@ Homepage = "https://github.com/LiteyukiStudio/nonebot-plugin-marshoai"
|
|||||||
|
|
||||||
[tool.nonebot]
|
[tool.nonebot]
|
||||||
plugins = ["nonebot_plugin_marshoai"]
|
plugins = ["nonebot_plugin_marshoai"]
|
||||||
adapters = [{name = "OneBot V11", module_name = "nonebot.adapters.onebot.v11"}]
|
|
||||||
|
|
||||||
|
|
||||||
[tool.pdm]
|
[tool.pdm]
|
||||||
distribution = true
|
distribution = true
|
||||||
|
|
||||||
[tool.pdm.version]
|
[tool.pdm.version]
|
||||||
source = "file"
|
source = "file"
|
||||||
path = "nonebot_plugin_marshoai/__init__.py"
|
path = "nonebot_plugin_marshoai/constants.py"
|
||||||
|
|
||||||
[tool.pdm.build]
|
[tool.pdm.build]
|
||||||
includes = []
|
includes = []
|
||||||
|
Loading…
Reference in New Issue
Block a user