mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2025-08-02 14:49:51 +00:00
Deploying to docs from @ LiteyukiStudio/nonebot-plugin-marshoai@23ca88b93a 🚀
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import{_ as i,c as a,ae as n,o as h}from"./chunks/framework.BzDBnRMZ.js";const g=JSON.parse('{"title":"marsho","description":"","frontmatter":{"title":"marsho","order":100},"headers":[],"relativePath":"dev/api/marsho.md","filePath":"zh/dev/api/marsho.md","lastUpdated":null}'),t={name:"dev/api/marsho.md"};function k(l,s,e,p,E,r){return h(),a("div",null,s[0]||(s[0]=[n(`<h1 id="模块-nonebot-plugin-marshoai-marsho" tabindex="-1"><strong>模块</strong> <code>nonebot_plugin_marshoai.marsho</code> <a class="header-anchor" href="#模块-nonebot-plugin-marshoai-marsho" aria-label="Permalink to "**模块** \`nonebot_plugin_marshoai.marsho\`""></a></h1><hr><h3 id="async-func-at-enable" tabindex="-1"><em><strong>async func</strong></em> <code>at_enable()</code> <a class="header-anchor" href="#async-func-at-enable" aria-label="Permalink to "***async func*** \`at_enable()\`""></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L35" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> at_enable</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">():</span></span>
|
||||
import{_ as i,c as a,ae as n,o as h}from"./chunks/framework.BzDBnRMZ.js";const d=JSON.parse('{"title":"marsho","description":"","frontmatter":{"title":"marsho","order":100},"headers":[],"relativePath":"dev/api/marsho.md","filePath":"zh/dev/api/marsho.md","lastUpdated":null}'),t={name:"dev/api/marsho.md"};function k(l,s,e,p,E,r){return h(),a("div",null,s[0]||(s[0]=[n(`<h1 id="模块-nonebot-plugin-marshoai-marsho" tabindex="-1"><strong>模块</strong> <code>nonebot_plugin_marshoai.marsho</code> <a class="header-anchor" href="#模块-nonebot-plugin-marshoai-marsho" aria-label="Permalink to "**模块** \`nonebot_plugin_marshoai.marsho\`""></a></h1><hr><h3 id="async-func-at-enable" tabindex="-1"><em><strong>async func</strong></em> <code>at_enable()</code> <a class="header-anchor" href="#async-func-at-enable" aria-label="Permalink to "***async func*** \`at_enable()\`""></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L35" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> at_enable</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">():</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config.marshoai_at</span></span></code></pre></div></details><hr><p><code>@add_usermsg_cmd.handle()</code></p><h3 id="async-func-add-usermsg-target-msgtarget-arg-message-commandarg" tabindex="-1"><em><strong>async func</strong></em> <code>add_usermsg(target: MsgTarget, arg: Message = CommandArg())</code> <a class="header-anchor" href="#async-func-add-usermsg-target-msgtarget-arg-message-commandarg" aria-label="Permalink to "***async func*** \`add_usermsg(target: MsgTarget, arg: Message = CommandArg())\`""></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L95" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@add_usermsg_cmd.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> add_usermsg</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(target: MsgTarget, arg: Message</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">CommandArg()):</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (msg </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> arg.extract_plain_text()):</span></span>
|
||||
@ -30,13 +30,16 @@ import{_ as i,c as a,ae as n,o as h}from"./chunks/framework.BzDBnRMZ.js";const g
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> resetmem</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(target: MsgTarget):</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> [target.id, target.private] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">not</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> target_list:</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> target_list.append([target.id, target.private])</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> backup_context </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_backup_context(target.id, target.private)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> backup_context:</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> context.set_context(backup_context, target.id, target.private)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> context.reset(target.id, target.private)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> resetmem_cmd.finish(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'上下文已重置'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><hr><p><code>@changemodel_cmd.handle()</code></p><h3 id="async-func-changemodel-arg-message-commandarg" tabindex="-1"><em><strong>async func</strong></em> <code>changemodel(arg: Message = CommandArg())</code> <a class="header-anchor" href="#async-func-changemodel-arg-message-commandarg" aria-label="Permalink to "***async func*** \`changemodel(arg: Message = CommandArg())\`""></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L155" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@changemodel_cmd.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> resetmem_cmd.finish(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'上下文已重置'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><hr><p><code>@changemodel_cmd.handle()</code></p><h3 id="async-func-changemodel-arg-message-commandarg" tabindex="-1"><em><strong>async func</strong></em> <code>changemodel(arg: Message = CommandArg())</code> <a class="header-anchor" href="#async-func-changemodel-arg-message-commandarg" aria-label="Permalink to "***async func*** \`changemodel(arg: Message = CommandArg())\`""></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L158" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@changemodel_cmd.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> changemodel</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(arg: Message</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">CommandArg()):</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> global</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> model_name</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (model </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> arg.extract_plain_text()):</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> model_name </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> model</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> changemodel_cmd.finish(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'已切换'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><hr><p><code>@nickname_cmd.handle()</code></p><h3 id="async-func-nickname-event-event-name-none" tabindex="-1"><em><strong>async func</strong></em> <code>nickname(event: Event, name = None)</code> <a class="header-anchor" href="#async-func-nickname-event-event-name-none" aria-label="Permalink to "***async func*** \`nickname(event: Event, name = None)\`""></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L163" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@nickname_cmd.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> changemodel_cmd.finish(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'已切换'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><hr><p><code>@nickname_cmd.handle()</code></p><h3 id="async-func-nickname-event-event-name-none" tabindex="-1"><em><strong>async func</strong></em> <code>nickname(event: Event, name = None)</code> <a class="header-anchor" href="#async-func-nickname-event-event-name-none" aria-label="Permalink to "***async func*** \`nickname(event: Event, name = None)\`""></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L166" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@nickname_cmd.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> nickname</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(event: Event, name</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> nicknames </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_nicknames()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> user_id </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> event.get_user_id()</span></span>
|
||||
@ -51,15 +54,15 @@ import{_ as i,c as a,ae as n,o as h}from"./chunks/framework.BzDBnRMZ.js";const g
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> len</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(name) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">></span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config.marshoai_nickname_limit:</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> nickname_cmd.finish(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'昵称超出长度限制:'</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> +</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(config.marshoai_nickname_limit))</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> set_nickname(user_id, name)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> nickname_cmd.finish(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'已设置昵称为:'</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> name)</span></span></code></pre></div></details><hr><p><code>@refresh_data_cmd.handle()</code></p><h3 id="async-func-refresh-data" tabindex="-1"><em><strong>async func</strong></em> <code>refresh_data()</code> <a class="header-anchor" href="#async-func-refresh-data" aria-label="Permalink to "***async func*** \`refresh_data()\`""></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L183" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@refresh_data_cmd.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> nickname_cmd.finish(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'已设置昵称为:'</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> name)</span></span></code></pre></div></details><hr><p><code>@refresh_data_cmd.handle()</code></p><h3 id="async-func-refresh-data" tabindex="-1"><em><strong>async func</strong></em> <code>refresh_data()</code> <a class="header-anchor" href="#async-func-refresh-data" aria-label="Permalink to "***async func*** \`refresh_data()\`""></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L186" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@refresh_data_cmd.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> refresh_data</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">():</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> refresh_nickname_json()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> refresh_praises_json()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> refresh_data_cmd.finish(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'已刷新数据'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><hr><p><code>@marsho_help_cmd.handle()</code></p><h3 id="async-func-marsho-help" tabindex="-1"><em><strong>async func</strong></em> <code>marsho_help()</code> <a class="header-anchor" href="#async-func-marsho-help" aria-label="Permalink to "***async func*** \`marsho_help()\`""></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L190" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@marsho_help_cmd.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> refresh_data_cmd.finish(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'已刷新数据'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><hr><p><code>@marsho_help_cmd.handle()</code></p><h3 id="async-func-marsho-help" tabindex="-1"><em><strong>async func</strong></em> <code>marsho_help()</code> <a class="header-anchor" href="#async-func-marsho-help" aria-label="Permalink to "***async func*** \`marsho_help()\`""></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L193" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@marsho_help_cmd.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> marsho_help</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">():</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> marsho_help_cmd.finish(metadata.usage)</span></span></code></pre></div></details><hr><p><code>@marsho_status_cmd.handle()</code></p><h3 id="async-func-marsho-status-bot-bot" tabindex="-1"><em><strong>async func</strong></em> <code>marsho_status(bot: Bot)</code> <a class="header-anchor" href="#async-func-marsho-status-bot-bot" aria-label="Permalink to "***async func*** \`marsho_status(bot: Bot)\`""></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L195" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@marsho_status_cmd.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> marsho_help_cmd.finish(metadata.usage)</span></span></code></pre></div></details><hr><p><code>@marsho_status_cmd.handle()</code></p><h3 id="async-func-marsho-status-bot-bot" tabindex="-1"><em><strong>async func</strong></em> <code>marsho_status(bot: Bot)</code> <a class="header-anchor" href="#async-func-marsho-status-bot-bot" aria-label="Permalink to "***async func*** \`marsho_status(bot: Bot)\`""></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L198" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@marsho_status_cmd.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> marsho_status</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(bot: Bot):</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> marsho_status_cmd.finish(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'当前适配器:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">bot.adapter.get_name()</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">当前使用的模型:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">model_name</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">当前支持图片的模型:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">SUPPORT_IMAGE_MODELS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config.marshoai_additional_image_models)</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><hr><p><code>@marsho_at.handle()</code><code>@marsho_cmd.handle()</code></p><h3 id="async-func-marsho-target-msgtarget-event-event-bot-bot-state-t-state-matcher-matcher-text-optional-unimsg-none" tabindex="-1"><em><strong>async func</strong></em> <code>marsho(target: MsgTarget, event: Event, bot: Bot, state: T_State, matcher: Matcher, text: Optional[UniMsg] = None)</code> <a class="header-anchor" href="#async-func-marsho-target-msgtarget-event-event-bot-bot-state-t-state-matcher-matcher-text-optional-unimsg-none" aria-label="Permalink to "***async func*** \`marsho(target: MsgTarget, event: Event, bot: Bot, state: T_State, matcher: Matcher, text: Optional[UniMsg] = None)\`""></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L207" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@marsho_at.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> marsho_status_cmd.finish(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'当前适配器:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">bot.adapter.get_name()</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">当前使用的模型:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">model_name</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">当前支持图片的模型:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">SUPPORT_IMAGE_MODELS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config.marshoai_additional_image_models)</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><hr><p><code>@marsho_at.handle()</code><code>@marsho_cmd.handle()</code></p><h3 id="async-func-marsho-target-msgtarget-event-event-bot-bot-state-t-state-matcher-matcher-text-optional-unimsg-none" tabindex="-1"><em><strong>async func</strong></em> <code>marsho(target: MsgTarget, event: Event, bot: Bot, state: T_State, matcher: Matcher, text: Optional[UniMsg] = None)</code> <a class="header-anchor" href="#async-func-marsho-target-msgtarget-event-event-bot-bot-state-t-state-matcher-matcher-text-optional-unimsg-none" aria-label="Permalink to "***async func*** \`marsho(target: MsgTarget, event: Event, bot: Bot, state: T_State, matcher: Matcher, text: Optional[UniMsg] = None)\`""></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L210" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@marsho_at.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@marsho_cmd.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> marsho</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(target: MsgTarget, event: Event, bot: Bot, state: T_State, matcher: Matcher, text: Optional[UniMsg]</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> global</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> target_list</span></span>
|
||||
@ -102,10 +105,12 @@ import{_ as i,c as a,ae as n,o as h}from"./chunks/framework.BzDBnRMZ.js";const g
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> is_reasoning_model:</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> context_msg </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> [get_prompt()] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">+</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> context_msg</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> tools_lists </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> tools.tools_list </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">+</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> list</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">map</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">lambda</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> v: v.data(), get_function_calls().values()))</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'正在获取回答,模型:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">model_name</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> response </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> make_chat_openai(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">client</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">client, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">model_name</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">model_name, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">msg</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">context_msg </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">+</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> [UserMessage(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">content</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">usermsg).as_dict()], </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">tools</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">tools_lists </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> tools_lists </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">else</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> choice </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> response.choices[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> choice.message.tool_calls </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">!=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> None</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> and</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config.marshoai_fix_toolcalls:</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> choice.finish_reason </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> CompletionsFinishReason.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">TOOL_CALLS</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.info(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'完成原因:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">choice.finish_reason</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> choice.finish_reason </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">==</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> CompletionsFinishReason.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">STOPPED</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> context.append(UserMessage(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">content</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">usermsg).as_dict(), target.id, target.private)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> choice_msg_dict </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> choice.message.to_dict()</span></span>
|
||||
@ -174,13 +179,14 @@ import{_ as i,c as a,ae as n,o as h}from"./chunks/framework.BzDBnRMZ.js";const g
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> except</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> Exception</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> as</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> e:</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> UniMessage(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(e) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">+</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> suggest_solution(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(e))).send()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> traceback.print_exc()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span></span></code></pre></div></details><hr><p><code>@poke_notify.handle()</code></p><h3 id="async-func-poke-event-event" tabindex="-1"><em><strong>async func</strong></em> <code>poke(event: Event)</code> <a class="header-anchor" href="#async-func-poke-event-event" aria-label="Permalink to "***async func*** \`poke(event: Event)\`""></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L441" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@poke_notify.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span></span></code></pre></div></details><hr><p><code>@poke_notify.handle()</code></p><h3 id="async-func-poke-event-event" tabindex="-1"><em><strong>async func</strong></em> <code>poke(event: Event)</code> <a class="header-anchor" href="#async-func-poke-event-event" aria-label="Permalink to "***async func*** \`poke(event: Event)\`""></a></h3><details><summary><b>源代码</b> 或 <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L446" target="_blank">在GitHub上查看</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@poke_notify.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> poke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(event: Event):</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> user_id </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> event.get_user_id()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> nicknames </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_nicknames()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> user_nickname </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> nicknames.get(user_id, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">''</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> try</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config.marshoai_poke_suffix </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">!=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ''</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.info(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'收到戳一戳,用户昵称:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">user_nickname</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">,用户ID:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">user_id</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> response </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> make_chat_openai(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">client</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">client, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">model_name</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">model_name, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">msg</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">[get_prompt() </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> model_name.lower() </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">not</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> in</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> NO_SYSPROMPT_MODELS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> else</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, UserMessage(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">content</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'*</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">user_nickname</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">config.marshoai_poke_suffix</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)])</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> choice </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> response.choices[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> choice.finish_reason </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">==</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> CompletionsFinishReason.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">STOPPED</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
|
||||
@ -188,4 +194,4 @@ import{_ as i,c as a,ae as n,o as h}from"./chunks/framework.BzDBnRMZ.js";const g
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> except</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> Exception</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> as</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> e:</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> UniMessage(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(e) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">+</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> suggest_solution(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(e))).send()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> traceback.print_exc()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span></span></code></pre></div></details><h3 id="var-text" tabindex="-1">var <code>text</code> <a class="header-anchor" href="#var-text" aria-label="Permalink to "var \`text\`""></a></h3><ul><li><p><strong>说明</strong>: type: ignore</p></li><li><p><strong>默认值</strong>: <code>event.get_message()</code></p></li></ul><h3 id="var-request-msg" tabindex="-1">var <code>request_msg</code> <a class="header-anchor" href="#var-request-msg" aria-label="Permalink to "var \`request_msg\`""></a></h3><ul><li><p><strong>说明</strong>: type: ignore</p></li><li><p><strong>默认值</strong>: <code>context_msg + [UserMessage(content=usermsg).as_dict()] + tool_msg</code></p></li></ul>`,64)]))}const y=i(t,[["render",k]]);export{g as __pageData,y as default};
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span></span></code></pre></div></details><h3 id="var-text" tabindex="-1">var <code>text</code> <a class="header-anchor" href="#var-text" aria-label="Permalink to "var \`text\`""></a></h3><ul><li><p><strong>说明</strong>: type: ignore</p></li><li><p><strong>默认值</strong>: <code>event.get_message()</code></p></li></ul><h3 id="var-request-msg" tabindex="-1">var <code>request_msg</code> <a class="header-anchor" href="#var-request-msg" aria-label="Permalink to "var \`request_msg\`""></a></h3><ul><li><p><strong>说明</strong>: type: ignore</p></li><li><p><strong>默认值</strong>: <code>context_msg + [UserMessage(content=usermsg).as_dict()] + tool_msg</code></p></li></ul>`,64)]))}const y=i(t,[["render",k]]);export{d as __pageData,y as default};
|
@ -1 +1 @@
|
||||
import{_ as i,c as a,ae as n,o as h}from"./chunks/framework.BzDBnRMZ.js";const g=JSON.parse('{"title":"marsho","description":"","frontmatter":{"title":"marsho","order":100},"headers":[],"relativePath":"dev/api/marsho.md","filePath":"zh/dev/api/marsho.md","lastUpdated":null}'),t={name:"dev/api/marsho.md"};function k(l,s,e,p,E,r){return h(),a("div",null,s[0]||(s[0]=[n("",64)]))}const y=i(t,[["render",k]]);export{g as __pageData,y as default};
|
||||
import{_ as i,c as a,ae as n,o as h}from"./chunks/framework.BzDBnRMZ.js";const d=JSON.parse('{"title":"marsho","description":"","frontmatter":{"title":"marsho","order":100},"headers":[],"relativePath":"dev/api/marsho.md","filePath":"zh/dev/api/marsho.md","lastUpdated":null}'),t={name:"dev/api/marsho.md"};function k(l,s,e,p,E,r){return h(),a("div",null,s[0]||(s[0]=[n("",64)]))}const y=i(t,[["render",k]]);export{d as __pageData,y as default};
|
@ -1,4 +1,4 @@
|
||||
import{_ as i,c as a,ae as n,o as h}from"./chunks/framework.BzDBnRMZ.js";const g=JSON.parse('{"title":"marsho","description":"","frontmatter":{"title":"marsho","order":100},"headers":[],"relativePath":"en/dev/api/marsho.md","filePath":"en/dev/api/marsho.md","lastUpdated":null}'),t={name:"en/dev/api/marsho.md"};function k(l,s,e,p,r,E){return h(),a("div",null,s[0]||(s[0]=[n(`<h1 id="module-nonebot-plugin-marshoai-marsho" tabindex="-1"><strong>Module</strong> <code>nonebot_plugin_marshoai.marsho</code> <a class="header-anchor" href="#module-nonebot-plugin-marshoai-marsho" aria-label="Permalink to "**Module** \`nonebot_plugin_marshoai.marsho\`""></a></h1><hr><h3 id="async-func-at-enable" tabindex="-1"><em><strong>async func</strong></em> <code>at_enable()</code> <a class="header-anchor" href="#async-func-at-enable" aria-label="Permalink to "***async func*** \`at_enable()\`""></a></h3><details><summary><b>Source code</b> or <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L35" target="_blank">View on GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> at_enable</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">():</span></span>
|
||||
import{_ as i,c as a,ae as n,o as h}from"./chunks/framework.BzDBnRMZ.js";const g=JSON.parse('{"title":"marsho","description":"","frontmatter":{"title":"marsho","order":100},"headers":[],"relativePath":"en/dev/api/marsho.md","filePath":"en/dev/api/marsho.md","lastUpdated":null}'),t={name:"en/dev/api/marsho.md"};function k(l,s,e,p,E,r){return h(),a("div",null,s[0]||(s[0]=[n(`<h1 id="module-nonebot-plugin-marshoai-marsho" tabindex="-1"><strong>Module</strong> <code>nonebot_plugin_marshoai.marsho</code> <a class="header-anchor" href="#module-nonebot-plugin-marshoai-marsho" aria-label="Permalink to "**Module** \`nonebot_plugin_marshoai.marsho\`""></a></h1><hr><h3 id="async-func-at-enable" tabindex="-1"><em><strong>async func</strong></em> <code>at_enable()</code> <a class="header-anchor" href="#async-func-at-enable" aria-label="Permalink to "***async func*** \`at_enable()\`""></a></h3><details><summary><b>Source code</b> or <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L35" target="_blank">View on GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> at_enable</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">():</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config.marshoai_at</span></span></code></pre></div></details><hr><p><code>@add_usermsg_cmd.handle()</code></p><h3 id="async-func-add-usermsg-target-msgtarget-arg-message-commandarg" tabindex="-1"><em><strong>async func</strong></em> <code>add_usermsg(target: MsgTarget, arg: Message = CommandArg())</code> <a class="header-anchor" href="#async-func-add-usermsg-target-msgtarget-arg-message-commandarg" aria-label="Permalink to "***async func*** \`add_usermsg(target: MsgTarget, arg: Message = CommandArg())\`""></a></h3><details><summary><b>Source code</b> or <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L95" target="_blank">View on GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@add_usermsg_cmd.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> add_usermsg</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(target: MsgTarget, arg: Message</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">CommandArg()):</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (msg </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> arg.extract_plain_text()):</span></span>
|
||||
@ -30,13 +30,16 @@ import{_ as i,c as a,ae as n,o as h}from"./chunks/framework.BzDBnRMZ.js";const g
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> resetmem</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(target: MsgTarget):</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> [target.id, target.private] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">not</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> target_list:</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> target_list.append([target.id, target.private])</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> backup_context </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_backup_context(target.id, target.private)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> backup_context:</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> context.set_context(backup_context, target.id, target.private)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> context.reset(target.id, target.private)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> resetmem_cmd.finish(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'上下文已重置'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><hr><p><code>@changemodel_cmd.handle()</code></p><h3 id="async-func-changemodel-arg-message-commandarg" tabindex="-1"><em><strong>async func</strong></em> <code>changemodel(arg: Message = CommandArg())</code> <a class="header-anchor" href="#async-func-changemodel-arg-message-commandarg" aria-label="Permalink to "***async func*** \`changemodel(arg: Message = CommandArg())\`""></a></h3><details><summary><b>Source code</b> or <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L155" target="_blank">View on GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@changemodel_cmd.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> resetmem_cmd.finish(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'上下文已重置'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><hr><p><code>@changemodel_cmd.handle()</code></p><h3 id="async-func-changemodel-arg-message-commandarg" tabindex="-1"><em><strong>async func</strong></em> <code>changemodel(arg: Message = CommandArg())</code> <a class="header-anchor" href="#async-func-changemodel-arg-message-commandarg" aria-label="Permalink to "***async func*** \`changemodel(arg: Message = CommandArg())\`""></a></h3><details><summary><b>Source code</b> or <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L158" target="_blank">View on GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@changemodel_cmd.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> changemodel</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(arg: Message</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">CommandArg()):</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> global</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> model_name</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (model </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> arg.extract_plain_text()):</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> model_name </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> model</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> changemodel_cmd.finish(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'已切换'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><hr><p><code>@nickname_cmd.handle()</code></p><h3 id="async-func-nickname-event-event-name-none" tabindex="-1"><em><strong>async func</strong></em> <code>nickname(event: Event, name = None)</code> <a class="header-anchor" href="#async-func-nickname-event-event-name-none" aria-label="Permalink to "***async func*** \`nickname(event: Event, name = None)\`""></a></h3><details><summary><b>Source code</b> or <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L163" target="_blank">View on GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@nickname_cmd.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> changemodel_cmd.finish(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'已切换'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><hr><p><code>@nickname_cmd.handle()</code></p><h3 id="async-func-nickname-event-event-name-none" tabindex="-1"><em><strong>async func</strong></em> <code>nickname(event: Event, name = None)</code> <a class="header-anchor" href="#async-func-nickname-event-event-name-none" aria-label="Permalink to "***async func*** \`nickname(event: Event, name = None)\`""></a></h3><details><summary><b>Source code</b> or <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L166" target="_blank">View on GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@nickname_cmd.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> nickname</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(event: Event, name</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> nicknames </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_nicknames()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> user_id </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> event.get_user_id()</span></span>
|
||||
@ -51,15 +54,15 @@ import{_ as i,c as a,ae as n,o as h}from"./chunks/framework.BzDBnRMZ.js";const g
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> len</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(name) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">></span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config.marshoai_nickname_limit:</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> nickname_cmd.finish(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'昵称超出长度限制:'</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> +</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(config.marshoai_nickname_limit))</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> set_nickname(user_id, name)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> nickname_cmd.finish(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'已设置昵称为:'</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> name)</span></span></code></pre></div></details><hr><p><code>@refresh_data_cmd.handle()</code></p><h3 id="async-func-refresh-data" tabindex="-1"><em><strong>async func</strong></em> <code>refresh_data()</code> <a class="header-anchor" href="#async-func-refresh-data" aria-label="Permalink to "***async func*** \`refresh_data()\`""></a></h3><details><summary><b>Source code</b> or <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L183" target="_blank">View on GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@refresh_data_cmd.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> nickname_cmd.finish(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'已设置昵称为:'</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> name)</span></span></code></pre></div></details><hr><p><code>@refresh_data_cmd.handle()</code></p><h3 id="async-func-refresh-data" tabindex="-1"><em><strong>async func</strong></em> <code>refresh_data()</code> <a class="header-anchor" href="#async-func-refresh-data" aria-label="Permalink to "***async func*** \`refresh_data()\`""></a></h3><details><summary><b>Source code</b> or <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L186" target="_blank">View on GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@refresh_data_cmd.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> refresh_data</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">():</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> refresh_nickname_json()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> refresh_praises_json()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> refresh_data_cmd.finish(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'已刷新数据'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><hr><p><code>@marsho_help_cmd.handle()</code></p><h3 id="async-func-marsho-help" tabindex="-1"><em><strong>async func</strong></em> <code>marsho_help()</code> <a class="header-anchor" href="#async-func-marsho-help" aria-label="Permalink to "***async func*** \`marsho_help()\`""></a></h3><details><summary><b>Source code</b> or <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L190" target="_blank">View on GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@marsho_help_cmd.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> refresh_data_cmd.finish(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'已刷新数据'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><hr><p><code>@marsho_help_cmd.handle()</code></p><h3 id="async-func-marsho-help" tabindex="-1"><em><strong>async func</strong></em> <code>marsho_help()</code> <a class="header-anchor" href="#async-func-marsho-help" aria-label="Permalink to "***async func*** \`marsho_help()\`""></a></h3><details><summary><b>Source code</b> or <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L193" target="_blank">View on GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@marsho_help_cmd.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> marsho_help</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">():</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> marsho_help_cmd.finish(metadata.usage)</span></span></code></pre></div></details><hr><p><code>@marsho_status_cmd.handle()</code></p><h3 id="async-func-marsho-status-bot-bot" tabindex="-1"><em><strong>async func</strong></em> <code>marsho_status(bot: Bot)</code> <a class="header-anchor" href="#async-func-marsho-status-bot-bot" aria-label="Permalink to "***async func*** \`marsho_status(bot: Bot)\`""></a></h3><details><summary><b>Source code</b> or <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L195" target="_blank">View on GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@marsho_status_cmd.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> marsho_help_cmd.finish(metadata.usage)</span></span></code></pre></div></details><hr><p><code>@marsho_status_cmd.handle()</code></p><h3 id="async-func-marsho-status-bot-bot" tabindex="-1"><em><strong>async func</strong></em> <code>marsho_status(bot: Bot)</code> <a class="header-anchor" href="#async-func-marsho-status-bot-bot" aria-label="Permalink to "***async func*** \`marsho_status(bot: Bot)\`""></a></h3><details><summary><b>Source code</b> or <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L198" target="_blank">View on GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@marsho_status_cmd.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> marsho_status</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(bot: Bot):</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> marsho_status_cmd.finish(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'当前适配器:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">bot.adapter.get_name()</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">当前使用的模型:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">model_name</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">当前支持图片的模型:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">SUPPORT_IMAGE_MODELS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config.marshoai_additional_image_models)</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><hr><p><code>@marsho_at.handle()</code><code>@marsho_cmd.handle()</code></p><h3 id="async-func-marsho-target-msgtarget-event-event-bot-bot-state-t-state-matcher-matcher-text-optional-unimsg-none" tabindex="-1"><em><strong>async func</strong></em> <code>marsho(target: MsgTarget, event: Event, bot: Bot, state: T_State, matcher: Matcher, text: Optional[UniMsg] = None)</code> <a class="header-anchor" href="#async-func-marsho-target-msgtarget-event-event-bot-bot-state-t-state-matcher-matcher-text-optional-unimsg-none" aria-label="Permalink to "***async func*** \`marsho(target: MsgTarget, event: Event, bot: Bot, state: T_State, matcher: Matcher, text: Optional[UniMsg] = None)\`""></a></h3><details><summary><b>Source code</b> or <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L207" target="_blank">View on GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@marsho_at.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> marsho_status_cmd.finish(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'当前适配器:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">bot.adapter.get_name()</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">当前使用的模型:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">model_name</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}\\n</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">当前支持图片的模型:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">SUPPORT_IMAGE_MODELS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config.marshoai_additional_image_models)</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div></details><hr><p><code>@marsho_at.handle()</code><code>@marsho_cmd.handle()</code></p><h3 id="async-func-marsho-target-msgtarget-event-event-bot-bot-state-t-state-matcher-matcher-text-optional-unimsg-none" tabindex="-1"><em><strong>async func</strong></em> <code>marsho(target: MsgTarget, event: Event, bot: Bot, state: T_State, matcher: Matcher, text: Optional[UniMsg] = None)</code> <a class="header-anchor" href="#async-func-marsho-target-msgtarget-event-event-bot-bot-state-t-state-matcher-matcher-text-optional-unimsg-none" aria-label="Permalink to "***async func*** \`marsho(target: MsgTarget, event: Event, bot: Bot, state: T_State, matcher: Matcher, text: Optional[UniMsg] = None)\`""></a></h3><details><summary><b>Source code</b> or <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L210" target="_blank">View on GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@marsho_at.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@marsho_cmd.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> marsho</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(target: MsgTarget, event: Event, bot: Bot, state: T_State, matcher: Matcher, text: Optional[UniMsg]</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">):</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> global</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> target_list</span></span>
|
||||
@ -102,10 +105,12 @@ import{_ as i,c as a,ae as n,o as h}from"./chunks/framework.BzDBnRMZ.js";const g
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> is_reasoning_model:</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> context_msg </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> [get_prompt()] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">+</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> context_msg</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> tools_lists </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> tools.tools_list </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">+</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> list</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">map</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">lambda</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> v: v.data(), get_function_calls().values()))</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.debug(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'正在获取回答,模型:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">model_name</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> response </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> make_chat_openai(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">client</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">client, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">model_name</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">model_name, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">msg</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">context_msg </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">+</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> [UserMessage(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">content</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">usermsg).as_dict()], </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">tools</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">tools_lists </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> tools_lists </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">else</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> choice </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> response.choices[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> choice.message.tool_calls </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">!=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> None</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> and</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config.marshoai_fix_toolcalls:</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> choice.finish_reason </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> CompletionsFinishReason.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">TOOL_CALLS</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.info(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'完成原因:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">choice.finish_reason</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> choice.finish_reason </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">==</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> CompletionsFinishReason.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">STOPPED</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> context.append(UserMessage(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">content</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">usermsg).as_dict(), target.id, target.private)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> choice_msg_dict </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> choice.message.to_dict()</span></span>
|
||||
@ -174,13 +179,14 @@ import{_ as i,c as a,ae as n,o as h}from"./chunks/framework.BzDBnRMZ.js";const g
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> except</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> Exception</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> as</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> e:</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> UniMessage(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(e) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">+</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> suggest_solution(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">str</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(e))).send()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> traceback.print_exc()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span></span></code></pre></div></details><hr><p><code>@poke_notify.handle()</code></p><h3 id="async-func-poke-event-event" tabindex="-1"><em><strong>async func</strong></em> <code>poke(event: Event)</code> <a class="header-anchor" href="#async-func-poke-event-event" aria-label="Permalink to "***async func*** \`poke(event: Event)\`""></a></h3><details><summary><b>Source code</b> or <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L441" target="_blank">View on GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@poke_notify.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> return</span></span></code></pre></div></details><hr><p><code>@poke_notify.handle()</code></p><h3 id="async-func-poke-event-event" tabindex="-1"><em><strong>async func</strong></em> <code>poke(event: Event)</code> <a class="header-anchor" href="#async-func-poke-event-event" aria-label="Permalink to "***async func*** \`poke(event: Event)\`""></a></h3><details><summary><b>Source code</b> or <a href="https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/marsho.py#L446" target="_blank">View on GitHub</a></summary><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">@poke_notify.handle</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> poke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(event: Event):</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> user_id </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> event.get_user_id()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> nicknames </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> get_nicknames()</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> user_nickname </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> nicknames.get(user_id, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">''</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> try</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> config.marshoai_poke_suffix </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">!=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ''</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> logger.info(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'收到戳一戳,用户昵称:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">user_nickname</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">,用户ID:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">user_id</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> response </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> await</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> make_chat_openai(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">client</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">client, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">model_name</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">model_name, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">msg</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">[get_prompt() </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> model_name.lower() </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">not</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> in</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> NO_SYSPROMPT_MODELS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> else</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> None</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, UserMessage(</span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70;">content</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'*</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">user_nickname</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">config.marshoai_poke_suffix</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)])</span></span>
|
||||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> choice </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> response.choices[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
|
||||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> choice.finish_reason </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">==</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> CompletionsFinishReason.</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">STOPPED</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
|
@ -1 +1 @@
|
||||
import{_ as i,c as a,ae as n,o as h}from"./chunks/framework.BzDBnRMZ.js";const g=JSON.parse('{"title":"marsho","description":"","frontmatter":{"title":"marsho","order":100},"headers":[],"relativePath":"en/dev/api/marsho.md","filePath":"en/dev/api/marsho.md","lastUpdated":null}'),t={name:"en/dev/api/marsho.md"};function k(l,s,e,p,r,E){return h(),a("div",null,s[0]||(s[0]=[n("",64)]))}const y=i(t,[["render",k]]);export{g as __pageData,y as default};
|
||||
import{_ as i,c as a,ae as n,o as h}from"./chunks/framework.BzDBnRMZ.js";const g=JSON.parse('{"title":"marsho","description":"","frontmatter":{"title":"marsho","order":100},"headers":[],"relativePath":"en/dev/api/marsho.md","filePath":"en/dev/api/marsho.md","lastUpdated":null}'),t={name:"en/dev/api/marsho.md"};function k(l,s,e,p,E,r){return h(),a("div",null,s[0]||(s[0]=[n("",64)]))}const y=i(t,[["render",k]]);export{g as __pageData,y as default};
|
Reference in New Issue
Block a user