From f63d666606f6727c3051976a5a38244aefc19147 Mon Sep 17 00:00:00 2001 From: vacuityv Date: Fri, 17 Nov 2023 07:41:44 +0800 Subject: [PATCH] fix(assistant-run): run ans run-step (#408) --- .../theokanning/openai/common/LastError.java | 24 +++++++ .../runs/CreateThreadAndRunRequest.java | 39 +++++++++++ .../openai/runs/MessageCreation.java | 3 +- .../openai/runs/RequiredAction.java | 26 +++++++ .../java/com/theokanning/openai/runs/Run.java | 69 ++++++++++++------- .../openai/runs/RunCreateRequest.java | 4 ++ .../com/theokanning/openai/runs/RunImage.java | 24 +++++++ .../com/theokanning/openai/runs/RunStep.java | 61 ++++++++++------ .../com/theokanning/openai/runs/RunSteps.java | 17 ----- .../com/theokanning/openai/runs/Runs.java | 17 ----- .../theokanning/openai/runs/StepDetails.java | 13 +++- .../runs/SubmitToolOutputRequestItem.java | 26 +++++++ .../openai/runs/SubmitToolOutputs.java | 26 +++++++ .../openai/runs/SubmitToolOutputsRequest.java | 26 +++++++ .../com/theokanning/openai/runs/ToolCall.java | 34 +++++++++ .../openai/runs/ToolCallCodeInterpreter.java | 26 +++++++ .../runs/ToolCallCodeInterpreterOutput.java | 26 +++++++ .../runs/{Tool.java => ToolCallFunction.java} | 18 +++-- .../theokanning/openai/client/OpenAiApi.java | 32 +++++++++ .../openai/service/OpenAiService.java | 31 +++++++++ 20 files changed, 455 insertions(+), 87 deletions(-) create mode 100644 api/src/main/java/com/theokanning/openai/common/LastError.java create mode 100644 api/src/main/java/com/theokanning/openai/runs/CreateThreadAndRunRequest.java create mode 100644 api/src/main/java/com/theokanning/openai/runs/RequiredAction.java create mode 100644 api/src/main/java/com/theokanning/openai/runs/RunImage.java delete mode 100644 api/src/main/java/com/theokanning/openai/runs/RunSteps.java delete mode 100644 api/src/main/java/com/theokanning/openai/runs/Runs.java create mode 100644 api/src/main/java/com/theokanning/openai/runs/SubmitToolOutputRequestItem.java create mode 100644 api/src/main/java/com/theokanning/openai/runs/SubmitToolOutputs.java create mode 100644 api/src/main/java/com/theokanning/openai/runs/SubmitToolOutputsRequest.java create mode 100644 api/src/main/java/com/theokanning/openai/runs/ToolCall.java create mode 100644 api/src/main/java/com/theokanning/openai/runs/ToolCallCodeInterpreter.java create mode 100644 api/src/main/java/com/theokanning/openai/runs/ToolCallCodeInterpreterOutput.java rename api/src/main/java/com/theokanning/openai/runs/{Tool.java => ToolCallFunction.java} (50%) diff --git a/api/src/main/java/com/theokanning/openai/common/LastError.java b/api/src/main/java/com/theokanning/openai/common/LastError.java new file mode 100644 index 00000000..6a9f99de --- /dev/null +++ b/api/src/main/java/com/theokanning/openai/common/LastError.java @@ -0,0 +1,24 @@ +package com.theokanning.openai.common; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: + * @author: vacuity + * @create: 2023-11-16 22:27 + **/ + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class LastError { + + private String code; + + private String message; +} diff --git a/api/src/main/java/com/theokanning/openai/runs/CreateThreadAndRunRequest.java b/api/src/main/java/com/theokanning/openai/runs/CreateThreadAndRunRequest.java new file mode 100644 index 00000000..b27de696 --- /dev/null +++ b/api/src/main/java/com/theokanning/openai/runs/CreateThreadAndRunRequest.java @@ -0,0 +1,39 @@ +package com.theokanning.openai.runs; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.theokanning.openai.assistants.Tool; +import com.theokanning.openai.threads.ThreadRequest; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +/** + * @description: + * @author: vacuity + * @create: 2023-11-16 23:08 + **/ + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CreateThreadAndRunRequest { + + @JsonProperty("assistant_id") + private String assistantId; + + private ThreadRequest thread; + + private String model; + + private String instructions; + + private List tools; + + private Map metadata; +} diff --git a/api/src/main/java/com/theokanning/openai/runs/MessageCreation.java b/api/src/main/java/com/theokanning/openai/runs/MessageCreation.java index fe59d845..535fd7e2 100644 --- a/api/src/main/java/com/theokanning/openai/runs/MessageCreation.java +++ b/api/src/main/java/com/theokanning/openai/runs/MessageCreation.java @@ -6,11 +6,12 @@ import lombok.Data; import lombok.NoArgsConstructor; +@Data @Builder @NoArgsConstructor @AllArgsConstructor -@Data public class MessageCreation { + @JsonProperty("message_id") String messageId; } diff --git a/api/src/main/java/com/theokanning/openai/runs/RequiredAction.java b/api/src/main/java/com/theokanning/openai/runs/RequiredAction.java new file mode 100644 index 00000000..959b89dc --- /dev/null +++ b/api/src/main/java/com/theokanning/openai/runs/RequiredAction.java @@ -0,0 +1,26 @@ +package com.theokanning.openai.runs; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: + * @author: vacuity + * @create: 2023-11-16 22:44 + **/ + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class RequiredAction { + + private String type; + + @JsonProperty("submit_tool_outputs") + private SubmitToolOutputs submitToolOutputs; +} diff --git a/api/src/main/java/com/theokanning/openai/runs/Run.java b/api/src/main/java/com/theokanning/openai/runs/Run.java index 2c14dd10..1da9ec95 100644 --- a/api/src/main/java/com/theokanning/openai/runs/Run.java +++ b/api/src/main/java/com/theokanning/openai/runs/Run.java @@ -1,6 +1,8 @@ package com.theokanning.openai.runs; import com.fasterxml.jackson.annotation.JsonProperty; +import com.theokanning.openai.assistants.Tool; +import com.theokanning.openai.common.LastError; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -9,37 +11,56 @@ import java.util.List; import java.util.Map; +@Data @Builder @NoArgsConstructor @AllArgsConstructor -@Data public class Run { - @JsonProperty("assistant_id") - String assistantId; - @JsonProperty("cancelled_at") - Long cancelledAt; - @JsonProperty("completed_at") - Long completedAt; + private String id; + + private String object; + @JsonProperty("created_at") - Long createdAt; + private Integer createdAt; + + @JsonProperty("thread_id") + private String threadId; + + @JsonProperty("assistant_id") + private String assistantId; + + private String status; + + @JsonProperty("required_action") + private RequiredAction requiredAction; + + @JsonProperty("last_error") + private LastError lastError; + @JsonProperty("expires_at") - Long expiresAt; + private Integer expiresAt; + + @JsonProperty("started_at") + private Integer startedAt; + + @JsonProperty("cancelled_at") + private Integer cancelledAt; + @JsonProperty("failed_at") - Long failedAt; + private Integer failedAt; + + @JsonProperty("completed_at") + private Integer completedAt; + + private String model; + + private String instructions; + + private List tools; + @JsonProperty("file_ids") - List fileIds; - String id; - String instructions; - @JsonProperty("last_error") - String lastError; - Map metadata; - String model; - String object; - @JsonProperty("started_at") - Long startedAt; - String status; - @JsonProperty("thread_id") - String threadId; - List tools; + private List fileIds; + + private Map metadata; } diff --git a/api/src/main/java/com/theokanning/openai/runs/RunCreateRequest.java b/api/src/main/java/com/theokanning/openai/runs/RunCreateRequest.java index 93744d44..cba5f283 100644 --- a/api/src/main/java/com/theokanning/openai/runs/RunCreateRequest.java +++ b/api/src/main/java/com/theokanning/openai/runs/RunCreateRequest.java @@ -1,5 +1,6 @@ package com.theokanning.openai.runs; +import com.theokanning.openai.assistants.Tool; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -17,7 +18,10 @@ public class RunCreateRequest { // Optional String model; + String instructions; + List tools; + Map metadata; } diff --git a/api/src/main/java/com/theokanning/openai/runs/RunImage.java b/api/src/main/java/com/theokanning/openai/runs/RunImage.java new file mode 100644 index 00000000..18135187 --- /dev/null +++ b/api/src/main/java/com/theokanning/openai/runs/RunImage.java @@ -0,0 +1,24 @@ +package com.theokanning.openai.runs; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: + * @author: vacuity + * @create: 2023-11-16 22:33 + **/ + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class RunImage { + + @JsonProperty("file_id") + private String fileId; +} diff --git a/api/src/main/java/com/theokanning/openai/runs/RunStep.java b/api/src/main/java/com/theokanning/openai/runs/RunStep.java index 98c1eee3..7cd39342 100644 --- a/api/src/main/java/com/theokanning/openai/runs/RunStep.java +++ b/api/src/main/java/com/theokanning/openai/runs/RunStep.java @@ -1,39 +1,58 @@ package com.theokanning.openai.runs; import com.fasterxml.jackson.annotation.JsonProperty; +import com.theokanning.openai.common.LastError; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.Map; + @Builder @NoArgsConstructor @AllArgsConstructor @Data public class RunStep { - @JsonProperty("assistant_id") - String assistantId; - @JsonProperty("canelled_at") - Long cancelledAt; - @JsonProperty("completed_at") - Long completedAt; + private String id; + + private String object; + @JsonProperty("created_at") - Long createdAt; - @JsonProperty("expired_at") - Long expiredAt; - @JsonProperty("failed_at") - Long failedAt; - String id; - @JsonProperty("last_error") - String lastError; - String object; + private Integer createdAt; + + @JsonProperty("assistant_id") + private String assistantId; + + @JsonProperty("thread_id") + private String threadId; + @JsonProperty("run_id") - String runId; - String status; + private String runId; + + private String type; + + private String status; + @JsonProperty("step_details") - StepDetails stepDetails; - @JsonProperty("thread_id") - String threadId; - String type; + private StepDetails stepDetails; + + @JsonProperty("last_error") + private LastError lastError; + + @JsonProperty("expired_at") + private Integer expiredAt; + + @JsonProperty("cancelled_at") + private Integer cancelledAt; + + @JsonProperty("failed_at") + private Integer failedAt; + + @JsonProperty("completed_at") + private Integer completedAt; + + private Map metadata; + } diff --git a/api/src/main/java/com/theokanning/openai/runs/RunSteps.java b/api/src/main/java/com/theokanning/openai/runs/RunSteps.java deleted file mode 100644 index c7260cfe..00000000 --- a/api/src/main/java/com/theokanning/openai/runs/RunSteps.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.theokanning.openai.runs; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class RunSteps { - - String object; - List data; - @JsonProperty("first_id") - String firstId; - @JsonProperty("last_id") - String lastId; - @JsonProperty("has_more") - boolean hasMore; -} diff --git a/api/src/main/java/com/theokanning/openai/runs/Runs.java b/api/src/main/java/com/theokanning/openai/runs/Runs.java deleted file mode 100644 index 2b07de7d..00000000 --- a/api/src/main/java/com/theokanning/openai/runs/Runs.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.theokanning.openai.runs; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class Runs { - - String object; - List data; - @JsonProperty("first_id") - String firstId; - @JsonProperty("last_id") - String lastId; - @JsonProperty("has_more") - boolean hasMore; -} diff --git a/api/src/main/java/com/theokanning/openai/runs/StepDetails.java b/api/src/main/java/com/theokanning/openai/runs/StepDetails.java index c17f9224..08972623 100644 --- a/api/src/main/java/com/theokanning/openai/runs/StepDetails.java +++ b/api/src/main/java/com/theokanning/openai/runs/StepDetails.java @@ -6,13 +6,20 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + +@Data @Builder @NoArgsConstructor @AllArgsConstructor -@Data public class StepDetails { + + private String type; + @JsonProperty("message_creation") - MessageCreation messageCreation; - String type; + private MessageCreation messageCreation; + + @JsonProperty("tool_calls") + private List toolCalls; } diff --git a/api/src/main/java/com/theokanning/openai/runs/SubmitToolOutputRequestItem.java b/api/src/main/java/com/theokanning/openai/runs/SubmitToolOutputRequestItem.java new file mode 100644 index 00000000..ec2b346a --- /dev/null +++ b/api/src/main/java/com/theokanning/openai/runs/SubmitToolOutputRequestItem.java @@ -0,0 +1,26 @@ +package com.theokanning.openai.runs; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: + * @author: vacuity + * @create: 2023-11-16 22:45 + **/ + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SubmitToolOutputRequestItem { + + @JsonProperty("tool_call_id") + private String toolCallId; + + private String output; +} diff --git a/api/src/main/java/com/theokanning/openai/runs/SubmitToolOutputs.java b/api/src/main/java/com/theokanning/openai/runs/SubmitToolOutputs.java new file mode 100644 index 00000000..e0aca757 --- /dev/null +++ b/api/src/main/java/com/theokanning/openai/runs/SubmitToolOutputs.java @@ -0,0 +1,26 @@ +package com.theokanning.openai.runs; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @description: + * @author: vacuity + * @create: 2023-11-16 22:45 + **/ + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SubmitToolOutputs { + + @JsonProperty("tool_calls") + List toolCalls; +} diff --git a/api/src/main/java/com/theokanning/openai/runs/SubmitToolOutputsRequest.java b/api/src/main/java/com/theokanning/openai/runs/SubmitToolOutputsRequest.java new file mode 100644 index 00000000..3086610c --- /dev/null +++ b/api/src/main/java/com/theokanning/openai/runs/SubmitToolOutputsRequest.java @@ -0,0 +1,26 @@ +package com.theokanning.openai.runs; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @description: + * @author: vacuity + * @create: 2023-11-16 22:45 + **/ + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SubmitToolOutputsRequest { + + @JsonProperty("tool_outputs") + private List tool_outputs; +} diff --git a/api/src/main/java/com/theokanning/openai/runs/ToolCall.java b/api/src/main/java/com/theokanning/openai/runs/ToolCall.java new file mode 100644 index 00000000..8aa6c26c --- /dev/null +++ b/api/src/main/java/com/theokanning/openai/runs/ToolCall.java @@ -0,0 +1,34 @@ +package com.theokanning.openai.runs; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +/** + * @description: + * @author: vacuity + * @create: 2023-11-16 22:32 + **/ + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ToolCall { + + private String id; + + private String type; + + @JsonProperty("code_interpreter") + private ToolCallCodeInterpreter codeInterpreter; + + private Map retrieval; + + private ToolCallFunction function; +} diff --git a/api/src/main/java/com/theokanning/openai/runs/ToolCallCodeInterpreter.java b/api/src/main/java/com/theokanning/openai/runs/ToolCallCodeInterpreter.java new file mode 100644 index 00000000..c2a3a446 --- /dev/null +++ b/api/src/main/java/com/theokanning/openai/runs/ToolCallCodeInterpreter.java @@ -0,0 +1,26 @@ +package com.theokanning.openai.runs; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @description: + * @author: vacuity + * @create: 2023-11-16 22:34 + **/ + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ToolCallCodeInterpreter { + + private String input; + + private List outputs; +} diff --git a/api/src/main/java/com/theokanning/openai/runs/ToolCallCodeInterpreterOutput.java b/api/src/main/java/com/theokanning/openai/runs/ToolCallCodeInterpreterOutput.java new file mode 100644 index 00000000..179ef2f1 --- /dev/null +++ b/api/src/main/java/com/theokanning/openai/runs/ToolCallCodeInterpreterOutput.java @@ -0,0 +1,26 @@ +package com.theokanning.openai.runs; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: + * @author: vacuity + * @create: 2023-11-16 22:34 + **/ + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ToolCallCodeInterpreterOutput { + + private String type; + + private String logs; + + private RunImage image; +} diff --git a/api/src/main/java/com/theokanning/openai/runs/Tool.java b/api/src/main/java/com/theokanning/openai/runs/ToolCallFunction.java similarity index 50% rename from api/src/main/java/com/theokanning/openai/runs/Tool.java rename to api/src/main/java/com/theokanning/openai/runs/ToolCallFunction.java index abeee04b..34de58d1 100644 --- a/api/src/main/java/com/theokanning/openai/runs/Tool.java +++ b/api/src/main/java/com/theokanning/openai/runs/ToolCallFunction.java @@ -5,11 +5,21 @@ import lombok.Data; import lombok.NoArgsConstructor; +/** + * @description: + * @author: vacuity + * @create: 2023-11-16 22:38 + **/ + +@Data @Builder @NoArgsConstructor @AllArgsConstructor -@Data -public class Tool { - - String type; +public class ToolCallFunction { + + private String name; + + private String arguments; + + private String output; } diff --git a/client/src/main/java/com/theokanning/openai/client/OpenAiApi.java b/client/src/main/java/com/theokanning/openai/client/OpenAiApi.java index 36fc7434..5bf3e732 100644 --- a/client/src/main/java/com/theokanning/openai/client/OpenAiApi.java +++ b/client/src/main/java/com/theokanning/openai/client/OpenAiApi.java @@ -1,6 +1,7 @@ package com.theokanning.openai.client; import com.theokanning.openai.DeleteResult; +import com.theokanning.openai.ListSearchParameters; import com.theokanning.openai.OpenAiResponse; import com.theokanning.openai.assistants.*; import com.theokanning.openai.audio.CreateSpeechRequest; @@ -33,8 +34,11 @@ import com.theokanning.openai.model.Model; import com.theokanning.openai.moderation.ModerationRequest; import com.theokanning.openai.moderation.ModerationResult; +import com.theokanning.openai.runs.CreateThreadAndRunRequest; import com.theokanning.openai.runs.Run; import com.theokanning.openai.runs.RunCreateRequest; +import com.theokanning.openai.runs.RunStep; +import com.theokanning.openai.runs.SubmitToolOutputsRequest; import com.theokanning.openai.threads.Thread; import com.theokanning.openai.threads.ThreadRequest; import io.reactivex.Single; @@ -288,4 +292,32 @@ public interface OpenAiApi { @GET("/v1/threads/{thread_id}/runs/{run_id}") Single retrieveRun(@Path("thread_id") String threadId, @Path("run_id") String runId); + @Headers("OpenAI-Beta: assistants=v1") + @POST("/v1/threads/{thread_id}/runs/{run_id}") + Single modifyRun(@Path("thread_id") String threadId, @Path("run_id") String runId, @Body Map metadata); + + @Headers("OpenAI-Beta: assistants=v1") + @GET("/v1/threads/{thread_id}/runs") + Single> listRuns(@Path("thread_id") String threadId, @Body ListSearchParameters listSearchParameters); + + @Headers("OpenAI-Beta: assistants=v1") + @POST("/v1/threads/{thread_id}/runs/{run_id}/submit_tool_outputs") + Single submitToolOutputs(@Path("thread_id") String threadId, @Path("run_id") String runId, @Body SubmitToolOutputsRequest submitToolOutputsRequest); + + + @Headers("OpenAI-Beta: assistants=v1") + @POST("/v1/threads/{thread_id}/runs/{run_id}/cancel") + Single cancelRun(@Path("thread_id") String threadId, @Path("run_id") String runId); + + @Headers("OpenAI-Beta: assistants=v1") + @POST("/v1/threads/runs") + Single createThreadAndRun(@Body CreateThreadAndRunRequest createThreadAndRunRequest); + + @Headers("OpenAI-Beta: assistants=v1") + @GET("/v1/threads/{thread_id}/runs/{run_id}/steps/{step_id}") + Single retrieveRunStep(@Path("thread_id") String threadId, @Path("run_id") String runId, @Path("step_id") String stepId); + + @Headers("OpenAI-Beta: assistants=v1") + @GET("/v1/threads/{thread_id}/runs/{run_id}/steps") + Single> listRunSteps(@Path("thread_id") String threadId, @Path("run_id") String runId, @Body ListSearchParameters listSearchParameters); } diff --git a/service/src/main/java/com/theokanning/openai/service/OpenAiService.java b/service/src/main/java/com/theokanning/openai/service/OpenAiService.java index d59f7e3c..09680304 100644 --- a/service/src/main/java/com/theokanning/openai/service/OpenAiService.java +++ b/service/src/main/java/com/theokanning/openai/service/OpenAiService.java @@ -38,8 +38,11 @@ import com.theokanning.openai.model.Model; import com.theokanning.openai.moderation.ModerationRequest; import com.theokanning.openai.moderation.ModerationResult; +import com.theokanning.openai.runs.CreateThreadAndRunRequest; import com.theokanning.openai.runs.Run; import com.theokanning.openai.runs.RunCreateRequest; +import com.theokanning.openai.runs.RunStep; +import com.theokanning.openai.runs.SubmitToolOutputsRequest; import com.theokanning.openai.threads.Thread; import com.theokanning.openai.threads.ThreadRequest; import io.reactivex.BackpressureStrategy; @@ -463,6 +466,34 @@ public Run retrieveRun(String threadId, String runId) { return execute(api.retrieveRun(threadId, runId)); } + public Run modifyRun(String threadId, String runId, Map metadata) { + return execute(api.modifyRun(threadId, runId, metadata)); + } + + public OpenAiResponse listRuns(String threadId, ListSearchParameters listSearchParameters) { + return execute(api.listRuns(threadId, listSearchParameters)); + } + + public Run submitToolOutputs(String threadId, String runId, SubmitToolOutputsRequest submitToolOutputsRequest) { + return execute(api.submitToolOutputs(threadId, runId, submitToolOutputsRequest)); + } + + public Run cancelRun(String threadId, String runId) { + return execute(api.cancelRun(threadId, runId)); + } + + public Run createThreadAndRun(CreateThreadAndRunRequest createThreadAndRunRequest) { + return execute(api.createThreadAndRun(createThreadAndRunRequest)); + } + + public RunStep retrieveRunStep(String threadId, String runId, String stepId) { + return execute(api.retrieveRunStep(threadId, runId, stepId)); + } + + public OpenAiResponse listRunSteps(String threadId, String runId, ListSearchParameters listSearchParameters) { + return execute(api.listRunSteps(threadId, runId, listSearchParameters)); + } + /** * Calls the Open AI api, returns the response, and parses error messages if the request fails */