【NVIDIA AIQ】自定义函数实践

NVIDIA Agent Intelligence Toolkit自定义函数实践

定义工具函数

python 复制代码
import logging

from pydantic import BaseModel
from pydantic import Field
from pydantic import HttpUrl

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

logger = logging.getLogger(__name__)

# 工具类
class CustomToolConfig(FunctionBaseConfig, name="custom_tool"):
    """ 测试自定义工具调用 """
    

# 注册工具函数
@register_function(config_type=CustomToolConfig)
async def custom_tool(config: CustomToolConfig, builder: Builder):

  	# 工具函数逻辑处理
    async def _custom_tool_test(text: str) -> str:
        return '这是一个自定义工具调用测试${text}'

    # 逻辑导出调用
    yield FunctionInfo.from_fn(
        _custom_tool_test,
        description="这是一个自定义工具调用测试",
    )

注册: 工具导出

  • aiq/tool/register.py
python 复制代码
from . import custom_tool

配置引用

yaml 复制代码
# NVIDIA NeMo Agent Toolkit 黑客松配置
# 支持用户自定义OpenAI兼容API

general:
  use_uvloop: true

functions:
  custom_tool:
    _type: custom_tool
    description: "自定义工具测试"

workflow:
  _type: react_agent
  tool_names:
    - custom_tool
  llm_name: default_llm
  verbose: true
  parse_agent_response_max_retries: 3
  max_iterations: 10

测试验证

输入关键字,触发AI调用

终端调用打印

参考资源

NVIDIA Agent Intelligence Toolkit

Custom Functions

相关推荐
EnCi Zheng9 小时前
09aaab-Softmax是什么?
人工智能
君为先-bey9 小时前
LeMiCa——基于扩散模型的高效视频生成的词典序最小化路径缓存
python·算法·机器学习·扩散模型
FAFU_kyp9 小时前
拼好设 UI 视觉快速搭建方法
人工智能
治数有道9 小时前
【一号文深度解读(上)】财务级数据中台,不是财务主题域:央国企数据中台的范式纠偏
大数据·人工智能·业财融合·数智化转型·穿透式监管·财务级数据中台·一号文
jiayong239 小时前
harness 与 hermes-agent 运行原理和核心流程
人工智能·ai·智能体·harness·hermes-agent
L_cl9 小时前
大模型应用开发 9.FastAPI ① 请求与响应
python·fastapi
码海浮生9 小时前
人工智能日报 每日AI新闻(2026年5月25日):Google I/O余波下的AI安全、多模态生成与搜索体验分化
大数据·人工智能·安全
dingzd959 小时前
Pinterest年度色彩发布后跨境内容团队如何统一视觉风格与选题方向
大数据·人工智能·新媒体运营·市场营销·跨境
ting94520009 小时前
深度解析 Google Stitch 3.0:文本驱动跨端 UI 生成技术原理、架构与工程实现
人工智能·ui·架构
数字化转型202510 小时前
重构Sales Force AI Agent
人工智能·重构