fix: trailing white spaces
This commit is contained in:
@@ -59,6 +59,13 @@ class ActiveNodeClientIO(NodeClientIO):
|
||||
self._input_result: str | None = None
|
||||
|
||||
async def emit_output(self, content: str, is_final: bool = False) -> None:
|
||||
# Strip leading whitespace from first output chunk to avoid leading spaces
|
||||
# (some LLMs like Kimi output leading whitespace before text)
|
||||
if not self._output_snapshot and content:
|
||||
content = content.lstrip()
|
||||
if not content: # Content was all whitespace
|
||||
return
|
||||
|
||||
self._output_snapshot += content
|
||||
await self._output_queue.put(content)
|
||||
|
||||
|
||||
@@ -3532,6 +3532,13 @@ class EventLoopNode(NodeProtocol):
|
||||
iteration: int | None = None,
|
||||
inner_turn: int = 0,
|
||||
) -> None:
|
||||
# Strip leading whitespace from first output chunk for client_facing nodes
|
||||
# (some LLMs like Kimi output leading whitespace before text)
|
||||
if ctx.node_spec.client_facing and not snapshot and content:
|
||||
content = content.lstrip()
|
||||
if not content: # Content was all whitespace
|
||||
return
|
||||
|
||||
return await publish_text_delta(
|
||||
event_bus=self._event_bus,
|
||||
stream_id=stream_id,
|
||||
|
||||
Reference in New Issue
Block a user