diff --git a/OpenAI.Playground/TestHelpers/AssistantTestHelper.cs b/OpenAI.Playground/TestHelpers/AssistantTestHelper.cs index 208e5156..bfa3e539 100644 --- a/OpenAI.Playground/TestHelpers/AssistantTestHelper.cs +++ b/OpenAI.Playground/TestHelpers/AssistantTestHelper.cs @@ -30,7 +30,7 @@ public static async Task RunAssistantApiTest(IOpenAIService sdk) { Instructions = "You are a professional assistant who provides company information. Company-related data comes from uploaded questions and does not provide vague answers, only clear answers.", Name = "Qicha", - Tools = new List() { ToolDefinition.DefineCodeInterpreter(), ToolDefinition.DefineRetrieval(), ToolDefinition.DefineFunction(func) }, + Tools = new List() { ToolDefinition.DefineCodeInterpreter(), ToolDefinition.DefineFileSearch(), ToolDefinition.DefineFunction(func) }, Model = Models.Gpt_3_5_Turbo_1106 }); if (assistantResult.Successful) @@ -162,7 +162,7 @@ public static async Task RunHowAssistantsWorkTest(IOpenAIService sdk) Instructions = "You are a professional assistant who provides company information. Company-related data comes from uploaded questions and does not provide vague answers, only clear answers.", Name = "Qicha", Model = Models.Gpt_3_5_Turbo_1106, - Tools = new List() { ToolDefinition.DefineCodeInterpreter(), ToolDefinition.DefineRetrieval(), ToolDefinition.DefineFunction(func) }, + Tools = new List() { ToolDefinition.DefineCodeInterpreter(), ToolDefinition.DefineFileSearch(), ToolDefinition.DefineFunction(func) }, FileIds = new List() { uplaodFileId } }); diff --git a/OpenAI.Playground/TestHelpers/RunTestHelper.cs b/OpenAI.Playground/TestHelpers/RunTestHelper.cs index 7b9e810d..44c1f8df 100644 --- a/OpenAI.Playground/TestHelpers/RunTestHelper.cs +++ b/OpenAI.Playground/TestHelpers/RunTestHelper.cs @@ -26,7 +26,7 @@ public static async Task RunRunCreateTest(IOpenAIService sdk) { Instructions = "You are a professional assistant who provides company information. Company-related data comes from uploaded questions and does not provide vague answers, only clear answers.", Name = "Qicha", - Tools = new List() { ToolDefinition.DefineCodeInterpreter(), ToolDefinition.DefineRetrieval(), ToolDefinition.DefineFunction(func) }, + Tools = new List() { ToolDefinition.DefineCodeInterpreter(), ToolDefinition.DefineFileSearch(), ToolDefinition.DefineFunction(func) }, Model = Models.Gpt_3_5_Turbo_1106 }); var runResult = await sdk.Beta.Runs.RunCreate(threadId, new RunCreateRequest() @@ -110,7 +110,7 @@ public static async Task RunRunCancelTest(IOpenAIService sdk) { Instructions = "You are a professional assistant who provides company information. Company-related data comes from uploaded questions and does not provide vague answers, only clear answers.", Name = "Qicha", - Tools = new List() { ToolDefinition.DefineCodeInterpreter(), ToolDefinition.DefineRetrieval(), ToolDefinition.DefineFunction(func) }, + Tools = new List() { ToolDefinition.DefineCodeInterpreter(), ToolDefinition.DefineFileSearch(), ToolDefinition.DefineFunction(func) }, Model = Models.Gpt_3_5_Turbo_1106 }); var runCreateResult = await sdk.Beta.Runs.RunCreate(threadId, new RunCreateRequest() diff --git a/OpenAI.SDK/Interfaces/IBetaService.cs b/OpenAI.SDK/Interfaces/IBetaService.cs index 3972503c..0a9e1c3d 100644 --- a/OpenAI.SDK/Interfaces/IBetaService.cs +++ b/OpenAI.SDK/Interfaces/IBetaService.cs @@ -9,4 +9,6 @@ public interface IBetaService public IThreadService Threads { get; } public IRunService Runs { get; } + + public IRunStepService RunSteps { get; } } \ No newline at end of file diff --git a/OpenAI.SDK/Interfaces/IRunStepService.cs b/OpenAI.SDK/Interfaces/IRunStepService.cs index 43b7a9d6..f0afdbef 100644 --- a/OpenAI.SDK/Interfaces/IRunStepService.cs +++ b/OpenAI.SDK/Interfaces/IRunStepService.cs @@ -13,7 +13,7 @@ public interface IRunStepService /// Paging /// /// A list of [run step](/docs/api-reference/runs/step-object) objects. - Task RunStepsList(string threadId, string runId, RunStepListRequest request, CancellationToken cancellationToken = default); + Task RunStepsList(string threadId, string runId, RunStepListRequest? request = null, CancellationToken cancellationToken = default); /// /// Retrieves a run step. diff --git a/OpenAI.SDK/Managers/OpenAIBetaService.cs b/OpenAI.SDK/Managers/OpenAIBetaService.cs index e5ef5876..8aa32375 100644 --- a/OpenAI.SDK/Managers/OpenAIBetaService.cs +++ b/OpenAI.SDK/Managers/OpenAIBetaService.cs @@ -14,4 +14,6 @@ public partial class OpenAIService : IBetaService public IThreadService Threads => this; public IRunService Runs => this; + + public IRunStepService RunSteps => this; } \ No newline at end of file diff --git a/OpenAI.SDK/Managers/OpenAIRunStepService.cs b/OpenAI.SDK/Managers/OpenAIRunStepService.cs index 3aebef4b..0aef617e 100644 --- a/OpenAI.SDK/Managers/OpenAIRunStepService.cs +++ b/OpenAI.SDK/Managers/OpenAIRunStepService.cs @@ -8,7 +8,7 @@ namespace OpenAI.Managers; public partial class OpenAIService : IRunStepService { /// - public async Task RunStepsList(string threadId, string runId, RunStepListRequest request, CancellationToken cancellationToken = default) + public async Task RunStepsList(string threadId, string runId, RunStepListRequest? request = null, CancellationToken cancellationToken = default) { return await _httpClient.GetReadAsAsync(_endpointProvider.RunStepList(threadId, runId,request), cancellationToken); } diff --git a/OpenAI.SDK/ObjectModels/RequestModels/ToolDefinition.cs b/OpenAI.SDK/ObjectModels/RequestModels/ToolDefinition.cs index 36e30641..59ae1f57 100644 --- a/OpenAI.SDK/ObjectModels/RequestModels/ToolDefinition.cs +++ b/OpenAI.SDK/ObjectModels/RequestModels/ToolDefinition.cs @@ -51,8 +51,16 @@ public object? FunctionCalculated { Type = StaticValues.AssistantsStatics.ToolCallTypes.CodeInterpreter, }; + + [Obsolete("Retrieval is now called FileSearch")] public static ToolDefinition DefineRetrieval() => new() { - Type = StaticValues.AssistantsStatics.ToolCallTypes.Retrieval, + Type = StaticValues.AssistantsStatics.ToolCallTypes.FileSearch, }; + + public static ToolDefinition DefineFileSearch() => new() + { + Type = StaticValues.AssistantsStatics.ToolCallTypes.FileSearch, + }; + } \ No newline at end of file diff --git a/OpenAI.SDK/ObjectModels/ResponseModels/RunStepListResponse.cs b/OpenAI.SDK/ObjectModels/ResponseModels/RunStepListResponse.cs index 1114d47e..39a52312 100644 --- a/OpenAI.SDK/ObjectModels/ResponseModels/RunStepListResponse.cs +++ b/OpenAI.SDK/ObjectModels/ResponseModels/RunStepListResponse.cs @@ -64,26 +64,13 @@ public record RunStepResponse : BaseResponse, IOpenAiModels.IId, IOpenAiModels.I public string Type { get; set; } /// - /// The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`. + /// The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, `expired`, or 'incomplete'. /// [JsonPropertyName("status")] public string Status { get; set; } - public class StepDetailsComplexType - { - [JsonIgnore] - public StepDetails StepDetails1 { get; set; } - - [JsonIgnore] - public StepDetails StepDetails2 { get; set; } - } - - /// - /// The details of the run step. - /// - [JsonConverter(typeof(ComplexTypeConverter))] [JsonPropertyName("step_details")] - public StepDetailsComplexType StepDetails { get; set; } + public RunStepDetails? StepDetails { get; set; } /// /// The last error associated with this run step. Will be `null` if there are no errors. @@ -127,17 +114,25 @@ public class StepDetailsComplexType [JsonPropertyName("usage")] public UsageResponse? Usage { get; set; } } -public record StepDetails + +public record RunStepDetails { /// - /// Always `tool_calls`. + /// Always message_creation. /// [JsonPropertyName("type")] public string Type { get; set; } - /// - /// An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. - /// - [JsonPropertyName("tool_calls")] - public List ToolCalls { get; set; } + [JsonPropertyName("message_creation")] + public RunStepMessageCreation MessageCreation { get; set; } + + public class RunStepMessageCreation + { + [JsonPropertyName("message_id")] + public string MessageId { get; set; } + } } + + + + diff --git a/OpenAI.SDK/ObjectModels/StaticValueHelper.cs b/OpenAI.SDK/ObjectModels/StaticValueHelper.cs index c643ca85..391859da 100644 --- a/OpenAI.SDK/ObjectModels/StaticValueHelper.cs +++ b/OpenAI.SDK/ObjectModels/StaticValueHelper.cs @@ -119,7 +119,7 @@ public static class AssistantsStatics public static class ToolCallTypes { public static string CodeInterpreter => "code_interpreter"; - public static string Retrieval => "retrieval"; + public static string FileSearch => "file_search"; public static string Function => "function"; }