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

浅谈OpenAIClaude LLM Tools的额外配置

前言

  • https://platform.openai.com/docs/guides/function-calling?api-mode=chat&strict-mode=disabled#additional-configurations
  • https://docs.anthropic.com/en/docs/build-with-claude/tool-use/overview#forcing-tool-use

tool_choice

  1. “none” 就是不用tools, tools传入也为味空
  2. auto,就是可能调用tool,或者不调用,agent loop,很多写的范式都是,调用tool,就执行拿到结果进入下一个loop,如果不调用tool就直接
  3. required:必须使用其中一个到多个工具,这样的agentloop可能就是tools里有对应的类似于stopTool,调用到就agent ending
  4. forced function: 只调用一个特定tool。

claude也是一样的,就是传入参数 required 为any了

parallel_tool_calls

parallel_tool_calls = True的时候返回的ChatCompletionMessage中的choice.message.tool_calls有多个 toolcall

为False的时候, 只能每次调用一个tool

Strict mode

“strict”= true的时候更能保证json output的输出,这个参数感觉大家用的很少,实际上为true和false,对于tool的parameters写法很多都可以等价

比如:

{"type": "function","function": {"name": "get_weather","description": "Retrieves current weather for the given location.","parameters": {"type": "object","properties": {"location": {"type": "string","description": "City and country e.g. Bogotá, Colombia"},"units": {"type": "string","enum": ["celsius", "fahrenheit"],"description": "Units the temperature will be returned in."}},"required": ["location"],}}
}

这个是我们平时很爱写的写法,看到的基本上都是这种,只会把一定需要的参数写为required中,但openai的"strict"= true, 对type做一下修改是一样的效果

{"type": "function","function": {"name": "get_weather","description": "Retrieves current weather for the given location.","strict": true,"parameters": {"type": "object","properties": {"location": {"type": "string","description": "City and country e.g. Bogotá, Colombia"},"units": {"type": ["string", "null"],"enum": ["celsius", "fahrenheit"],"description": "Units the temperature will be returned in."}},"required": ["location", "units"],"additionalProperties": false}}
}

加入 "null"的type

http://www.xdnf.cn/news/2107.html

相关文章:

  • 计算机组成原理实验(1) 算术逻辑运算单元实验
  • Java 设计模式心法之第21篇 - 命令 (Command) - 将请求封装成对象,实现操作解耦与扩展
  • verilog中实现单周期cpu的RVM指令(乘除取模)
  • 登高架设作业证考试的实操项目有哪些?
  • 前端八股 2
  • 支持私有化部署的电子合同平台——一合通
  • 01.oracle SQL基础
  • 使用Go语言实现轻量级消息队列
  • Ubuntu系统卡机日志笔记
  • OpenHarmony 5.0设置锁屏密码失败
  • QuecPython+USBNET:实现USB网卡功能
  • 真.从“零”搞 VSCode+STM32CubeMx+C <2>调试+烧录
  • docker-compose安装RustDesk远程工具
  • 工业电子测量中的安全隐患与解决方案——差分探头的技术优势解析
  • 如何在SpringBoot中通过@Value注入Map和List并使用YAML配置?
  • 分账解决连锁酒店资金分配难题
  • Langchain文本摘要
  • Exposure Adjusted Incidence Rate (EAIR) 暴露调整发病率:精准量化疾病风险
  • 基于Python或Java实现的本地知识库文档问答系统
  • 解锁大数据新视野:构建强大可观测平台
  • Scala语法基础
  • window和ubuntu自签证书
  • SD3302 驱动:轻量级模块化,一键集成,高效易用。
  • PTC加热片详解(STM32)
  • kvm物理接口发现的脚本COLT_CMDB_KVM_IFACE.sh
  • Qt指ModbusTcp协议的使用
  • 潇洒郎:ssh 连接Windows WSL2 Linux子系统 ipv6地址转发到ipv4地址上
  • BTSRB德国交通标志数据集.csv文件提取数据转换成.json文件
  • UVM 寄存器模型中的概念
  • 国标GB28181视频平台EasyGBS视频监控平台助力打造校园安防智能化