white-room-9349
12/30/2025, 3:27 PMtall-airline-16756
12/30/2025, 3:27 PMtall-airline-16756
12/30/2025, 3:27 PMllm_node and stream the LLM output yourself. Inside your custom llm_node you can inspect, modify, filter, log, or replace text chunks as they arrive, then yield those (possibly modified) chunks so they continue to the TTS stage.
Minimal example:
async def llm_node(self, chat_ctx, tools, model_settings=None):
async def process_stream():
async with self.llm.chat(chat_ctx=chat_ctx, tools=tools, tool_choice=None) as stream:
async for chunk in stream:
if chunk is None:
continue
content = getattr(chunk.delta, 'content', None) if hasattr(chunk, 'delta') else str(chunk)
if content is None:
yield chunk
continue
# Intercept/modify text here
processed = content.replace("undesirable text", "")
# If chunk object holds content, update it; otherwise replace chunk
if hasattr(chunk, 'delta') and hasattr(chunk.delta, 'content'):
chunk.delta.content = processed
else:
chunk = processed
yield chunk
return process_stream()
If you want, tell me:
• Which agent framework/version you’re using,
• Whether you need synchronous blocking or streaming behavior,
• Any specific modifications (filtering, censorship, markup, logging),
and I’ll provide a tailored snippet or integration notes.
Sources: Pipeline nodes and hooks | LiveKit docs | Modifying LLM output before TTS | LiveKit docs | LLM Output Replacement | LiveKit docs