mirror of
https://github.com/FuQuan233/nonebot-plugin-llmchat.git
synced 2025-09-04 18:30:43 +00:00
✨ send reasoning content via forward message
This commit is contained in:
parent
ede61a028a
commit
df8944ec73
1 changed files with 28 additions and 1 deletions
|
@ -16,6 +16,7 @@ from nonebot import (
|
|||
on_command,
|
||||
on_message,
|
||||
require,
|
||||
get_bot,
|
||||
)
|
||||
from nonebot.adapters.onebot.v11 import GroupMessageEvent, Message
|
||||
from nonebot.adapters.onebot.v11.permission import GROUP_ADMIN, GROUP_OWNER
|
||||
|
@ -125,6 +126,29 @@ def format_message(event: GroupMessageEvent) -> str:
|
|||
return json.dumps(message, ensure_ascii=False)
|
||||
|
||||
|
||||
def build_reasoning_forward_nodes(self_id: str, reasoning_content: str):
|
||||
self_nickname = next(iter(driver.config.nickname))
|
||||
nodes = [
|
||||
{
|
||||
"type": "node",
|
||||
"data": {
|
||||
"name": self_nickname,
|
||||
"uin": self_id,
|
||||
"content": f"{self_nickname}的内心OS:",
|
||||
},
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"data": {
|
||||
"name": self_nickname,
|
||||
"uin": self_id,
|
||||
"content": reasoning_content,
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
return nodes
|
||||
|
||||
async def is_triggered(event: GroupMessageEvent) -> bool:
|
||||
"""扩展后的消息处理规则"""
|
||||
|
||||
|
@ -245,7 +269,10 @@ async def process_messages(group_id: int):
|
|||
)
|
||||
|
||||
if state.output_reasoning_content and reasoning_content:
|
||||
await handler.send(Message(reasoning_content))
|
||||
bot = get_bot(str(event.self_id))
|
||||
await bot.send_group_forward_msg(
|
||||
group_id=group_id, messages=build_reasoning_forward_nodes(bot.self_id,reasoning_content)
|
||||
)
|
||||
|
||||
assert reply is not None
|
||||
logger.info(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue