helpful-author-83080
09/06/2025, 9:28 PMtall-airline-16756
09/06/2025, 9:29 PMtall-airline-16756
09/06/2025, 9:29 PMfunction_tool() with raw_schema, the key is to define all your parameters inside the parameters field of the raw_schema dictionary. Then, you can grab these parameters from the raw_arguments dictionary in your function handler.
Here’s a friendly step-by-step:
• Start by defining each parameter in the parameters > properties section of the raw_schema. For example, you might include things like city and units.
• When you’re inside your function handler, access these parameters using raw_arguments["parameter_name"]. If a parameter is optional, you can use raw_arguments.get("parameter_name", "default_value") to set a fallback.
• Don’t forget to list any required parameters in the required array within the schema.
So, when the tool runs, it reads the JSON object that matches your schema and hands it over as the raw_arguments dictionary to your function. This way, you can easily manage multiple arguments without any fuss.
Sources: Tool definition and use | LiveKit Docs | livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/llm.pyhelpful-author-83080
09/06/2025, 9:30 PMtall-airline-16756
09/06/2025, 9:31 PMraw_arguments, you can use the RunContext parameter in your function. This handy feature lets you tap into external info like session details or custom user data.
Here’s a simple way to do it:
• Add a context: RunContext parameter to your function signature. The framework automatically takes care of this, so the LLM won’t see it.
• Use the context.userdata property to save and grab custom data. For instance, you can set up userdata with your extra arguments when you start the agent session.
• Inside your function, access userdata or other session info to work with those additional arguments.
If you’d like me to walk you through an example or explain anything further, just give me a shout!
Sources: Tool definition and use | LiveKit Docs | Tool definition and use | LiveKit Docs