fix: fix command reply_message error bug,del some print

This commit is contained in:
Dong_master
2025-08-12 20:54:47 +08:00
parent b6d47187f5
commit 4668db716a
4 changed files with 20 additions and 20 deletions

View File

@@ -7,6 +7,9 @@ import asyncio
from ...platform.types import events as platform_events
from ...platform.types import message as platform_message
from ...provider import entities as llm_entities
from .. import stage, entities
from ...core import entities as core_entities
@@ -37,9 +40,9 @@ class SendResponseBackStage(stage.PipelineStage):
quote_origin = query.pipeline_config['output']['misc']['quote-origin']
# has_chunks = any(isinstance(msg, llm_entities.MessageChunk) for msg in query.resp_messages)
has_chunks = any(isinstance(msg, llm_entities.MessageChunk) for msg in query.resp_messages)
# TODO 命令与流式的兼容性问题
if await query.adapter.is_stream_output_supported():
if await query.adapter.is_stream_output_supported() and has_chunks:
is_final = [msg.is_final for msg in query.resp_messages][0]
await query.adapter.reply_message_chunk(
message_source=query.message_event,

View File

@@ -109,9 +109,9 @@ class WebChatAdapter(msadapter.MessagePlatformAdapter):
# notify waiter
if isinstance(message_source, platform_events.FriendMessage):
self.webchat_person_session.resp_queues[message_source.message_chain.message_id].put(message_data)
await self.webchat_person_session.resp_queues[message_source.message_chain.message_id].put(message_data)
elif isinstance(message_source, platform_events.GroupMessage):
self.webchat_group_session.resp_queues[message_source.message_chain.message_id].put(message_data)
await self.webchat_group_session.resp_queues[message_source.message_chain.message_id].put(message_data)
return message_data.model_dump()
@@ -264,24 +264,22 @@ class WebChatAdapter(msadapter.MessagePlatformAdapter):
# waiter = asyncio.Future[WebChatMessage]()
# use_session.resp_waiters[message_id] = waiter
# # waiter.add_done_callback(lambda future: use_session.resp_waiters.pop(message_id))
#
# resp_message = await waiter
#
# resp_message.id = len(use_session.get_message_list(pipeline_uuid)) + 1
#
# use_session.get_message_list(pipeline_uuid).append(resp_message)
#
# yield resp_message.model_dump()
msg_id = len(use_session.get_message_list(pipeline_uuid)) + 1
queue = use_session.resp_queues[message_id]
while True:
resp_message = await queue.get()
resp_message.id = msg_id
if resp_message.is_final:
resp_message.id = msg_id
use_session.get_message_list(pipeline_uuid).append(resp_message)
yield resp_message.model_dump()
break
yield resp_message.model_dump()
resp_message = await queue.get()
resp_message.id = msg_id
resp_message.is_final = True
yield resp_message.model_dump()
def get_webchat_messages(self, pipeline_uuid: str, session_type: str) -> list[dict]:
"""获取调试消息历史"""

View File

@@ -36,7 +36,7 @@ class ModelScopeChatCompletions(requester.ProviderAPIRequester):
self,
args: dict,
extra_body: dict = {},
remove_think:bool = False,
remove_think: bool = False,
) -> chat_completion.ChatCompletion:
args['stream'] = True
@@ -291,7 +291,6 @@ class ModelScopeChatCompletions(requester.ProviderAPIRequester):
# 处理工具调用增量
if delta.get('tool_calls'):
print(delta.get('tool_calls'))
for tool_call in delta['tool_calls']:
if tool_call['id'] != '':
tool_id = tool_call['id']

View File

@@ -226,7 +226,7 @@ class LocalAgentRunner(runner.RequestRunner):
# 第一次请求工具调用时的内容
if msg_idx == 1:
accumulated_content =first_content if first_content is not None else accumulated_content
accumulated_content = first_content if first_content is not None else accumulated_content
# 累积内容
if msg.content: