Compare commits

...

2 Commits

Author SHA1 Message Date
Akarin~
0c57ace798 重构模型参数配置,合并为marshoai_model_args字典 (#11) 2025-02-13 01:02:18 +08:00
Akarin~
6885487709 修改reset命令,添加pdm.lock (#10)
* 🔧 update command

* 更新 .gitignore,修改 pypi-publish.yml 以删除冲突发布触发条件;调整 marsho.py 中的命令名称;更新使用文档。
2025-02-12 18:03:54 +08:00
11 changed files with 2926 additions and 26 deletions

View File

@@ -1,9 +1,6 @@
name: Publish name: Publish
on: on:
push:
tags:
- 'v*'
release: release:
types: types:
- published - published

1
.gitignore vendored
View File

@@ -170,7 +170,6 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder. # option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/ #.idea/
bot.py bot.py
pdm.lock
praises.json praises.json
*.bak *.bak
config/ config/

View File

@@ -122,9 +122,8 @@ Add options in the `.env` file from the diagram below in nonebot2 project.
| MARSHOAI_ENFORCE_NICKNAME | `bool` | `true` | Enforce user to set nickname or not | | MARSHOAI_ENFORCE_NICKNAME | `bool` | `true` | Enforce user to set nickname or not |
| MARSHOAI_POKE_SUFFIX | `str` | `揉了揉你的猫耳` | When double click Marsho who connected to OneBot adapter, the chat content. When it's empty string, double click function is off. Such as, the default content is `*[昵称]揉了揉你的猫耳。` | | MARSHOAI_POKE_SUFFIX | `str` | `揉了揉你的猫耳` | When double click Marsho who connected to OneBot adapter, the chat content. When it's empty string, double click function is off. Such as, the default content is `*[昵称]揉了揉你的猫耳。` |
| MARSHOAI_AZURE_ENDPOINT | `str` | `https://models.inference.ai.azure.com` | OpenAI standard API | | MARSHOAI_AZURE_ENDPOINT | `str` | `https://models.inference.ai.azure.com` | OpenAI standard API |
| MARSHOAI_TEMPERATURE | `float` | `null` | temperature parameter | | MARSHOAI_MODEL_ARGS | `dict` | `{}` |model arguments(such as `temperature`, `top_p`, `max_tokens` etc.) |
| MARSHOAI_TOP_P | `float` | `null` | Nucleus Sampling parameter |
| MARSHOAI_MAX_TOKENS | `int` | `null` | Max token number |
| MARSHOAI_ADDITIONAL_IMAGE_MODELS | `list` | `[]` | External image-support model list, such as `hunyuan-vision` | | MARSHOAI_ADDITIONAL_IMAGE_MODELS | `list` | `[]` | External image-support model list, such as `hunyuan-vision` |
| MARSHOAI_NICKNAME_LIMIT | `int` | `16` | Limit for nickname length | | MARSHOAI_NICKNAME_LIMIT | `int` | `16` | Limit for nickname length |
| MARSHOAI_TIMEOUT | `float` | `50` | AI request timeout (seconds) | | MARSHOAI_TIMEOUT | `float` | `50` | AI request timeout (seconds) |

View File

@@ -124,9 +124,7 @@ GitHub Models API 的限制较多,不建议使用,建议通过修改`MARSHOA
| MARSHOAI_ENFORCE_NICKNAME | `bool` | `true` | 是否强制用户设置昵称 | | MARSHOAI_ENFORCE_NICKNAME | `bool` | `true` | 是否强制用户设置昵称 |
| MARSHOAI_POKE_SUFFIX | `str` | `揉了揉你的猫耳` | 对 Marsho 所连接的 OneBot 用户进行双击戳一戳时,构建的聊天内容。此配置项为空字符串时,戳一戳响应功能会被禁用。例如,默认值构建的聊天内容将为`*[昵称]揉了揉你的猫耳。` | | MARSHOAI_POKE_SUFFIX | `str` | `揉了揉你的猫耳` | 对 Marsho 所连接的 OneBot 用户进行双击戳一戳时,构建的聊天内容。此配置项为空字符串时,戳一戳响应功能会被禁用。例如,默认值构建的聊天内容将为`*[昵称]揉了揉你的猫耳。` |
| MARSHOAI_AZURE_ENDPOINT | `str` | `https://models.inference.ai.azure.com` | OpenAI 标准格式 API 端点 | | MARSHOAI_AZURE_ENDPOINT | `str` | `https://models.inference.ai.azure.com` | OpenAI 标准格式 API 端点 |
| MARSHOAI_TEMPERATURE | `float` | `null` | 推理生成多样性(温度)参数 | | MARSHOAI_MODEL_ARGS | `dict` | `{}` | 模型参数(例如`temperature`, `top_p`, `max_tokens`等) |
| MARSHOAI_TOP_P | `float` | `null` | 推理核采样参数 |
| MARSHOAI_MAX_TOKENS | `int` | `null` | 最大生成 token 数 |
| MARSHOAI_ADDITIONAL_IMAGE_MODELS | `list` | `[]` | 额外添加的支持图片的模型列表,例如`hunyuan-vision` | | MARSHOAI_ADDITIONAL_IMAGE_MODELS | `list` | `[]` | 额外添加的支持图片的模型列表,例如`hunyuan-vision` |
| MARSHOAI_NICKNAME_LIMIT | `int` | `16` | 昵称长度限制 | | MARSHOAI_NICKNAME_LIMIT | `int` | `16` | 昵称长度限制 |
| MARSHOAI_TIMEOUT | `float` | `50` | AI 请求超时时间(秒) | | MARSHOAI_TIMEOUT | `float` | `50` | AI 请求超时时间(秒) |

View File

@@ -33,10 +33,12 @@ MarshoAI 兼容 DeepSeek-R1 模型,你可通过以下步骤来使用:
MARSHOAI_TOKEN="<你的 API Key>" MARSHOAI_TOKEN="<你的 API Key>"
MARSHOAI_AZURE_ENDPOINT="https://api.deepseek.com" MARSHOAI_AZURE_ENDPOINT="https://api.deepseek.com"
MARSHOAI_DEFAULT_MODEL="deepseek-reasoner" MARSHOAI_DEFAULT_MODEL="deepseek-reasoner"
MARSHOAI_ENABLE_PLUGINS=false
``` ```
你可修改 `MARSHOAI_DEFAULT_MODEL` 为 其它模型名来调用其它 DeepSeek 模型。 你可修改 `MARSHOAI_DEFAULT_MODEL` 为 其它模型名来调用其它 DeepSeek 模型。
:::tip :::tip
如果使用 one-api 作为中转,你可将 `MARSHOAI_AZURE_ENDPOINT` 设置为 one-api 的地址,将 `MARSHOAI_TOKEN` 设为 one-api 配置的令牌,在 one-api 中添加 DeepSeek 渠道。 如果使用 one-api 作为中转,你可将 `MARSHOAI_AZURE_ENDPOINT` 设置为 one-api 的地址,将 `MARSHOAI_TOKEN` 设为 one-api 配置的令牌,在 one-api 中添加 DeepSeek 渠道。
同样可使用其它提供商(例如 [SiliconFlow](https://siliconflow.cn/))提供的 DeepSeek 等模型。
::: :::
### 使用 vLLM 部署本地模型 ### 使用 vLLM 部署本地模型

View File

@@ -55,9 +55,7 @@ class ConfigModel(BaseModel):
marshoai_toolset_dir: list = [] marshoai_toolset_dir: list = []
marshoai_disabled_toolkits: list = [] marshoai_disabled_toolkits: list = []
marshoai_azure_endpoint: str = "https://models.inference.ai.azure.com" marshoai_azure_endpoint: str = "https://models.inference.ai.azure.com"
marshoai_temperature: float | None = None marshoai_model_args: dict = {}
marshoai_max_tokens: int | None = None
marshoai_top_p: float | None = None
marshoai_timeout: float | None = 50.0 marshoai_timeout: float | None = 50.0
marshoai_nickname_limit: int = 16 marshoai_nickname_limit: int = 16
marshoai_additional_image_models: list = [] marshoai_additional_image_models: list = []

View File

@@ -61,9 +61,7 @@ marshoai_devmode: false # 是否启用开发者模式。
marshoai_azure_endpoint: "https://models.inference.ai.azure.com" # OpenAI 标准格式 API 的端点。 marshoai_azure_endpoint: "https://models.inference.ai.azure.com" # OpenAI 标准格式 API 的端点。
# 模型参数配置 # 模型参数配置
marshoai_temperature: null # 调整生成的多样性,未设置时使用默认 marshoai_model_args: {} # 模型参数配置,默认
marshoai_max_tokens: null # 最大生成的token数未设置时使用默认值。
marshoai_top_p: null # 使用的概率采样值,未设置时使用默认值。
marshoai_timeout: 50.0 # 请求超时时间。 marshoai_timeout: 50.0 # 请求超时时间。
marshoai_additional_image_models: [] # 额外的图片模型列表,默认空。 marshoai_additional_image_models: [] # 额外的图片模型列表,默认空。

View File

@@ -2,10 +2,11 @@ import re
from .config import config from .config import config
NAME: str = config.marshoai_default_name
USAGE: str = f"""用法: USAGE: str = f"""用法:
{config.marshoai_default_name} <聊天内容> : 与 Marsho 进行对话。当模型为 GPT-4o(-mini) 等时,可以带上图片进行对话。 {NAME} <聊天内容> : 与 Marsho 进行对话。当模型为 GPT-4o(-mini) 等时,可以带上图片进行对话。
nickname [昵称] : 为自己设定昵称设置昵称后Marsho 会根据你的昵称进行回答。使用'nickname reset'命令可清除自己设定的昵称。 nickname [昵称] : 为自己设定昵称设置昵称后Marsho 会根据你的昵称进行回答。使用'nickname reset'命令可清除自己设定的昵称。
reset : 重置当前会话的上下文。 ※需要加上命令前缀使用(默认为'/')。 {NAME}.reset : 重置当前会话的上下文。
超级用户命令(均需要加上命令前缀使用): 超级用户命令(均需要加上命令前缀使用):
changemodel <模型名> : 切换全局 AI 模型。 changemodel <模型名> : 切换全局 AI 模型。
contexts : 返回当前会话的上下文列表。 ※当上下文包含图片时,不要使用此命令。 contexts : 返回当前会话的上下文列表。 ※当上下文包含图片时,不要使用此命令。

View File

@@ -37,7 +37,6 @@ async def at_enable():
changemodel_cmd = on_command( changemodel_cmd = on_command(
"changemodel", permission=SUPERUSER, priority=10, block=True "changemodel", permission=SUPERUSER, priority=10, block=True
) )
resetmem_cmd = on_command("reset", priority=10, block=True)
# setprompt_cmd = on_command("prompt",permission=SUPERUSER) # setprompt_cmd = on_command("prompt",permission=SUPERUSER)
praises_cmd = on_command("praises", permission=SUPERUSER, priority=10, block=True) praises_cmd = on_command("praises", permission=SUPERUSER, priority=10, block=True)
add_usermsg_cmd = on_command("usermsg", permission=SUPERUSER, priority=10, block=True) add_usermsg_cmd = on_command("usermsg", permission=SUPERUSER, priority=10, block=True)
@@ -60,6 +59,13 @@ marsho_cmd = on_alconna(
priority=10, priority=10,
block=True, block=True,
) )
resetmem_cmd = on_alconna(
Alconna(
config.marshoai_default_name + ".reset",
),
priority=10,
block=True,
)
marsho_help_cmd = on_alconna( marsho_help_cmd = on_alconna(
Alconna( Alconna(
config.marshoai_default_name + ".help", config.marshoai_default_name + ".help",

View File

@@ -126,9 +126,7 @@ async def make_chat(
messages=msg, messages=msg,
model=model_name, model=model_name,
tools=tools, tools=tools,
temperature=config.marshoai_temperature, **config.marshoai_model_args,
max_tokens=config.marshoai_max_tokens,
top_p=config.marshoai_top_p,
) )
@@ -151,10 +149,8 @@ async def make_chat_openai(
messages=msg, messages=msg,
model=model_name, model=model_name,
tools=tools or NOT_GIVEN, tools=tools or NOT_GIVEN,
temperature=config.marshoai_temperature or NOT_GIVEN,
max_tokens=config.marshoai_max_tokens or NOT_GIVEN,
top_p=config.marshoai_top_p or NOT_GIVEN,
timeout=config.marshoai_timeout, timeout=config.marshoai_timeout,
**config.marshoai_model_args,
) )

2906
pdm.lock generated Normal file

File diff suppressed because it is too large Load Diff