How to trigger a function_tool using generate_repl...
# ask-ai
m
How to trigger a function_tool using generate_reply(tool_choice=) give a example
t
Thanks for reaching out, Rajadurai. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To help you trigger a function tool using
generate_reply(tool_choice=)
, you can specify the
tool_choice
parameter to guide how the LLM uses tools. Here are some friendly examples to get you started: • Auto Mode: This lets the LLM decide if a tool is needed based on the context.
await session.generate_reply(user_input="What's the weather like?", tool_choice="auto")
• Required Mode: This makes sure the LLM uses at least one function tool.
await session.generate_reply(user_input="Tell me about New York", tool_choice="required")
• None Mode: This turns off tool usage, so the LLM responds directly.
await session.generate_reply(user_input="What's the weather in Paris?", tool_choice="none")
• Specific Tool: This directs the LLM to use a particular tool.
await session.generate_reply(user_input="I want to know about the weather", tool_choice=ToolChoice(type="function", name="get_weather"))
If you have any questions or want me to walk you through more examples, just let me know—I’m here to help! Sources: OpenAI LLM plugin guide | LiveKit Docs | Azure OpenAI LLM plugin guide | LiveKit Docs | livekit-agents/livekit/agents/voice/agent_activity.py
m
where to import ToolChoice
t
Hey there! You can easily import
ToolChoice
like this: • In Python:
from livekit.agents.llm import ToolChoice
• In JavaScript:
import { ToolChoice } from 'livekit-agents';
If you have any questions or need a hand with anything else, just let me know—I’m here to help! Sources: livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realti... | plugins/google/src/llm.ts | OpenAI LLM plugin guide | LiveKit Docs