Skip to content

Commit

Permalink
Fix to reference Tool instead of AssistantTool
Browse files Browse the repository at this point in the history
  • Loading branch information
Sashir Estela authored and sashirestela committed May 25, 2024
1 parent e4b7555 commit 90a95f0
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void prepareConversation() {
.name("World Assistant")
.model("gpt-4-turbo")
.instructions("You are a skilled tutor on geo-politic topics.")
.tools(AssistantTool.functions(functionList))
.tools(functionExecutor.getToolFunctions())
.tool(AssistantTool.FILE_SEARCH)
.toolResources(ToolResourceFull.builder()
.fileSearch(FileSearch.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import io.github.sashirestela.openai.demo.ThreadRunV2Demo.CurrentTemperature;
import io.github.sashirestela.openai.demo.ThreadRunV2Demo.RainProbability;
import io.github.sashirestela.openai.domain.assistant.AssistantRequest;
import io.github.sashirestela.openai.domain.assistant.AssistantTool;
import io.github.sashirestela.openai.domain.assistant.ThreadMessageRequest;
import io.github.sashirestela.openai.domain.assistant.ThreadMessageRole;
import io.github.sashirestela.openai.domain.assistant.ThreadRunRequest;
Expand Down Expand Up @@ -45,7 +44,7 @@ private void prepareDemo() {
.instructions("You are a very kind assistant. If you cannot find correct facts to answer the "
+ "questions, you have to refer to the attached files or use the functions provided. "
+ "Finally, if you receive math questions, you must write and run code to answer them.")
.tools(AssistantTool.functions(functionList))
.tools(functionExecutor.getToolFunctions())
.temperature(0.2)
.build())
.join();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void prepareDemo() {
.instructions("You are a very kind assistant. If you cannot find correct facts to answer the "
+ "questions, you have to refer to the attached files or use the functions provided. "
+ "Finally, if you receive math questions, you must write and run code to answer them.")
.tools(AssistantTool.functions(functionList))
.tools(functionExecutor.getToolFunctions())
.tool(AssistantTool.FILE_SEARCH)
.toolResources(ToolResourceFull.builder()
.fileSearch(FileSearch.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.util.List;
import java.util.stream.Collectors;

@AllArgsConstructor
@NoArgsConstructor
@Getter
Expand All @@ -33,12 +30,6 @@ public static Tool function(FunctionDef function) {
JsonSchemaUtil.classToJsonSchema(function.getFunctionalClass())));
}

public static List<Tool> functions(List<FunctionDef> functions) {
return functions.stream()
.map(funDef -> function(funDef))
.collect(Collectors.toList());
}

@AllArgsConstructor(access = AccessLevel.PROTECTED)
@NoArgsConstructor
@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import io.github.sashirestela.openai.common.tool.Tool;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
Expand All @@ -22,7 +23,7 @@ public class Assistant {
private String description;
private String model;
private String instructions;
private List<AssistantTool> tools;
private List<Tool> tools;
private ToolResource toolResources;
private Map<String, String> metadata;
private Double temperature;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import io.github.sashirestela.openai.common.ResponseFormat;
import io.github.sashirestela.openai.common.tool.Tool;
import io.github.sashirestela.slimvalidator.constraints.ObjectType;
import io.github.sashirestela.slimvalidator.constraints.Range;
import io.github.sashirestela.slimvalidator.constraints.Size;
Expand Down Expand Up @@ -34,7 +35,7 @@ public class AssistantModifyRequest {

@Singular
@Size(max = 128)
private List<AssistantTool> tools;
private List<Tool> tools;

private ToolResource toolResources;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import io.github.sashirestela.openai.common.ResponseFormat;
import io.github.sashirestela.openai.common.tool.Tool;
import io.github.sashirestela.openai.common.tool.ToolChoice;
import io.github.sashirestela.openai.common.tool.ToolChoiceOption;
import io.github.sashirestela.slimvalidator.constraints.ObjectType;
Expand Down Expand Up @@ -34,7 +35,7 @@ public class ThreadCreateAndRunRequest {
private String instructions;
@Singular
@Size(max = 20)
private List<AssistantTool> tools;
private List<Tool> tools;

private ToolResource toolResources;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import io.github.sashirestela.openai.common.Usage;
import io.github.sashirestela.openai.common.tool.Tool;
import io.github.sashirestela.openai.common.tool.ToolCall;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand Down Expand Up @@ -34,7 +35,7 @@ public class ThreadRun {
private IncompleteDetail incompleteDetails;
private String model;
private String instructions;
private List<AssistantTool> tools;
private List<Tool> tools;
private Map<String, String> metadata;
private Usage usage;
private Double temperature;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import io.github.sashirestela.openai.common.ResponseFormat;
import io.github.sashirestela.openai.common.tool.Tool;
import io.github.sashirestela.openai.common.tool.ToolChoice;
import io.github.sashirestela.openai.common.tool.ToolChoiceOption;
import io.github.sashirestela.slimvalidator.constraints.ObjectType;
Expand Down Expand Up @@ -38,7 +39,7 @@ public class ThreadRunRequest {

@Singular
@Size(max = 20)
private List<AssistantTool> tools;
private List<Tool> tools;

@Size(max = 16)
private Map<String, String> metadata;
Expand Down

0 comments on commit 90a95f0

Please sign in to comment.