Is it possible to adjust LLM settings mid-session?...
# ask-ai
a
Is it possible to adjust LLM settings mid-session? I allow users of my app to choose the verbosity level. I use this to prompt the LLM differently - but I also wanted to change the max tokens setting. Is that possible - can I update LLM settings mid session?
t
Thanks for reaching out, Matt. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Absolutely, you can adjust LLM settings like
max_tokens
right in the middle of a session with LiveKit. It’s pretty flexible! Using the Realtime API, you can easily update parameters on the fly—methods like
session_update
let you tweak things like
max_response_output_tokens
,
temperature
, and more while your session is still active. The best part is these changes usually take effect immediately, so there’s no need to restart your session. If you have any questions about this, I’m here to help! Sources: agent/main.py | livekit-plugins/livekit-plugins-google/livekit/plugins/google/realtime/real...
a
I'm using the AWS Bedrock plugin
t
Thanks for reaching out! I wanted to share that when you're using the AWS Bedrock plugin, the LLM settings like
max_tokens
are set up during the initial creation of the LLM instance. Unfortunately, these settings can't be changed in the middle of a session. But don’t worry—if you want to update these parameters, you can simply create a new LLM instance with the changes, and it will work for your next requests. I’m here if you have any more questions or need a hand with this! Sources: livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realti... | Amazon Bedrock LLM plugin guide | LiveKit docs
a
How do I create a new LLM instance and update the agent to use it in this way mid session? Can you show me some example code?
t
Thanks for reaching out! To make sure I fully understand and can help you best with creating a new LLM instance and updating the agent mid-session, could you please clarify a few things? • Are you working with the standard LLM interface or the Realtime model? • Are you hoping to switch models based on user input, the context, or some other trigger? • Is it important for you to keep the conversation state intact when changing the LLM? Sources: Amazon Bedrock LLM plugin guide | LiveKit docs
a
Standard LLM. I want to adjust max output token parameter (we allow user to set this during a conversation) - and yes I want conversation state to remain intact - and I also do not want to introduce additional latency when I do this.
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!
a
can we use update_agent() and pass in a new agent with the updated LLM during an agent session?