clever-doctor-15083
02/15/2025, 2:28 PMgray-monkey-83525
02/15/2025, 2:28 PMclever-doctor-15083
02/15/2025, 2:29 PMgray-monkey-83525
02/15/2025, 2:29 PMbefore_llm_cb
callback. This allows you to adjust the context dynamically during the conversation.
Would you like more details on how to implement this?
Sources:
- LiveKit documentation 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.clever-doctor-15083
02/15/2025, 2:42 PMgray-monkey-83525
02/15/2025, 2:42 PMFunctionContext
dynamically. According to LiveKit documentation, you can modify the FunctionContext
to include different tools or functions as needed during the conversation. This can be done by setting voice_assistant.fnc_ctx
to a new FunctionContext
instance with the desired tools.
Would you like more detailed guidance on implementing this?
Sources:
- LiveKit documentation 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.clever-doctor-15083
02/15/2025, 2:44 PMgray-monkey-83525
02/15/2025, 2:45 PMFunctionContext
.
from livekit.agents import llm
from livekit.agents.pipeline import VoicePipelineAgent
# Define a custom FunctionContext with tools
class CustomFunctionContext(llm.FunctionContext):
@llm.ai_callable()
async def tool_one(self):
"""Tool one description."""
return "Tool one executed"
@llm.ai_callable()
async def tool_two(self):
"""Tool two description."""
return "Tool two executed"
# Initialize the agent with an initial FunctionContext
initial_fnc_ctx = CustomFunctionContext()
agent = VoicePipelineAgent(
fnc_ctx=initial_fnc_ctx,
# other parameters...
)
# Function to update the FunctionContext conditionally
def update_function_context(agent, condition):
if condition:
new_fnc_ctx = CustomFunctionContext()
# Add or modify tools based on the condition
agent.fnc_ctx = new_fnc_ctx
# Example usage
condition = True # This could be any condition based on your logic
update_function_context(agent, condition)
In this example, CustomFunctionContext
is defined with two tools, tool_one
and tool_two
. The update_function_context
function updates the agent's FunctionContext
based on a condition.
Would you like more information on this?
Sources:
- https://docs.livekit.io/sip/examples/sip-participant-attributes/
- https://livekit-users.slack.com/archives/C07FY8WHGPM/p1731463251.597929 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.clever-doctor-15083
02/15/2025, 2:53 PMclever-doctor-15083
02/15/2025, 2:53 PMgray-monkey-83525
02/15/2025, 2:53 PMgray-monkey-83525
02/16/2025, 2:04 PM