fix: chat处理过程的插件返回值目标错误

This commit is contained in:
RockChinQ 2024-03-20 23:32:28 +08:00
parent 0752698c1d
commit d0b0f2209a
3 changed files with 16 additions and 2 deletions

View File

@ -39,7 +39,14 @@ class ChatMessageHandler(handler.MessageHandler):
if event_ctx.is_prevented_default():
if event_ctx.event.reply is not None:
query.resp_message_chain = mirai.MessageChain(event_ctx.event.reply)
mc = mirai.MessageChain(event_ctx.event.reply)
query.resp_messages.append(
llm_entities.Message(
role='plugin',
content=str(mc),
)
)
yield entities.StageProcessResult(
result_type=entities.ResultType.CONTINUE,

View File

@ -29,6 +29,13 @@ class ResponseWrapper(stage.PipelineStage):
if query.resp_messages[-1].role == 'command':
query.resp_message_chain = mirai.MessageChain("[bot] "+query.resp_messages[-1].content)
yield entities.StageProcessResult(
result_type=entities.ResultType.CONTINUE,
new_query=query
)
elif query.resp_messages[-1].role == 'plugin':
query.resp_message_chain = mirai.MessageChain(query.resp_messages[-1].content)
yield entities.StageProcessResult(
result_type=entities.ResultType.CONTINUE,
new_query=query

View File

@ -22,7 +22,7 @@ class ToolCall(pydantic.BaseModel):
class Message(pydantic.BaseModel):
"""消息"""
role: str # user, system, assistant, tool, command
role: str # user, system, assistant, tool, command, plugin
name: typing.Optional[str] = None