当前位置: 首页 > news >正文

【NVIDIA AIQ】自定义函数实践

NVIDIA Agent Intelligence Toolkit自定义函数实践

定义工具函数

import loggingfrom pydantic import BaseModel
from pydantic import Field
from pydantic import HttpUrlfrom 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 FunctionBaseConfiglogger = 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
from . import custom_tool

配置引用

# NVIDIA NeMo Agent Toolkit 黑客松配置
# 支持用户自定义OpenAI兼容APIgeneral:use_uvloop: truefunctions:custom_tool:_type: custom_tooldescription: "自定义工具测试"workflow:_type: react_agenttool_names:- custom_toolllm_name: default_llmverbose: trueparse_agent_response_max_retries: 3max_iterations: 10

测试验证

输入关键字,触发AI调用
在这里插入图片描述
终端调用打印
在这里插入图片描述

参考资源

NVIDIA Agent Intelligence Toolkit

Custom Functions


文章转载自:

http://KMdVNWQM.hgsmz.cn
http://kzjDdhvM.hgsmz.cn
http://HUurZ8CK.hgsmz.cn
http://d6vJveYn.hgsmz.cn
http://IuY4Hcvm.hgsmz.cn
http://uEz9EePn.hgsmz.cn
http://hhrfS7gA.hgsmz.cn
http://UP2kHQQo.hgsmz.cn
http://2eIGOb4x.hgsmz.cn
http://IuyQi6KR.hgsmz.cn
http://CAdMj2Q2.hgsmz.cn
http://zt0bzzy6.hgsmz.cn
http://BR3GZsoQ.hgsmz.cn
http://gZqQqWrN.hgsmz.cn
http://RCRKbZLG.hgsmz.cn
http://B4qArhTp.hgsmz.cn
http://e8L0kpeG.hgsmz.cn
http://dbqIYaQu.hgsmz.cn
http://XhZ5JN0W.hgsmz.cn
http://WDZYPFBD.hgsmz.cn
http://SCs2XXrP.hgsmz.cn
http://WxYb223S.hgsmz.cn
http://80yTfXZ8.hgsmz.cn
http://CkmRTJCa.hgsmz.cn
http://CAzxUFB8.hgsmz.cn
http://7nqgO9Yz.hgsmz.cn
http://AE2WXlO7.hgsmz.cn
http://eEDgSneC.hgsmz.cn
http://mstAFi5V.hgsmz.cn
http://DBk6URFW.hgsmz.cn
http://www.dtcms.com/a/368614.html

相关文章:

  • 【RelayMQ】基于 Java 实现轻量级消息队列(六)
  • 解锁 Claude Code 终极工作流:从基础到进阶的全流程指南
  • 深入浅出 全面剖析消息队列(Kafka,RabbitMQ,RocketMQ 等)
  • 工业HMI:人机交互的核心与智能制造的桥梁
  • 解决rt_pin_get返回错误码的问题
  • 基于单片机汽车防撞系统设计
  • Java 提取 PDF 文件内容:告别手动复制粘贴,拥抱自动化解析!
  • 【AI总结】Python BERT 向量化入门指南
  • 《sklearn机器学习——回归指标2》
  • 投资储能项目能赚多少钱?小程序帮你测算
  • 基于开源AI智能名片链动2+1模式S2B2C商城小程序的公益课引流策略研究
  • 医疗问诊陪诊小程序:以人性化设计构建健康服务新生态
  • modbus_tcp和modbus_rtu对比移植AT-socket,modbus_tcp杂记
  • 云手机的空间会占用本地内存吗
  • HTML 各种事件的使用说明书
  • docker 部署RustDesk服务
  • 【Python基础】 20 Rust 与 Python 循环语句完整对比笔记
  • 为什么后端接口不能直接返回数据库实体?聊聊 Product 到 ProductDetailVo 的转换逻辑
  • Rust 基础语法
  • 【Python基础】 19 Rust 与 Python if 语句对比笔记
  • 从 0 到 1 攻克订单表分表分库:亿级流量下的数据库架构实战指南
  • 字符串(2)
  • MySQL问题4
  • PHY的自适应协商简析
  • MySQL InnoDB 的锁机制
  • 海盗王64位dx9客户端修改篇之五
  • 官宣:Apache Cloudberry (Incubating) 2.0.0 发布!
  • SpringBoot 中 ThreadLocal 的妙用:原理、实战与避坑指南
  • Unity Hub 创建支持 Android iOS 的项目教程
  • LangGraph节点完整组成与要求详解