delightful-air-266
02/27/2025, 5:04 PMgray-monkey-83525
02/27/2025, 5:04 PMVoicePipelineAgent
, you cannot directly set the llm
property because it does not have a setter. Instead, you can modify the LLM instance by using the before_llm_cb
callback to dynamically adjust the LLM configuration before each call. This allows you to inject a new LLM instance or modify the existing one as needed.
Here's a basic example of how you might implement this:
from livekit.agents import VoicePipelineAgent, llm
async def before_llm_cb(agent: VoicePipelineAgent, chat_ctx: llm.ChatContext):
# Create a new LLM instance or modify the existing one
new_llm = llm.LLM() # Replace with your LLM configuration
agent._llm = new_llm # Directly modify the internal attribute
agent = VoicePipelineAgent(
vad=your_vad_instance,
stt=your_stt_instance,
llm=initial_llm_instance,
tts=your_tts_instance,
before_llm_cb=before_llm_cb
)
Would you like more details on this approach?
Sources:
- https://livekit-users.slack.com/archives/C07FY8WHGPM/p1729785664.481519
- https://docs.livekit.io/agents-js/classes/agents.pipeline.VoicePipelineAgent.html 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.