vtong
May 31, 2025, 6:25am
1
The NVIDIA Agent Intelligence toolkit is an open-source library for efficiently connecting, profiling and optimizing teams of AI agents. With it, developers can easily accelerate and evaluate enterprise-ready agentic AI systems.
Functions with Multiple Arguments
I have a question about Functions with Multiple Arguments. I defined function similar to this. But I have not idea. How to set the params in config.yml. I have no idea on the prompt and syntax. Can anyone teach me how to use Multiple Arguments?
Or does anyone know which examples/ has the sample code for my reference?
Thanks you so much.
slopp
June 11, 2025, 3:29pm
3
Hi @vtong - one way to do this is to pass the input as JSON, eg
aiq run --config_file … --input ‘{“input1”: “value1”, “input2”:“value2”}’
That input will then automatically be converted to the appropriate multi-argument input for your function. See Writing Custom Functions — NVIDIA Agent Intelligence Toolkit (1.1.0)
If you want more control over how the input is parsed into your function arguments you can create a converter, here is an example:
import logging
from pydantic import Field
from aiq.builder.builder import Builder
from aiq.builder.function_info import FunctionInfo
from aiq.cli.register_workflow import register_function
from aiq.data_models.function import FunctionBaseConfig
from pydantic import BaseModel
logger = logging.getLogger(__name__)
class RegistryExampleFunctionConfig(FunctionBaseConfig, name="registry_example"):
"""
AIQ Toolkit function template. Please update the description.
"""
# Add your custom configuration parameters here
parameter: str = Field(default="default_value", description="Notional description for this parameter")
class MyFunctionInput(BaseModel):
input1: str
input2: str
@register_function(config_type=RegistryExampleFunctionConfig)
async def registry_example_function(
config: RegistryExampleFunctionConfig, builder: Builder
):
# Implement your function logic here
async def _response_fn(input_message: MyFunctionInput) -> str:
# Process the input_message and generate output
output_message = f"{input_message.input1} and {input_message.input2}"
return output_message
def converter(input_message: str) -> MyFunctionInput:
return MyFunctionInput.model_validate_json(input_message)
try:
yield FunctionInfo.create(single_fn=_response_fn, converters=[converter])
except GeneratorExit:
print("Function exited early!")
finally:
print("Cleaning up registry_example workflow.")
For more info, Writing Custom Functions — NVIDIA Agent Intelligence Toolkit (1.1.0)
2 Likes
vtong
June 11, 2025, 10:42pm
4
Great! The key point is “–input ‘{“input1”: “value1”, “input2”:“value2”}’” 👍
system
Closed
June 25, 2025, 10:43pm
5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.