You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
1.8 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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);
}
}
}

Powered by TurnKey Linux.