package xyz.wbsite.achat.chat.tool; import cn.hutool.core.util.RandomUtil; /** * 工具调用请求 - 符合OpenAI官方API规范 * * @author wangbing * @version 0.0.1 * @since 1.8 */ public class ToolCall { private final String id = "call_" + RandomUtil.randomNumbers(8); private int index; private String type; private FunctionCall function; public int getIndex() { return index; } public void setIndex(int index) { this.index = index; } public String getType() { return type; } public void setType(String type) { this.type = type; } public FunctionCall getFunction() { return function; } public void setFunction(FunctionCall function) { this.function = function; } private ToolCall(String id, int index, String type, FunctionCall function) { this.index = index; this.type = type; this.function = function; } public static Builder builder() { return new Builder(); } public static class Builder { private String id; private int index; private String type; private FunctionCall function; // 链式设置id(可选,不设置则使用默认值) public Builder id(String id) { this.id = id; return this; } public Builder index(int index) { this.index = index; return this; } public Builder type(String type) { this.type = type; return this; } public Builder function(FunctionCall function) { this.function = function; return this; } public ToolCall build() { return new ToolCall(id, index, type, function); } } }