diff --git a/.docs/OpenAI.Docs.ApiReference/Assistants/ListAssistants.cs b/.docs/OpenAI.Docs.ApiReference/Assistants/ListAssistants.cs index 7ff05e97b..be9764b4a 100644 --- a/.docs/OpenAI.Docs.ApiReference/Assistants/ListAssistants.cs +++ b/.docs/OpenAI.Docs.ApiReference/Assistants/ListAssistants.cs @@ -19,9 +19,9 @@ public void ListAssistants() apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY") ); - AssistantCollectionOptions options = new() + OpenAIPageOptions options = new() { - Order = AssistantCollectionOrder.Descending, + Order = OpenAIPageOrder.Descending, PageSizeLimit = 20 }; diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Assistants/AzureAssistantClient.Protocol.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Assistants/AzureAssistantClient.Protocol.cs index 11e2b5010..124c13071 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Assistants/AzureAssistantClient.Protocol.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Assistants/AzureAssistantClient.Protocol.cs @@ -13,28 +13,12 @@ namespace Azure.AI.OpenAI.Assistants; [Experimental("OPENAI001")] internal partial class AzureAssistantClient : AssistantClient { - public override async Task CreateAssistantAsync(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateCreateAssistantRequest(content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - public override ClientResult CreateAssistant(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateCreateAssistantRequest(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - public override AsyncCollectionResult GetAssistantsAsync(int? limit, string order, string after, string before, RequestOptions options) { return new AzureAsyncCollectionResult( Pipeline, options, - continuation => CreateGetAssistantsRequest(limit, order, continuation?.After ?? after, continuation?.Before ?? before, options), + continuation => CreateListAssistantsRequest(limit, order, continuation?.After ?? after, continuation?.Before ?? before, options), page => AssistantCollectionPageToken.FromResponse(page, limit, order, before), page => ModelReaderWriter.Read(page.GetRawResponse().Content).Data, options?.CancellationToken ?? default); @@ -45,61 +29,11 @@ public override CollectionResult GetAssistants(int? limit, string order, string return new AzureCollectionResult( Pipeline, options, - continuation => CreateGetAssistantsRequest(limit, order, continuation?.After ?? after, continuation?.Before ?? before, options), + continuation => CreateListAssistantsRequest(limit, order, continuation?.After ?? after, continuation?.Before ?? before, options), page => AssistantCollectionPageToken.FromResponse(page, limit, order, before), page => ModelReaderWriter.Read(page.GetRawResponse().Content).Data); } - public override async Task GetAssistantAsync(string assistantId, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - - using PipelineMessage message = CreateGetAssistantRequest(assistantId, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - public override ClientResult GetAssistant(string assistantId, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - - using PipelineMessage message = CreateGetAssistantRequest(assistantId, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - - public override async Task ModifyAssistantAsync(string assistantId, BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateModifyAssistantRequest(assistantId, content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - public override ClientResult ModifyAssistant(string assistantId, BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateModifyAssistantRequest(assistantId, content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - - public override async Task DeleteAssistantAsync(string assistantId, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - - using PipelineMessage message = CreateDeleteAssistantRequest(assistantId, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - public override ClientResult DeleteAssistant(string assistantId, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - - using PipelineMessage message = CreateDeleteAssistantRequest(assistantId, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - /// public override async Task CreateMessageAsync(string threadId, BinaryContent content, RequestOptions options = null) { @@ -518,19 +452,19 @@ public override ClientResult DeleteThread(string threadId, RequestOptions option return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } - private new PipelineMessage CreateCreateAssistantRequest(BinaryContent content, RequestOptions options = null) + internal override PipelineMessage CreateCreateAssistantRequest(BinaryContent content, RequestOptions options = null) => NewJsonPostBuilder(content, options).WithPath("assistants").Build(); - private PipelineMessage CreateGetAssistantsRequest(int? limit, string order, string after, string before, RequestOptions options) + internal override PipelineMessage CreateListAssistantsRequest(int? limit, string order, string after, string before, RequestOptions options) => NewGetListBuilder(limit, order, after, before, options).WithPath("assistants").Build(); - private new PipelineMessage CreateGetAssistantRequest(string assistantId, RequestOptions options) + internal override PipelineMessage CreateGetAssistantRequest(string assistantId, RequestOptions options) => NewJsonGetBuilder(options).WithPath("assistants", assistantId).Build(); - private new PipelineMessage CreateModifyAssistantRequest(string assistantId, BinaryContent content, RequestOptions options) + internal override PipelineMessage CreateModifyAssistantRequest(string assistantId, BinaryContent content, RequestOptions options) => NewJsonPostBuilder(content, options).WithPath("assistants", assistantId).Build(); - private new PipelineMessage CreateDeleteAssistantRequest(string assistantId, RequestOptions options) + internal override PipelineMessage CreateDeleteAssistantRequest(string assistantId, RequestOptions options) => NewJsonDeleteBuilder(options).WithPath("assistants", assistantId).Build(); private PipelineMessage CreateCreateThreadRequest(BinaryContent content, RequestOptions options) diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Audio/AzureAudioClient.Protocol.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Audio/AzureAudioClient.Protocol.cs index ca0fc9095..b0ba70982 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Audio/AzureAudioClient.Protocol.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Audio/AzureAudioClient.Protocol.cs @@ -3,58 +3,12 @@ using System.ClientModel; using System.ClientModel.Primitives; -using System.ComponentModel; -using OpenAI.Audio; namespace Azure.AI.OpenAI.Audio; internal partial class AzureAudioClient : AudioClient { - [EditorBrowsable(EditorBrowsableState.Never)] - public override ClientResult TranscribeAudio(BinaryContent content, string contentType, RequestOptions options = null) - { - using PipelineMessage message = CreateTranscribeAudioRequestMessage(content, contentType, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - - [EditorBrowsable(EditorBrowsableState.Never)] - public override async Task TranscribeAudioAsync(BinaryContent content, string contentType, RequestOptions options = null) - { - using PipelineMessage message = CreateTranscribeAudioRequestMessage(content, contentType, options); - PipelineResponse response = await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false); - return ClientResult.FromResponse(response); - } - - [EditorBrowsable(EditorBrowsableState.Never)] - public override ClientResult TranslateAudio(BinaryContent content, string contentType, RequestOptions options = null) - { - using PipelineMessage message = CreateTranslateAudioRequestMessage(content, contentType, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - - [EditorBrowsable(EditorBrowsableState.Never)] - public override async Task TranslateAudioAsync(BinaryContent content, string contentType, RequestOptions options = null) - { - using PipelineMessage message = CreateTranslateAudioRequestMessage(content, contentType, options); - PipelineResponse response = await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false); - return ClientResult.FromResponse(response); - } - #if !AZURE_OPENAI_GA - [EditorBrowsable(EditorBrowsableState.Never)] - public override ClientResult GenerateSpeech(BinaryContent content, RequestOptions options = null) - { - using PipelineMessage message = CreateGenerateSpeechFromTextRequestMessage(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - - [EditorBrowsable(EditorBrowsableState.Never)] - public override async Task GenerateSpeechAsync(BinaryContent content, RequestOptions options = null) - { - using PipelineMessage message = CreateGenerateSpeechFromTextRequestMessage(content, options); - PipelineResponse response = await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false); - return ClientResult.FromResponse(response); - } #else [EditorBrowsable(EditorBrowsableState.Never)] public override ClientResult GenerateSpeech(BinaryContent content, RequestOptions options = null) @@ -69,7 +23,7 @@ public override Task GenerateSpeechAsync(BinaryContent content, Re } #endif - private PipelineMessage CreateTranscribeAudioRequestMessage(BinaryContent content, string contentType, RequestOptions options) + internal override PipelineMessage CreateCreateTranscriptionRequest(BinaryContent content, string contentType, RequestOptions options) => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion, _deploymentName) .WithMethod("POST") .WithPath("audio", "transcriptions") @@ -78,7 +32,7 @@ private PipelineMessage CreateTranscribeAudioRequestMessage(BinaryContent conten .WithOptions(options) .Build(); - private PipelineMessage CreateTranslateAudioRequestMessage(BinaryContent content, string contentType, RequestOptions options) + internal override PipelineMessage CreateCreateTranslationRequest(BinaryContent content, string contentType, RequestOptions options) => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion, _deploymentName) .WithMethod("POST") .WithPath("audio", "translations") @@ -87,7 +41,7 @@ private PipelineMessage CreateTranslateAudioRequestMessage(BinaryContent content .WithOptions(options) .Build(); - private PipelineMessage CreateGenerateSpeechFromTextRequestMessage(BinaryContent content, RequestOptions options) + internal override PipelineMessage CreateCreateSpeechRequest(BinaryContent content, RequestOptions options) => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion, _deploymentName) .WithMethod("POST") .WithPath("audio", "speech") diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Batch/AzureBatchClient.Protocol.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Batch/AzureBatchClient.Protocol.cs index 9426b20a5..ea87675fa 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Batch/AzureBatchClient.Protocol.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Batch/AzureBatchClient.Protocol.cs @@ -10,62 +10,6 @@ namespace Azure.AI.OpenAI.Batch; internal partial class AzureBatchClient : BatchClient { - public override async Task CreateBatchAsync(BinaryContent content, bool waitUntilCompleted, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateCreateBatchRequest(content, options); - PipelineResponse response = await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false); - - using JsonDocument doc = JsonDocument.Parse(response.Content); - string batchId = doc.RootElement.GetProperty("id"u8).GetString(); - string status = doc.RootElement.GetProperty("status"u8).GetString(); - - CreateBatchOperation operation = CreateCreateBatchOperation(batchId, status, response); - return await operation.WaitUntilAsync(waitUntilCompleted, options).ConfigureAwait(false); - } - - public override CreateBatchOperation CreateBatch(BinaryContent content, bool waitUntilCompleted, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateCreateBatchRequest(content, options); - PipelineResponse response = Pipeline.ProcessMessage(message, options); - - using JsonDocument doc = JsonDocument.Parse(response.Content); - string batchId = doc.RootElement.GetProperty("id"u8).GetString(); - string status = doc.RootElement.GetProperty("status"u8).GetString(); - - CreateBatchOperation operation = CreateCreateBatchOperation(batchId, status, response); - return operation.WaitUntil(waitUntilCompleted, options); - } - - public override AsyncCollectionResult GetBatchesAsync(string after, int? limit, RequestOptions options) - { - return new AsyncBatchCollectionResult(this, Pipeline, options, limit, after); - } - - public override CollectionResult GetBatches(string after, int? limit, RequestOptions options) - { - return new BatchCollectionResult(this, Pipeline, options, limit, after); - } - - internal override async Task GetBatchAsync(string batchId, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); - - using PipelineMessage message = CreateRetrieveBatchRequest(batchId, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - internal override ClientResult GetBatch(string batchId, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); - - using PipelineMessage message = CreateRetrieveBatchRequest(batchId, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - internal override PipelineMessage CreateCreateBatchRequest(BinaryContent content, RequestOptions options) => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion, null) .WithMethod("POST") diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Batch/AzureBatchClient.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Batch/AzureBatchClient.cs index b22f93371..05eaec871 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Batch/AzureBatchClient.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Batch/AzureBatchClient.cs @@ -32,9 +32,4 @@ internal AzureBatchClient(ClientPipeline pipeline, Uri endpoint, AzureOpenAIClie protected AzureBatchClient() { } - - internal override CreateBatchOperation CreateCreateBatchOperation(string batchId, string status, PipelineResponse response) - { - return new AzureCreateBatchOperation(Pipeline, _endpoint, batchId, status, response, _apiVersion); - } } \ No newline at end of file diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Batch/AzureCreateBatchOperation.Protocol.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Batch/AzureCreateBatchOperation.Protocol.cs deleted file mode 100644 index 220e09fc5..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Batch/AzureCreateBatchOperation.Protocol.cs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Diagnostics.CodeAnalysis; - -#nullable enable - -namespace Azure.AI.OpenAI.Batch; - -/// -/// A long-running operation for executing a batch from an uploaded file of requests. -/// -[Experimental("AOAI001")] -internal partial class AzureCreateBatchOperation : CreateBatchOperation -{ - private readonly ClientPipeline _pipeline; - private readonly Uri _endpoint; - private readonly string _batchId; - private readonly string _apiVersion; - - internal AzureCreateBatchOperation( - ClientPipeline pipeline, - Uri endpoint, - string batchId, - string status, - PipelineResponse response, - string apiVersion) - : base(pipeline, endpoint, batchId, status, response) - { - _pipeline = pipeline; - _endpoint = endpoint; - _batchId = batchId; - _apiVersion = apiVersion; - } - - internal override PipelineMessage CreateRetrieveBatchRequest(string batchId, RequestOptions? options) - => new AzureOpenAIPipelineMessageBuilder(_pipeline, _endpoint, _apiVersion, null) - .WithMethod("GET") - .WithPath("batches", batchId) - .WithAccept("application/json") - .WithOptions(options) - .Build(); - - internal override PipelineMessage CreateCancelBatchRequest(string batchId, RequestOptions? options) - => new AzureOpenAIPipelineMessageBuilder(_pipeline, _endpoint, _apiVersion, null) - .WithMethod("POST") - .WithPath("batches", batchId, "cancel") - .WithAccept("application/json") - .WithOptions(options) - .Build(); - - private static PipelineMessageClassifier? _pipelineMessageClassifier200; - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/AzureChatClient.Protocol.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/AzureChatClient.Protocol.cs index 1420399fc..1ca3eb44c 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/AzureChatClient.Protocol.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/AzureChatClient.Protocol.cs @@ -1,41 +1,19 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using OpenAI.Chat; using System.ClientModel; using System.ClientModel.Primitives; -using System.ComponentModel; namespace Azure.AI.OpenAI.Chat; internal partial class AzureChatClient : ChatClient { - [EditorBrowsable(EditorBrowsableState.Never)] - public override ClientResult CompleteChat(BinaryContent content, RequestOptions options = null) - { - using PipelineMessage message = CreateCompleteChatRequestMessage(content, options); - PipelineResponse response = Pipeline.ProcessMessage(message, options); - return ClientResult.FromResponse(message.BufferResponse ? response : message.ExtractResponse()); - } - - [EditorBrowsable(EditorBrowsableState.Never)] - public override async Task CompleteChatAsync(BinaryContent content, RequestOptions options = null) - { - using PipelineMessage message = CreateCompleteChatRequestMessage(content, options); - PipelineResponse response = await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false); - return ClientResult.FromResponse(message.BufferResponse ? response : message.ExtractResponse()); - } - - private PipelineMessage CreateCompleteChatRequestMessage( - BinaryContent content, - RequestOptions options = null, - bool? bufferResponse = true) - => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion, _deploymentName) - .WithPath("chat", "completions") - .WithMethod("POST") - .WithContent(content, "application/json") - .WithAccept("application/json") - .WithResponseContentBuffering(bufferResponse) - .WithOptions(options) - .Build(); + internal override PipelineMessage CreateCreateChatCompletionRequest(BinaryContent content, RequestOptions options) + => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion, _deploymentName) + .WithPath("chat", "completions") + .WithMethod("POST") + .WithContent(content, "application/json") + .WithAccept("application/json") + .WithOptions(options) + .Build(); } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Embeddings/AzureEmbeddingClient.Protocol.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Embeddings/AzureEmbeddingClient.Protocol.cs index afe5ac46e..5ab9a3187 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Embeddings/AzureEmbeddingClient.Protocol.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Embeddings/AzureEmbeddingClient.Protocol.cs @@ -3,29 +3,12 @@ using System.ClientModel; using System.ClientModel.Primitives; -using System.ComponentModel; -using OpenAI.Embeddings; namespace Azure.AI.OpenAI.Embeddings; internal partial class AzureEmbeddingClient : EmbeddingClient { - [EditorBrowsable(EditorBrowsableState.Never)] - public override ClientResult GenerateEmbeddings(BinaryContent content, RequestOptions options = null) - { - using PipelineMessage message = CreateEmbeddingPipelineMessage(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - - [EditorBrowsable(EditorBrowsableState.Never)] - public override async Task GenerateEmbeddingsAsync(BinaryContent content, RequestOptions options = null) - { - using PipelineMessage message = CreateEmbeddingPipelineMessage(content, options); - PipelineResponse response = await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false); - return ClientResult.FromResponse(response); - } - - private PipelineMessage CreateEmbeddingPipelineMessage(BinaryContent content, RequestOptions options = null) + internal override PipelineMessage CreateCreateEmbeddingRequest(BinaryContent content, RequestOptions options) => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion, _deploymentName) .WithMethod("POST") .WithPath("embeddings") diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureFileClient.Protocol.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureFileClient.Protocol.cs index 468f34903..dee6c8448 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureFileClient.Protocol.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureFileClient.Protocol.cs @@ -1,103 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; using System.ClientModel; using System.ClientModel.Primitives; -using System.ComponentModel; namespace Azure.AI.OpenAI.Files; internal partial class AzureFileClient : OpenAIFileClient { - [EditorBrowsable(EditorBrowsableState.Never)] - public override ClientResult DeleteFile(string fileId, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - using PipelineMessage message = CreateDeleteRequestMessage(fileId, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - - [EditorBrowsable(EditorBrowsableState.Never)] - public override async Task DeleteFileAsync(string fileId, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - using PipelineMessage message = CreateDeleteRequestMessage(fileId, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - [EditorBrowsable(EditorBrowsableState.Never)] - public override ClientResult DownloadFile(string fileId, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - using PipelineMessage message = CreateDownloadContentRequestMessage(fileId, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - - [EditorBrowsable(EditorBrowsableState.Never)] - public override async Task DownloadFileAsync(string fileId, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - using PipelineMessage message = CreateDownloadContentRequestMessage(fileId, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - [EditorBrowsable(EditorBrowsableState.Never)] - public override ClientResult GetFile(string fileId, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - using PipelineMessage message = CreateGetFileRequestMessage(fileId, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - - [EditorBrowsable(EditorBrowsableState.Never)] - public override async Task GetFileAsync(string fileId, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - using PipelineMessage message = CreateGetFileRequestMessage(fileId, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - [EditorBrowsable(EditorBrowsableState.Never)] - public override ClientResult GetFiles(string purpose, RequestOptions options) - { - using PipelineMessage message = CreateGetFilesRequestMessage(purpose, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - - [EditorBrowsable(EditorBrowsableState.Never)] - public override async Task GetFilesAsync(string purpose, RequestOptions options) - { - using PipelineMessage message = CreateGetFilesRequestMessage(purpose, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - [EditorBrowsable(EditorBrowsableState.Never)] - public override ClientResult UploadFile(BinaryContent content, string contentType, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - Argument.AssertNotNullOrEmpty(contentType, nameof(contentType)); - - using PipelineMessage message = CreateUploadRequestMessage(content, contentType, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - - [EditorBrowsable(EditorBrowsableState.Never)] - public override async Task UploadFileAsync(BinaryContent content, string contentType, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - Argument.AssertNotNullOrEmpty(contentType, nameof(contentType)); - - using PipelineMessage message = CreateUploadRequestMessage(content, contentType, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - public override async Task CreateUploadAsync(BinaryContent content, RequestOptions options = null) { Argument.AssertNotNull(content, nameof(content)); @@ -150,7 +60,34 @@ public override ClientResult CancelUpload(string uploadId, RequestOptions option return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } - private PipelineMessage CreateDeleteRequestMessage(string fileId, RequestOptions options) + public override async Task CompleteUploadAsync(string uploadId, BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateCompleteUploadRequestMessage(uploadId, content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + public override ClientResult CompleteUpload(string uploadId, BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(uploadId, nameof(uploadId)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateCompleteUploadRequestMessage(uploadId, content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + internal override PipelineMessage CreateCreateFileRequest(BinaryContent content, string contentType, RequestOptions options) + => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) + .WithMethod("POST") + .WithPath("files") + .WithContent(content, contentType) + .WithAccept("application/json") + .WithOptions(options) + .Build(); + + internal override PipelineMessage CreateDeleteFileRequest(string fileId, RequestOptions options) => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) .WithMethod("DELETE") .WithPath("files", fileId) @@ -158,7 +95,7 @@ private PipelineMessage CreateDeleteRequestMessage(string fileId, RequestOptions .WithOptions(options) .Build(); - private PipelineMessage CreateDownloadContentRequestMessage(string fileId, RequestOptions options) + internal override PipelineMessage CreateDownloadFileRequest(string fileId, RequestOptions options) => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) .WithMethod("GET") .WithPath("files", fileId, "content") @@ -166,7 +103,7 @@ private PipelineMessage CreateDownloadContentRequestMessage(string fileId, Reque .WithOptions(options) .Build(); - private PipelineMessage CreateGetFileRequestMessage(string fileId, RequestOptions options) + internal override PipelineMessage CreateRetrieveFileRequest(string fileId, RequestOptions options) => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) .WithMethod("GET") .WithPath("files", fileId) @@ -174,7 +111,7 @@ private PipelineMessage CreateGetFileRequestMessage(string fileId, RequestOption .WithOptions(options) .Build(); - private PipelineMessage CreateGetFilesRequestMessage(string purpose, RequestOptions options) + internal override PipelineMessage CreateListFilesRequest(string purpose, RequestOptions options) => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) .WithMethod("GET") .WithPath("files") @@ -183,15 +120,6 @@ private PipelineMessage CreateGetFilesRequestMessage(string purpose, RequestOpti .WithOptions(options) .Build(); - private PipelineMessage CreateUploadRequestMessage(BinaryContent content, string contentType, RequestOptions options) - => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) - .WithMethod("POST") - .WithPath("files") - .WithContent(content, contentType) - .WithAccept("application/json") - .WithOptions(options) - .Build(); - private PipelineMessage CreateCreateUploadRequestMessage(BinaryContent content, RequestOptions options) => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) .WithMethod("POST") @@ -201,7 +129,7 @@ private PipelineMessage CreateCreateUploadRequestMessage(BinaryContent content, .WithOptions(options) .Build(); - internal PipelineMessage CreateAddUploadPartRequestMessage(string uploadId, BinaryContent content, string contentType, RequestOptions options) + private PipelineMessage CreateAddUploadPartRequestMessage(string uploadId, BinaryContent content, string contentType, RequestOptions options) => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) .WithMethod("POST") .WithPath($"uploads/{uploadId}/parts") diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Images/AzureImageClient.Protocol.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Images/AzureImageClient.Protocol.cs index 81fc8a739..9fb565ea5 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Images/AzureImageClient.Protocol.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Images/AzureImageClient.Protocol.cs @@ -3,59 +3,12 @@ using System.ClientModel; using System.ClientModel.Primitives; -using System.ComponentModel; -using OpenAI.Images; namespace Azure.AI.OpenAI.Images; internal partial class AzureImageClient : ImageClient { - [EditorBrowsable(EditorBrowsableState.Never)] - public override ClientResult GenerateImages(BinaryContent content, RequestOptions options = null) - { - using PipelineMessage message = CreateGenerateImagesRequestMessage(content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - - [EditorBrowsable(EditorBrowsableState.Never)] - public override async Task GenerateImagesAsync(BinaryContent content, RequestOptions options = null) - { - using PipelineMessage message = CreateGenerateImagesRequestMessage(content, options); - PipelineResponse response = await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false); - return ClientResult.FromResponse(response); - } - - [EditorBrowsable(EditorBrowsableState.Never)] - public override ClientResult GenerateImageEdits(BinaryContent content, string contentType, RequestOptions options = null) - { - using PipelineMessage message = CreateGenerateImageEditsRequestMessage(content, contentType, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - - [EditorBrowsable(EditorBrowsableState.Never)] - public override async Task GenerateImageEditsAsync(BinaryContent content, string contentType, RequestOptions options = null) - { - using PipelineMessage message = CreateGenerateImageEditsRequestMessage(content, contentType, options); - PipelineResponse response = await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false); - return ClientResult.FromResponse(response); - } - - [EditorBrowsable(EditorBrowsableState.Never)] - public override ClientResult GenerateImageVariations(BinaryContent content, string contentType, RequestOptions options = null) - { - using PipelineMessage message = CreateGenerateImageVariationsRequestMessage(content, contentType, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - - [EditorBrowsable(EditorBrowsableState.Never)] - public override async Task GenerateImageVariationsAsync(BinaryContent content, string contentType, RequestOptions options = null) - { - using PipelineMessage message = CreateGenerateImageVariationsRequestMessage(content, contentType, options); - PipelineResponse response = await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false); - return ClientResult.FromResponse(response); - } - - private PipelineMessage CreateGenerateImagesRequestMessage(BinaryContent content, RequestOptions options = null) + internal override PipelineMessage CreateCreateImageRequest(BinaryContent content, RequestOptions options) => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion, _deploymentName) .WithMethod("POST") .WithPath("images", "generations") @@ -64,7 +17,7 @@ private PipelineMessage CreateGenerateImagesRequestMessage(BinaryContent content .WithOptions(options) .Build(); - private PipelineMessage CreateGenerateImageEditsRequestMessage(BinaryContent content, string contentType, RequestOptions options = null) + internal override PipelineMessage CreateCreateImageEditRequest(BinaryContent content, string contentType, RequestOptions options) => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion, _deploymentName) .WithMethod("POST") .WithPath("images", "edits") @@ -73,7 +26,7 @@ private PipelineMessage CreateGenerateImageEditsRequestMessage(BinaryContent con .WithOptions(options) .Build(); - private PipelineMessage CreateGenerateImageVariationsRequestMessage(BinaryContent content, string contentType, RequestOptions options = null) + internal override PipelineMessage CreateCreateImageVariationRequest(BinaryContent content, string contentType, RequestOptions options) => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion, _deploymentName) .WithMethod("POST") .WithPath("images", "variations") diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureAddFileToVectorStoreOperation.Protocol.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureAddFileToVectorStoreOperation.Protocol.cs deleted file mode 100644 index 2823bef03..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureAddFileToVectorStoreOperation.Protocol.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#if !AZURE_OPENAI_GA - -using System.ClientModel.Primitives; - -namespace Azure.AI.OpenAI.VectorStores; -internal partial class AzureAddFileToVectorStoreOperation : AddFileToVectorStoreOperation -{ - internal override PipelineMessage CreateGetVectorStoreFileRequest(string vectorStoreId, string fileId, RequestOptions options) - => new AzureOpenAIPipelineMessageBuilder(_pipeline, _endpoint, _apiVersion) - .WithMethod("GET") - .WithPath("vector_stores", vectorStoreId, "files", fileId) - .WithAccept("application/json") - .WithOptions(options) - .Build(); -} - -#endif \ No newline at end of file diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureAddFileToVectorStoreOperation.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureAddFileToVectorStoreOperation.cs deleted file mode 100644 index df60ddb63..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureAddFileToVectorStoreOperation.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#if !AZURE_OPENAI_GA - -using System.ClientModel.Primitives; -using System.ClientModel; -using System.Diagnostics.CodeAnalysis; - -namespace Azure.AI.OpenAI.VectorStores; -[Experimental("OPENAI001")] -internal partial class AzureAddFileToVectorStoreOperation : AddFileToVectorStoreOperation -{ - private readonly string _apiVersion; - private readonly ClientPipeline _pipeline; - private readonly Uri _endpoint; - internal AzureAddFileToVectorStoreOperation( - ClientPipeline pipeline, - Uri endpoint, - ClientResult result, - string apiVersion) - : base(pipeline, endpoint, result) - { - _pipeline = pipeline; - _endpoint = endpoint; - _apiVersion = apiVersion; - } -} - -#endif \ No newline at end of file diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureCreateBatchFileJobOperation.Protocol.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureCreateBatchFileJobOperation.Protocol.cs deleted file mode 100644 index 5315f2bfa..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureCreateBatchFileJobOperation.Protocol.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#if !AZURE_OPENAI_GA - -using System.ClientModel; -using System.ClientModel.Primitives; - -namespace Azure.AI.OpenAI.VectorStores; -internal partial class AzureCreateBatchFileJobOperation -{ - internal override PipelineMessage CreateGetVectorStoreFileBatchRequest(string vectorStoreId, string batchId, RequestOptions options) - => new AzureOpenAIPipelineMessageBuilder(_pipeline, _endpoint, _apiVersion) - .WithMethod("GET") - .WithPath("vector_stores", vectorStoreId, "file_batches", batchId) - .WithAccept("application/json") - .WithOptions(options) - .Build(); - - internal override PipelineMessage CreateCancelVectorStoreFileBatchRequest(string vectorStoreId, string batchId, RequestOptions options) - => new AzureOpenAIPipelineMessageBuilder(_pipeline, _endpoint, _apiVersion) - .WithMethod("POST") - .WithPath("vector_stores", vectorStoreId, "file_batches", batchId, "cancel") - .WithAccept("application/json") - .WithOptions(options) - .Build(); -} - -#endif \ No newline at end of file diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureCreateBatchFileJobOperation.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureCreateBatchFileJobOperation.cs deleted file mode 100644 index 5952c4e14..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureCreateBatchFileJobOperation.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#if !AZURE_OPENAI_GA - -using Azure.Core; -using System.ClientModel.Primitives; -using System.ClientModel; -using System.Diagnostics.CodeAnalysis; - -namespace Azure.AI.OpenAI.VectorStores; - -[Experimental("OPENAI001")] -internal partial class AzureCreateBatchFileJobOperation : CreateBatchFileJobOperation -{ - private readonly ClientPipeline _pipeline; - private readonly Uri _endpoint; - private readonly string _apiVersion; - private readonly string _vectorStoreId; - private readonly string _batchId; - - internal AzureCreateBatchFileJobOperation( - ClientPipeline pipeline, - Uri endpoint, - ClientResult result, - string apiVersion) - : base(pipeline, endpoint, result) - { - _pipeline = pipeline; - _endpoint = endpoint; - _apiVersion = apiVersion; - - _vectorStoreId = Value.VectorStoreId; - _batchId = Value.BatchId; - } -} - -#endif \ No newline at end of file diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureCreateVectorStoreOperation.Protocol.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureCreateVectorStoreOperation.Protocol.cs deleted file mode 100644 index 61e2080cf..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureCreateVectorStoreOperation.Protocol.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#if !AZURE_OPENAI_GA - -using Azure.AI.OpenAI; -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.ComponentModel; -using System.Threading.Tasks; - -namespace Azure.AI.OpenAI.VectorStores; - -internal partial class AzureCreateVectorStoreOperation -{ - internal override PipelineMessage CreateGetVectorStoreRequest(string vectorStoreId, RequestOptions options) - => new AzureOpenAIPipelineMessageBuilder(_pipeline, _endpoint, _apiVersion) - .WithMethod("GET") - .WithPath("vector_stores", vectorStoreId) - .WithAccept("application/json") - .WithOptions(options) - .Build(); -} - -#endif \ No newline at end of file diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureCreateVectorStoreOperation.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureCreateVectorStoreOperation.cs deleted file mode 100644 index 3bb1f927b..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureCreateVectorStoreOperation.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#if !AZURE_OPENAI_GA - -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Diagnostics.CodeAnalysis; - -namespace Azure.AI.OpenAI.VectorStores; - -[Experimental("OPENAI001")] -internal partial class AzureCreateVectorStoreOperation : CreateVectorStoreOperation -{ - private readonly ClientPipeline _pipeline; - private readonly Uri _endpoint; - private readonly string _apiVersion; - - internal AzureCreateVectorStoreOperation( - ClientPipeline pipeline, - Uri endpoint, - ClientResult result, - string apiVersion) - : base(pipeline, endpoint, result) - { - _pipeline = pipeline; - _endpoint = endpoint; - _apiVersion = apiVersion; - } -} - -#endif \ No newline at end of file diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureVectorStoreClient.Protocol.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureVectorStoreClient.Protocol.cs index 5527cf7ea..86f446954 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureVectorStoreClient.Protocol.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureVectorStoreClient.Protocol.cs @@ -16,7 +16,7 @@ public override AsyncCollectionResult GetVectorStoresAsync(int? limit, string or return new AzureAsyncCollectionResult( Pipeline, options, - continuation => CreateGetVectorStoresRequest(limit, order, continuation?.After ?? after, before, options), + continuation => CreateListVectorStoresRequest(limit, order, continuation?.After ?? after, before, options), page => VectorStoreCollectionPageToken.FromResponse(page, limit, order, before), page => ModelReaderWriter.Read(page.GetRawResponse().Content).Data, options?.CancellationToken ?? default); @@ -27,61 +27,11 @@ public override CollectionResult GetVectorStores(int? limit, string order, strin return new AzureCollectionResult( Pipeline, options, - continuation => CreateGetVectorStoresRequest(limit, order, continuation?.After ?? after, before, options), + continuation => CreateListVectorStoresRequest(limit, order, continuation?.After ?? after, before, options), page => VectorStoreCollectionPageToken.FromResponse(page, limit, order, before), page => ModelReaderWriter.Read(page.GetRawResponse().Content).Data); } - internal override async Task GetVectorStoreAsync(string vectorStoreId, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - - using PipelineMessage message = CreateGetVectorStoreRequest(vectorStoreId, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - internal override ClientResult GetVectorStore(string vectorStoreId, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - - using PipelineMessage message = CreateGetVectorStoreRequest(vectorStoreId, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - - public override async Task ModifyVectorStoreAsync(string vectorStoreId, BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateModifyVectorStoreRequest(vectorStoreId, content, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - public override ClientResult ModifyVectorStore(string vectorStoreId, BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateModifyVectorStoreRequest(vectorStoreId, content, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - - public override async Task DeleteVectorStoreAsync(string vectorStoreId, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - - using PipelineMessage message = CreateDeleteVectorStoreRequest(vectorStoreId, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - public override ClientResult DeleteVectorStore(string vectorStoreId, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - - using PipelineMessage message = CreateDeleteVectorStoreRequest(vectorStoreId, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - public override AsyncCollectionResult GetFileAssociationsAsync(string vectorStoreId, int? limit, string order, string after, string before, string filter, RequestOptions options) { Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); @@ -89,7 +39,7 @@ public override AsyncCollectionResult GetFileAssociationsAsync(string vectorStor return new AzureAsyncCollectionResult( Pipeline, options, - continuation => CreateGetVectorStoreFilesRequest(vectorStoreId, limit, order, continuation?.After ?? after, before, filter, options), + continuation => CreateListVectorStoreFilesRequest(vectorStoreId, limit, order, continuation?.After ?? after, before, filter, options), page => VectorStoreFileCollectionPageToken.FromResponse(page, vectorStoreId, limit, order, before, filter), page => ModelReaderWriter.Read(page.GetRawResponse().Content).Data, options?.CancellationToken ?? default); @@ -102,90 +52,12 @@ public override CollectionResult GetFileAssociations(string vectorStoreId, int? return new AzureCollectionResult( Pipeline, options, - continuation => CreateGetVectorStoreFilesRequest(vectorStoreId, limit, order, continuation?.After ?? after, before, filter, options), + continuation => CreateListVectorStoreFilesRequest(vectorStoreId, limit, order, continuation?.After ?? after, before, filter, options), page => VectorStoreFileCollectionPageToken.FromResponse(page, vectorStoreId, limit, order, before, filter), page => ModelReaderWriter.Read(page.GetRawResponse().Content).Data); } - public override async Task AddFileToVectorStoreAsync(string vectorStoreId, BinaryContent content, bool waitUntilCompleted, RequestOptions options = null) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateCreateVectorStoreFileRequest(vectorStoreId, content, options); - PipelineResponse response = await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false); - var result = ClientResult.FromResponse(response); - - AzureAddFileToVectorStoreOperation operation = new(Pipeline, _endpoint, ClientResult.FromValue((VectorStoreFileAssociation)result, response), _apiVersion); - return await operation.WaitUntilAsync(waitUntilCompleted, options).ConfigureAwait(false); - } - - public override AddFileToVectorStoreOperation AddFileToVectorStore(string vectorStoreId, BinaryContent content, bool waitUntilCompleted, RequestOptions options = null) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateCreateVectorStoreFileRequest(vectorStoreId, content, options); - PipelineResponse response = Pipeline.ProcessMessage(message, options); - var result = ClientResult.FromResponse(response); - - AzureAddFileToVectorStoreOperation operation = new(Pipeline, _endpoint, ClientResult.FromValue((VectorStoreFileAssociation)result, response), _apiVersion); - return operation.WaitUntil(waitUntilCompleted, options); - } - - public override async Task RemoveFileFromStoreAsync(string vectorStoreId, string fileId, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - using PipelineMessage message = CreateDeleteVectorStoreFileRequest(vectorStoreId, fileId, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - public override ClientResult RemoveFileFromStore(string vectorStoreId, string fileId, RequestOptions options) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - - using PipelineMessage message = CreateDeleteVectorStoreFileRequest(vectorStoreId, fileId, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); - } - - public override async Task CreateBatchFileJobAsync( - string vectorStoreId, - BinaryContent content, - bool waitUntilCompleted, - RequestOptions options = null) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateCreateVectorStoreFileBatchRequest(vectorStoreId, content, options); - PipelineResponse response = await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false); - var result = ClientResult.FromResponse(response); - - AzureCreateBatchFileJobOperation operation = new(Pipeline, _endpoint, ClientResult.FromValue((VectorStoreBatchFileJob)result, response), _apiVersion); - return await operation.WaitUntilAsync(waitUntilCompleted, options).ConfigureAwait(false); - } - - public override CreateBatchFileJobOperation CreateBatchFileJob( - string vectorStoreId, - BinaryContent content, - bool waitUntilCompleted, - RequestOptions options = null) - { - Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreateCreateVectorStoreFileBatchRequest(vectorStoreId, content, options); - PipelineResponse response = Pipeline.ProcessMessage(message, options); - var result = ClientResult.FromResponse(response); - - AzureCreateBatchFileJobOperation operation = new(Pipeline, _endpoint, ClientResult.FromValue((VectorStoreBatchFileJob)result, response), _apiVersion); - return operation.WaitUntil(waitUntilCompleted, options); - } - - internal override PipelineMessage CreateGetVectorStoresRequest(int? limit, string order, string after, string before, RequestOptions options) + internal override PipelineMessage CreateListVectorStoresRequest(int? limit, string order, string after, string before, RequestOptions options) => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) .WithAssistantsHeader() .WithOptions(options) @@ -220,7 +92,7 @@ internal override PipelineMessage CreateDeleteVectorStoreRequest(string vectorSt .WithOptions(options) .Build(); - internal override PipelineMessage CreateGetVectorStoreFilesRequest(string vectorStoreId, int? limit, string order, string after, string before, string filter, RequestOptions options) + internal override PipelineMessage CreateListVectorStoreFilesRequest(string vectorStoreId, int? limit, string order, string after, string before, string filter, RequestOptions options) => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) .WithAssistantsHeader() .WithOptions(options) @@ -282,7 +154,15 @@ internal override PipelineMessage CreateGetVectorStoreFileBatchRequest(string ve .WithOptions(options) .Build(); - internal override PipelineMessage CreateGetFilesInVectorStoreBatchesRequest(string vectorStoreId, string batchId, int? limit, string order, string after, string before, string filter, RequestOptions options) + internal override PipelineMessage CreateCancelVectorStoreFileBatchRequest(string vectorStoreId, string batchId, RequestOptions options) + => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) + .WithMethod("POST") + .WithPath("vector_stores", vectorStoreId, "file_batches", batchId, "cancel") + .WithAccept("application/json") + .WithOptions(options) + .Build(); + + internal override PipelineMessage CreateListFilesInVectorStoreBatchRequest(string vectorStoreId, string batchId, int? limit, string order, string after, string before, string filter, RequestOptions options) => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) .WithAssistantsHeader() .WithOptions(options) diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureVectorStoreClient.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureVectorStoreClient.cs index 1e07b8803..9790f63bd 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureVectorStoreClient.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureVectorStoreClient.cs @@ -37,17 +37,17 @@ protected AzureVectorStoreClient() internal override CreateVectorStoreOperation CreateCreateVectorStoreOperation(ClientResult result) { - return new AzureCreateVectorStoreOperation(Pipeline, _endpoint, result, _apiVersion); + return new CreateVectorStoreOperation(this, _endpoint, result); } internal override AddFileToVectorStoreOperation CreateAddFileToVectorStoreOperation(ClientResult result) { - return new AzureAddFileToVectorStoreOperation(Pipeline, _endpoint, result, _apiVersion); + return new AddFileToVectorStoreOperation(this, _endpoint, result); } internal override CreateBatchFileJobOperation CreateBatchFileJobOperation(ClientResult result) { - return new AzureCreateBatchFileJobOperation(Pipeline, _endpoint, result, _apiVersion); + return new CreateBatchFileJobOperation(this, _endpoint, result); } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/AssistantTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/AssistantTests.cs index c7eae4a46..fd3b169a1 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/AssistantTests.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/AssistantTests.cs @@ -301,7 +301,7 @@ public async Task ThreadWithInitialMessagesWorks() }; AssistantThread thread = await client.CreateThreadAsync(options); Validate(thread); - List messageList = await client.GetMessagesAsync(thread.Id, new() { Order = MessageCollectionOrder.Ascending }).ToListAsync(); + List messageList = await client.GetMessagesAsync(thread.Id, new() { Order = OpenAIPageOrder.Ascending }).ToListAsync(); Assert.That(messageList.Count, Is.EqualTo(2)); Assert.That(messageList[0].Role, Is.EqualTo(MessageRole.User)); Assert.That(messageList[0].Content?.Count, Is.EqualTo(1)); @@ -481,7 +481,7 @@ public async Task FunctionToolsWork(TestStrictSchemaMode schemaMode) r => r.Status.IsTerminal); Assert.That(run.Status, Is.EqualTo(RunStatus.Completed)); - List messages = await client.GetMessagesAsync(run.ThreadId, new() { Order = MessageCollectionOrder.Descending }) + List messages = await client.GetMessagesAsync(run.ThreadId, new() { Order = OpenAIPageOrder.Descending }) .ToListAsync(); Assert.That(messages.Count, Is.GreaterThan(1)); Assert.That(messages.ElementAt(0).Role, Is.EqualTo(MessageRole.Assistant)); @@ -585,7 +585,7 @@ This file describes the favorite foods of several people. r => r.Status.IsTerminal); Assert.That(run.Status, Is.EqualTo(RunStatus.Completed)); - AsyncCollectionResult messages = client.GetMessagesAsync(thread.Id, new() { Order = MessageCollectionOrder.Descending }); + AsyncCollectionResult messages = client.GetMessagesAsync(thread.Id, new() { Order = OpenAIPageOrder.Descending }); int numThreads = 0; bool hasCake = false; await foreach (ThreadMessage message in messages) diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/VectorStoreTests.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/VectorStoreTests.cs index f38a462d5..1f868fddf 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/VectorStoreTests.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/tests/VectorStoreTests.cs @@ -121,7 +121,7 @@ public async Task CanEnumerateVectorStores() Assert.That(vectorStore.Name, Is.EqualTo($"Test Vector Store {i}")); } - AsyncCollectionResult response = client.GetVectorStoresAsync(new VectorStoreCollectionOptions() { Order = VectorStoreCollectionOrder.Descending }); + AsyncCollectionResult response = client.GetVectorStoresAsync(new OpenAIPageOptions() { Order = OpenAIPageOrder.Descending }); Assert.That(response, Is.Not.Null); int lastIdSeen = int.MaxValue; diff --git a/.dotnet/CHANGELOG.md b/.dotnet/CHANGELOG.md index 34c4a5097..10bc291e8 100644 --- a/.dotnet/CHANGELOG.md +++ b/.dotnet/CHANGELOG.md @@ -2,6 +2,10 @@ ## 2.2.0-beta.2 (2025-02-18) +### `[Experimental]` Breaking changes + +- A number of collection-specific options classes and order enumerations have been consolidated into a shared `OpenAIPageOptions` and `OpenAIPageOrder`. `VectorStoreClient`'s `GetFileAssociations` method now features `fileStatusFilter` as an optional method parameter rather than within a collection-specific options type. + ### Bugs fixed - OpenAI.Chat: diff --git a/.dotnet/README.md b/.dotnet/README.md index 10a815604..e14c6ca94 100644 --- a/.dotnet/README.md +++ b/.dotnet/README.md @@ -656,7 +656,7 @@ For illustrative purposes, you could print the messages to the console and also ```csharp CollectionResult messages - = assistantClient.GetMessages(threadRun.ThreadId, new MessageCollectionOptions() { Order = MessageCollectionOrder.Ascending }); + = assistantClient.GetMessages(threadRun.ThreadId, new OpenAIPageOptions() { Order = OpenAIPageOrder.Ascending }); foreach (ThreadMessage message in messages) { diff --git a/.dotnet/api/OpenAI.net8.0.cs b/.dotnet/api/OpenAI.net8.0.cs index 907ff7eac..3308a2a4d 100644 --- a/.dotnet/api/OpenAI.net8.0.cs +++ b/.dotnet/api/OpenAI.net8.0.cs @@ -30,6 +30,28 @@ public class OpenAIClientOptions : ClientPipelineOptions { public string ProjectId { get; set; } public string UserAgentApplicationId { get; set; } } + [Experimental("OPENAI001")] + public class OpenAIPageOptions { + public string AfterId { get; set; } + public string BeforeId { get; set; } + public OpenAIPageOrder? Order { get; set; } + public int? PageSizeLimit { get; set; } + } + [Experimental("OPENAI001")] + public readonly partial struct OpenAIPageOrder : IEquatable { + public OpenAIPageOrder(string value); + public static OpenAIPageOrder Ascending { get; } + public static OpenAIPageOrder Descending { get; } + public readonly bool Equals(OpenAIPageOrder other); + [EditorBrowsable(EditorBrowsableState.Never)] + public override readonly bool Equals(object obj); + [EditorBrowsable(EditorBrowsableState.Never)] + public override readonly int GetHashCode(); + public static bool operator ==(OpenAIPageOrder left, OpenAIPageOrder right); + public static implicit operator OpenAIPageOrder(string value); + public static bool operator !=(OpenAIPageOrder left, OpenAIPageOrder right); + public override readonly string ToString(); + } } namespace OpenAI.Assistants { [Experimental("OPENAI001")] @@ -121,11 +143,11 @@ public class AssistantClient { [EditorBrowsable(EditorBrowsableState.Never)] public virtual Task GetAssistantAsync(string assistantId, RequestOptions options); public virtual Task> GetAssistantAsync(string assistantId, CancellationToken cancellationToken = default); - public virtual CollectionResult GetAssistants(AssistantCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual CollectionResult GetAssistants(OpenAIPageOptions options = null, CancellationToken cancellationToken = default); public virtual CollectionResult GetAssistants(ContinuationToken firstPageToken, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual CollectionResult GetAssistants(int? limit, string order, string after, string before, RequestOptions options); - public virtual AsyncCollectionResult GetAssistantsAsync(AssistantCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual AsyncCollectionResult GetAssistantsAsync(OpenAIPageOptions options = null, CancellationToken cancellationToken = default); public virtual AsyncCollectionResult GetAssistantsAsync(ContinuationToken firstPageToken, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual AsyncCollectionResult GetAssistantsAsync(int? limit, string order, string after, string before, RequestOptions options); @@ -136,11 +158,11 @@ public class AssistantClient { public virtual Task GetMessageAsync(string threadId, string messageId, RequestOptions options); public virtual Task> GetMessageAsync(string threadId, string messageId, CancellationToken cancellationToken = default); public virtual CollectionResult GetMessages(ContinuationToken firstPageToken, CancellationToken cancellationToken = default); - public virtual CollectionResult GetMessages(string threadId, MessageCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual CollectionResult GetMessages(string threadId, OpenAIPageOptions options = null, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual CollectionResult GetMessages(string threadId, int? limit, string order, string after, string before, RequestOptions options); public virtual AsyncCollectionResult GetMessagesAsync(ContinuationToken firstPageToken, CancellationToken cancellationToken = default); - public virtual AsyncCollectionResult GetMessagesAsync(string threadId, MessageCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual AsyncCollectionResult GetMessagesAsync(string threadId, OpenAIPageOptions options = null, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual AsyncCollectionResult GetMessagesAsync(string threadId, int? limit, string order, string after, string before, RequestOptions options); [EditorBrowsable(EditorBrowsableState.Never)] @@ -150,11 +172,11 @@ public class AssistantClient { public virtual Task GetRunAsync(string threadId, string runId, RequestOptions options); public virtual Task> GetRunAsync(string threadId, string runId, CancellationToken cancellationToken = default); public virtual CollectionResult GetRuns(ContinuationToken firstPageToken, CancellationToken cancellationToken = default); - public virtual CollectionResult GetRuns(string threadId, RunCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual CollectionResult GetRuns(string threadId, OpenAIPageOptions options = null, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual CollectionResult GetRuns(string threadId, int? limit, string order, string after, string before, RequestOptions options); public virtual AsyncCollectionResult GetRunsAsync(ContinuationToken firstPageToken, CancellationToken cancellationToken = default); - public virtual AsyncCollectionResult GetRunsAsync(string threadId, RunCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual AsyncCollectionResult GetRunsAsync(string threadId, OpenAIPageOptions options = null, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual AsyncCollectionResult GetRunsAsync(string threadId, int? limit, string order, string after, string before, RequestOptions options); [EditorBrowsable(EditorBrowsableState.Never)] @@ -164,11 +186,11 @@ public class AssistantClient { public virtual Task GetRunStepAsync(string threadId, string runId, string stepId, RequestOptions options); public virtual Task> GetRunStepAsync(string threadId, string runId, string stepId, CancellationToken cancellationToken = default); public virtual CollectionResult GetRunSteps(ContinuationToken firstPageToken, CancellationToken cancellationToken = default); - public virtual CollectionResult GetRunSteps(string threadId, string runId, RunStepCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual CollectionResult GetRunSteps(string threadId, string runId, OpenAIPageOptions options = null, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual CollectionResult GetRunSteps(string threadId, string runId, int? limit, string order, string after, string before, RequestOptions options); public virtual AsyncCollectionResult GetRunStepsAsync(ContinuationToken firstPageToken, CancellationToken cancellationToken = default); - public virtual AsyncCollectionResult GetRunStepsAsync(string threadId, string runId, RunStepCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual AsyncCollectionResult GetRunStepsAsync(string threadId, string runId, OpenAIPageOptions options = null, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual AsyncCollectionResult GetRunStepsAsync(string threadId, string runId, int? limit, string order, string after, string before, RequestOptions options); [EditorBrowsable(EditorBrowsableState.Never)] @@ -209,28 +231,6 @@ public class AssistantClient { public virtual AsyncCollectionResult SubmitToolOutputsToRunStreamingAsync(string threadId, string runId, IEnumerable toolOutputs, CancellationToken cancellationToken = default); } [Experimental("OPENAI001")] - public class AssistantCollectionOptions { - public string AfterId { get; set; } - public string BeforeId { get; set; } - public AssistantCollectionOrder? Order { get; set; } - public int? PageSizeLimit { get; set; } - } - [Experimental("OPENAI001")] - public readonly partial struct AssistantCollectionOrder : IEquatable { - public AssistantCollectionOrder(string value); - public static AssistantCollectionOrder Ascending { get; } - public static AssistantCollectionOrder Descending { get; } - public readonly bool Equals(AssistantCollectionOrder other); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly bool Equals(object obj); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly int GetHashCode(); - public static bool operator ==(AssistantCollectionOrder left, AssistantCollectionOrder right); - public static implicit operator AssistantCollectionOrder(string value); - public static bool operator !=(AssistantCollectionOrder left, AssistantCollectionOrder right); - public override readonly string ToString(); - } - [Experimental("OPENAI001")] public class AssistantCreationOptions : IJsonModel, IPersistableModel { public string Description { get; set; } public string Instructions { get; set; } @@ -365,28 +365,6 @@ public class FunctionToolDefinition : ToolDefinition, IJsonModel { - public MessageCollectionOrder(string value); - public static MessageCollectionOrder Ascending { get; } - public static MessageCollectionOrder Descending { get; } - public readonly bool Equals(MessageCollectionOrder other); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly bool Equals(object obj); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly int GetHashCode(); - public static bool operator ==(MessageCollectionOrder left, MessageCollectionOrder right); - public static implicit operator MessageCollectionOrder(string value); - public static bool operator !=(MessageCollectionOrder left, MessageCollectionOrder right); - public override readonly string ToString(); - } - [Experimental("OPENAI001")] public abstract class MessageContent : IJsonModel, IPersistableModel { public MessageImageDetail? ImageDetail { get; } public string ImageFileId { get; } @@ -508,28 +486,6 @@ public class RequiredActionUpdate : RunUpdate { public ThreadRun GetThreadRun(); } [Experimental("OPENAI001")] - public class RunCollectionOptions { - public string AfterId { get; set; } - public string BeforeId { get; set; } - public RunCollectionOrder? Order { get; set; } - public int? PageSizeLimit { get; set; } - } - [Experimental("OPENAI001")] - public readonly partial struct RunCollectionOrder : IEquatable { - public RunCollectionOrder(string value); - public static RunCollectionOrder Ascending { get; } - public static RunCollectionOrder Descending { get; } - public readonly bool Equals(RunCollectionOrder other); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly bool Equals(object obj); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly int GetHashCode(); - public static bool operator ==(RunCollectionOrder left, RunCollectionOrder right); - public static implicit operator RunCollectionOrder(string value); - public static bool operator !=(RunCollectionOrder left, RunCollectionOrder right); - public override readonly string ToString(); - } - [Experimental("OPENAI001")] public class RunCreationOptions : IJsonModel, IPersistableModel { public string AdditionalInstructions { get; set; } public IList AdditionalMessages { get; } @@ -649,28 +605,6 @@ public abstract class RunStepCodeInterpreterOutput : IJsonModel { - public RunStepCollectionOrder(string value); - public static RunStepCollectionOrder Ascending { get; } - public static RunStepCollectionOrder Descending { get; } - public readonly bool Equals(RunStepCollectionOrder other); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly bool Equals(object obj); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly int GetHashCode(); - public static bool operator ==(RunStepCollectionOrder left, RunStepCollectionOrder right); - public static implicit operator RunStepCollectionOrder(string value); - public static bool operator !=(RunStepCollectionOrder left, RunStepCollectionOrder right); - public override readonly string ToString(); - } - [Experimental("OPENAI001")] public abstract class RunStepDetails : IJsonModel, IPersistableModel { public string CreatedMessageId { get; } public IReadOnlyList ToolCalls { get; } @@ -2979,27 +2913,27 @@ public class VectorStoreClient { public virtual Task GetFileAssociationAsync(string vectorStoreId, string fileId, RequestOptions options); public virtual Task> GetFileAssociationAsync(string vectorStoreId, string fileId, CancellationToken cancellationToken = default); public virtual CollectionResult GetFileAssociations(ContinuationToken firstPageToken, CancellationToken cancellationToken = default); - public virtual CollectionResult GetFileAssociations(string vectorStoreId, VectorStoreFileAssociationCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual CollectionResult GetFileAssociations(string vectorStoreId, OpenAIPageOptions options = null, VectorStoreFileStatusFilter? fileStatusFilter = null, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual CollectionResult GetFileAssociations(string vectorStoreId, int? limit, string order, string after, string before, string filter, RequestOptions options); - public virtual CollectionResult GetFileAssociations(string vectorStoreId, string batchJobId, VectorStoreFileAssociationCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual CollectionResult GetFileAssociations(string vectorStoreId, string batchJobId, OpenAIPageOptions options = null, VectorStoreFileStatusFilter? fileStatusFilter = null, CancellationToken cancellationToken = default); public virtual CollectionResult GetFileAssociations(string vectorStoreId, string batchJobId, ContinuationToken firstPageToken, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual CollectionResult GetFileAssociations(string vectorStoreId, string batchId, int? limit, string order, string after, string before, string filter, RequestOptions options); public virtual AsyncCollectionResult GetFileAssociationsAsync(ContinuationToken firstPageToken, CancellationToken cancellationToken = default); - public virtual AsyncCollectionResult GetFileAssociationsAsync(string vectorStoreId, VectorStoreFileAssociationCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual AsyncCollectionResult GetFileAssociationsAsync(string vectorStoreId, OpenAIPageOptions options = null, VectorStoreFileStatusFilter? fileStatusFilter = null, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual AsyncCollectionResult GetFileAssociationsAsync(string vectorStoreId, int? limit, string order, string after, string before, string filter, RequestOptions options); - public virtual AsyncCollectionResult GetFileAssociationsAsync(string vectorStoreId, string batchJobId, VectorStoreFileAssociationCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual AsyncCollectionResult GetFileAssociationsAsync(string vectorStoreId, string batchJobId, OpenAIPageOptions options = null, VectorStoreFileStatusFilter? fileStatusFilter = null, CancellationToken cancellationToken = default); public virtual AsyncCollectionResult GetFileAssociationsAsync(string vectorStoreId, string batchJobId, ContinuationToken firstPageToken, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual AsyncCollectionResult GetFileAssociationsAsync(string vectorStoreId, string batchId, int? limit, string order, string after, string before, string filter, RequestOptions options); public virtual ClientResult GetVectorStore(string vectorStoreId, CancellationToken cancellationToken = default); - public virtual CollectionResult GetVectorStores(VectorStoreCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual CollectionResult GetVectorStores(OpenAIPageOptions options = null, CancellationToken cancellationToken = default); public virtual CollectionResult GetVectorStores(ContinuationToken firstPageToken, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual CollectionResult GetVectorStores(int? limit, string order, string after, string before, RequestOptions options); - public virtual AsyncCollectionResult GetVectorStoresAsync(VectorStoreCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual AsyncCollectionResult GetVectorStoresAsync(OpenAIPageOptions options = null, CancellationToken cancellationToken = default); public virtual AsyncCollectionResult GetVectorStoresAsync(ContinuationToken firstPageToken, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual AsyncCollectionResult GetVectorStoresAsync(int? limit, string order, string after, string before, RequestOptions options); @@ -3017,28 +2951,6 @@ public class VectorStoreClient { public virtual Task> RemoveFileFromStoreAsync(string vectorStoreId, string fileId, CancellationToken cancellationToken = default); } [Experimental("OPENAI001")] - public class VectorStoreCollectionOptions { - public string AfterId { get; set; } - public string BeforeId { get; set; } - public VectorStoreCollectionOrder? Order { get; set; } - public int? PageSizeLimit { get; set; } - } - [Experimental("OPENAI001")] - public readonly partial struct VectorStoreCollectionOrder : IEquatable { - public VectorStoreCollectionOrder(string value); - public static VectorStoreCollectionOrder Ascending { get; } - public static VectorStoreCollectionOrder Descending { get; } - public readonly bool Equals(VectorStoreCollectionOrder other); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly bool Equals(object obj); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly int GetHashCode(); - public static bool operator ==(VectorStoreCollectionOrder left, VectorStoreCollectionOrder right); - public static implicit operator VectorStoreCollectionOrder(string value); - public static bool operator !=(VectorStoreCollectionOrder left, VectorStoreCollectionOrder right); - public override readonly string ToString(); - } - [Experimental("OPENAI001")] public class VectorStoreCreationOptions : IJsonModel, IPersistableModel { public FileChunkingStrategy ChunkingStrategy { get; set; } public VectorStoreExpirationPolicy ExpirationPolicy { get; set; } @@ -3083,29 +2995,6 @@ public class VectorStoreFileAssociation : IJsonModel public static implicit operator BinaryContent(VectorStoreFileAssociation vectorStoreFileAssociation); } [Experimental("OPENAI001")] - public class VectorStoreFileAssociationCollectionOptions { - public string AfterId { get; set; } - public string BeforeId { get; set; } - public VectorStoreFileStatusFilter? Filter { get; set; } - public VectorStoreFileAssociationCollectionOrder? Order { get; set; } - public int? PageSizeLimit { get; set; } - } - [Experimental("OPENAI001")] - public readonly partial struct VectorStoreFileAssociationCollectionOrder : IEquatable { - public VectorStoreFileAssociationCollectionOrder(string value); - public static VectorStoreFileAssociationCollectionOrder Ascending { get; } - public static VectorStoreFileAssociationCollectionOrder Descending { get; } - public readonly bool Equals(VectorStoreFileAssociationCollectionOrder other); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly bool Equals(object obj); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly int GetHashCode(); - public static bool operator ==(VectorStoreFileAssociationCollectionOrder left, VectorStoreFileAssociationCollectionOrder right); - public static implicit operator VectorStoreFileAssociationCollectionOrder(string value); - public static bool operator !=(VectorStoreFileAssociationCollectionOrder left, VectorStoreFileAssociationCollectionOrder right); - public override readonly string ToString(); - } - [Experimental("OPENAI001")] public class VectorStoreFileAssociationError : IJsonModel, IPersistableModel { public VectorStoreFileAssociationErrorCode Code { get; } public string Message { get; } diff --git a/.dotnet/api/OpenAI.netstandard2.0.cs b/.dotnet/api/OpenAI.netstandard2.0.cs index f47434267..298134899 100644 --- a/.dotnet/api/OpenAI.netstandard2.0.cs +++ b/.dotnet/api/OpenAI.netstandard2.0.cs @@ -25,6 +25,26 @@ public class OpenAIClientOptions : ClientPipelineOptions { public string ProjectId { get; set; } public string UserAgentApplicationId { get; set; } } + public class OpenAIPageOptions { + public string AfterId { get; set; } + public string BeforeId { get; set; } + public OpenAIPageOrder? Order { get; set; } + public int? PageSizeLimit { get; set; } + } + public readonly partial struct OpenAIPageOrder : IEquatable { + public OpenAIPageOrder(string value); + public static OpenAIPageOrder Ascending { get; } + public static OpenAIPageOrder Descending { get; } + public readonly bool Equals(OpenAIPageOrder other); + [EditorBrowsable(EditorBrowsableState.Never)] + public override readonly bool Equals(object obj); + [EditorBrowsable(EditorBrowsableState.Never)] + public override readonly int GetHashCode(); + public static bool operator ==(OpenAIPageOrder left, OpenAIPageOrder right); + public static implicit operator OpenAIPageOrder(string value); + public static bool operator !=(OpenAIPageOrder left, OpenAIPageOrder right); + public override readonly string ToString(); + } } namespace OpenAI.Assistants { public class Assistant : IJsonModel, IPersistableModel { @@ -114,11 +134,11 @@ public class AssistantClient { [EditorBrowsable(EditorBrowsableState.Never)] public virtual Task GetAssistantAsync(string assistantId, RequestOptions options); public virtual Task> GetAssistantAsync(string assistantId, CancellationToken cancellationToken = default); - public virtual CollectionResult GetAssistants(AssistantCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual CollectionResult GetAssistants(OpenAIPageOptions options = null, CancellationToken cancellationToken = default); public virtual CollectionResult GetAssistants(ContinuationToken firstPageToken, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual CollectionResult GetAssistants(int? limit, string order, string after, string before, RequestOptions options); - public virtual AsyncCollectionResult GetAssistantsAsync(AssistantCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual AsyncCollectionResult GetAssistantsAsync(OpenAIPageOptions options = null, CancellationToken cancellationToken = default); public virtual AsyncCollectionResult GetAssistantsAsync(ContinuationToken firstPageToken, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual AsyncCollectionResult GetAssistantsAsync(int? limit, string order, string after, string before, RequestOptions options); @@ -129,11 +149,11 @@ public class AssistantClient { public virtual Task GetMessageAsync(string threadId, string messageId, RequestOptions options); public virtual Task> GetMessageAsync(string threadId, string messageId, CancellationToken cancellationToken = default); public virtual CollectionResult GetMessages(ContinuationToken firstPageToken, CancellationToken cancellationToken = default); - public virtual CollectionResult GetMessages(string threadId, MessageCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual CollectionResult GetMessages(string threadId, OpenAIPageOptions options = null, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual CollectionResult GetMessages(string threadId, int? limit, string order, string after, string before, RequestOptions options); public virtual AsyncCollectionResult GetMessagesAsync(ContinuationToken firstPageToken, CancellationToken cancellationToken = default); - public virtual AsyncCollectionResult GetMessagesAsync(string threadId, MessageCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual AsyncCollectionResult GetMessagesAsync(string threadId, OpenAIPageOptions options = null, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual AsyncCollectionResult GetMessagesAsync(string threadId, int? limit, string order, string after, string before, RequestOptions options); [EditorBrowsable(EditorBrowsableState.Never)] @@ -143,11 +163,11 @@ public class AssistantClient { public virtual Task GetRunAsync(string threadId, string runId, RequestOptions options); public virtual Task> GetRunAsync(string threadId, string runId, CancellationToken cancellationToken = default); public virtual CollectionResult GetRuns(ContinuationToken firstPageToken, CancellationToken cancellationToken = default); - public virtual CollectionResult GetRuns(string threadId, RunCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual CollectionResult GetRuns(string threadId, OpenAIPageOptions options = null, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual CollectionResult GetRuns(string threadId, int? limit, string order, string after, string before, RequestOptions options); public virtual AsyncCollectionResult GetRunsAsync(ContinuationToken firstPageToken, CancellationToken cancellationToken = default); - public virtual AsyncCollectionResult GetRunsAsync(string threadId, RunCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual AsyncCollectionResult GetRunsAsync(string threadId, OpenAIPageOptions options = null, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual AsyncCollectionResult GetRunsAsync(string threadId, int? limit, string order, string after, string before, RequestOptions options); [EditorBrowsable(EditorBrowsableState.Never)] @@ -157,11 +177,11 @@ public class AssistantClient { public virtual Task GetRunStepAsync(string threadId, string runId, string stepId, RequestOptions options); public virtual Task> GetRunStepAsync(string threadId, string runId, string stepId, CancellationToken cancellationToken = default); public virtual CollectionResult GetRunSteps(ContinuationToken firstPageToken, CancellationToken cancellationToken = default); - public virtual CollectionResult GetRunSteps(string threadId, string runId, RunStepCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual CollectionResult GetRunSteps(string threadId, string runId, OpenAIPageOptions options = null, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual CollectionResult GetRunSteps(string threadId, string runId, int? limit, string order, string after, string before, RequestOptions options); public virtual AsyncCollectionResult GetRunStepsAsync(ContinuationToken firstPageToken, CancellationToken cancellationToken = default); - public virtual AsyncCollectionResult GetRunStepsAsync(string threadId, string runId, RunStepCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual AsyncCollectionResult GetRunStepsAsync(string threadId, string runId, OpenAIPageOptions options = null, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual AsyncCollectionResult GetRunStepsAsync(string threadId, string runId, int? limit, string order, string after, string before, RequestOptions options); [EditorBrowsable(EditorBrowsableState.Never)] @@ -201,26 +221,6 @@ public class AssistantClient { public virtual CollectionResult SubmitToolOutputsToRunStreaming(string threadId, string runId, IEnumerable toolOutputs, CancellationToken cancellationToken = default); public virtual AsyncCollectionResult SubmitToolOutputsToRunStreamingAsync(string threadId, string runId, IEnumerable toolOutputs, CancellationToken cancellationToken = default); } - public class AssistantCollectionOptions { - public string AfterId { get; set; } - public string BeforeId { get; set; } - public AssistantCollectionOrder? Order { get; set; } - public int? PageSizeLimit { get; set; } - } - public readonly partial struct AssistantCollectionOrder : IEquatable { - public AssistantCollectionOrder(string value); - public static AssistantCollectionOrder Ascending { get; } - public static AssistantCollectionOrder Descending { get; } - public readonly bool Equals(AssistantCollectionOrder other); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly bool Equals(object obj); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly int GetHashCode(); - public static bool operator ==(AssistantCollectionOrder left, AssistantCollectionOrder right); - public static implicit operator AssistantCollectionOrder(string value); - public static bool operator !=(AssistantCollectionOrder left, AssistantCollectionOrder right); - public override readonly string ToString(); - } public class AssistantCreationOptions : IJsonModel, IPersistableModel { public string Description { get; set; } public string Instructions { get; set; } @@ -341,26 +341,6 @@ public class FunctionToolDefinition : ToolDefinition, IJsonModel { - public MessageCollectionOrder(string value); - public static MessageCollectionOrder Ascending { get; } - public static MessageCollectionOrder Descending { get; } - public readonly bool Equals(MessageCollectionOrder other); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly bool Equals(object obj); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly int GetHashCode(); - public static bool operator ==(MessageCollectionOrder left, MessageCollectionOrder right); - public static implicit operator MessageCollectionOrder(string value); - public static bool operator !=(MessageCollectionOrder left, MessageCollectionOrder right); - public override readonly string ToString(); - } public abstract class MessageContent : IJsonModel, IPersistableModel { public MessageImageDetail? ImageDetail { get; } public string ImageFileId { get; } @@ -468,26 +448,6 @@ public class RequiredActionUpdate : RunUpdate { public string ToolCallId { get; } public ThreadRun GetThreadRun(); } - public class RunCollectionOptions { - public string AfterId { get; set; } - public string BeforeId { get; set; } - public RunCollectionOrder? Order { get; set; } - public int? PageSizeLimit { get; set; } - } - public readonly partial struct RunCollectionOrder : IEquatable { - public RunCollectionOrder(string value); - public static RunCollectionOrder Ascending { get; } - public static RunCollectionOrder Descending { get; } - public readonly bool Equals(RunCollectionOrder other); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly bool Equals(object obj); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly int GetHashCode(); - public static bool operator ==(RunCollectionOrder left, RunCollectionOrder right); - public static implicit operator RunCollectionOrder(string value); - public static bool operator !=(RunCollectionOrder left, RunCollectionOrder right); - public override readonly string ToString(); - } public class RunCreationOptions : IJsonModel, IPersistableModel { public string AdditionalInstructions { get; set; } public IList AdditionalMessages { get; } @@ -598,26 +558,6 @@ public abstract class RunStepCodeInterpreterOutput : IJsonModel { - public RunStepCollectionOrder(string value); - public static RunStepCollectionOrder Ascending { get; } - public static RunStepCollectionOrder Descending { get; } - public readonly bool Equals(RunStepCollectionOrder other); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly bool Equals(object obj); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly int GetHashCode(); - public static bool operator ==(RunStepCollectionOrder left, RunStepCollectionOrder right); - public static implicit operator RunStepCollectionOrder(string value); - public static bool operator !=(RunStepCollectionOrder left, RunStepCollectionOrder right); - public override readonly string ToString(); - } public abstract class RunStepDetails : IJsonModel, IPersistableModel { public string CreatedMessageId { get; } public IReadOnlyList ToolCalls { get; } @@ -2816,27 +2756,27 @@ public class VectorStoreClient { public virtual Task GetFileAssociationAsync(string vectorStoreId, string fileId, RequestOptions options); public virtual Task> GetFileAssociationAsync(string vectorStoreId, string fileId, CancellationToken cancellationToken = default); public virtual CollectionResult GetFileAssociations(ContinuationToken firstPageToken, CancellationToken cancellationToken = default); - public virtual CollectionResult GetFileAssociations(string vectorStoreId, VectorStoreFileAssociationCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual CollectionResult GetFileAssociations(string vectorStoreId, OpenAIPageOptions options = null, VectorStoreFileStatusFilter? fileStatusFilter = null, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual CollectionResult GetFileAssociations(string vectorStoreId, int? limit, string order, string after, string before, string filter, RequestOptions options); - public virtual CollectionResult GetFileAssociations(string vectorStoreId, string batchJobId, VectorStoreFileAssociationCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual CollectionResult GetFileAssociations(string vectorStoreId, string batchJobId, OpenAIPageOptions options = null, VectorStoreFileStatusFilter? fileStatusFilter = null, CancellationToken cancellationToken = default); public virtual CollectionResult GetFileAssociations(string vectorStoreId, string batchJobId, ContinuationToken firstPageToken, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual CollectionResult GetFileAssociations(string vectorStoreId, string batchId, int? limit, string order, string after, string before, string filter, RequestOptions options); public virtual AsyncCollectionResult GetFileAssociationsAsync(ContinuationToken firstPageToken, CancellationToken cancellationToken = default); - public virtual AsyncCollectionResult GetFileAssociationsAsync(string vectorStoreId, VectorStoreFileAssociationCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual AsyncCollectionResult GetFileAssociationsAsync(string vectorStoreId, OpenAIPageOptions options = null, VectorStoreFileStatusFilter? fileStatusFilter = null, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual AsyncCollectionResult GetFileAssociationsAsync(string vectorStoreId, int? limit, string order, string after, string before, string filter, RequestOptions options); - public virtual AsyncCollectionResult GetFileAssociationsAsync(string vectorStoreId, string batchJobId, VectorStoreFileAssociationCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual AsyncCollectionResult GetFileAssociationsAsync(string vectorStoreId, string batchJobId, OpenAIPageOptions options = null, VectorStoreFileStatusFilter? fileStatusFilter = null, CancellationToken cancellationToken = default); public virtual AsyncCollectionResult GetFileAssociationsAsync(string vectorStoreId, string batchJobId, ContinuationToken firstPageToken, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual AsyncCollectionResult GetFileAssociationsAsync(string vectorStoreId, string batchId, int? limit, string order, string after, string before, string filter, RequestOptions options); public virtual ClientResult GetVectorStore(string vectorStoreId, CancellationToken cancellationToken = default); - public virtual CollectionResult GetVectorStores(VectorStoreCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual CollectionResult GetVectorStores(OpenAIPageOptions options = null, CancellationToken cancellationToken = default); public virtual CollectionResult GetVectorStores(ContinuationToken firstPageToken, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual CollectionResult GetVectorStores(int? limit, string order, string after, string before, RequestOptions options); - public virtual AsyncCollectionResult GetVectorStoresAsync(VectorStoreCollectionOptions options = null, CancellationToken cancellationToken = default); + public virtual AsyncCollectionResult GetVectorStoresAsync(OpenAIPageOptions options = null, CancellationToken cancellationToken = default); public virtual AsyncCollectionResult GetVectorStoresAsync(ContinuationToken firstPageToken, CancellationToken cancellationToken = default); [EditorBrowsable(EditorBrowsableState.Never)] public virtual AsyncCollectionResult GetVectorStoresAsync(int? limit, string order, string after, string before, RequestOptions options); @@ -2853,26 +2793,6 @@ public class VectorStoreClient { public virtual Task RemoveFileFromStoreAsync(string vectorStoreId, string fileId, RequestOptions options); public virtual Task> RemoveFileFromStoreAsync(string vectorStoreId, string fileId, CancellationToken cancellationToken = default); } - public class VectorStoreCollectionOptions { - public string AfterId { get; set; } - public string BeforeId { get; set; } - public VectorStoreCollectionOrder? Order { get; set; } - public int? PageSizeLimit { get; set; } - } - public readonly partial struct VectorStoreCollectionOrder : IEquatable { - public VectorStoreCollectionOrder(string value); - public static VectorStoreCollectionOrder Ascending { get; } - public static VectorStoreCollectionOrder Descending { get; } - public readonly bool Equals(VectorStoreCollectionOrder other); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly bool Equals(object obj); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly int GetHashCode(); - public static bool operator ==(VectorStoreCollectionOrder left, VectorStoreCollectionOrder right); - public static implicit operator VectorStoreCollectionOrder(string value); - public static bool operator !=(VectorStoreCollectionOrder left, VectorStoreCollectionOrder right); - public override readonly string ToString(); - } public class VectorStoreCreationOptions : IJsonModel, IPersistableModel { public FileChunkingStrategy ChunkingStrategy { get; set; } public VectorStoreExpirationPolicy ExpirationPolicy { get; set; } @@ -2911,27 +2831,6 @@ public class VectorStoreFileAssociation : IJsonModel public static explicit operator VectorStoreFileAssociation(ClientResult result); public static implicit operator BinaryContent(VectorStoreFileAssociation vectorStoreFileAssociation); } - public class VectorStoreFileAssociationCollectionOptions { - public string AfterId { get; set; } - public string BeforeId { get; set; } - public VectorStoreFileStatusFilter? Filter { get; set; } - public VectorStoreFileAssociationCollectionOrder? Order { get; set; } - public int? PageSizeLimit { get; set; } - } - public readonly partial struct VectorStoreFileAssociationCollectionOrder : IEquatable { - public VectorStoreFileAssociationCollectionOrder(string value); - public static VectorStoreFileAssociationCollectionOrder Ascending { get; } - public static VectorStoreFileAssociationCollectionOrder Descending { get; } - public readonly bool Equals(VectorStoreFileAssociationCollectionOrder other); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly bool Equals(object obj); - [EditorBrowsable(EditorBrowsableState.Never)] - public override readonly int GetHashCode(); - public static bool operator ==(VectorStoreFileAssociationCollectionOrder left, VectorStoreFileAssociationCollectionOrder right); - public static implicit operator VectorStoreFileAssociationCollectionOrder(string value); - public static bool operator !=(VectorStoreFileAssociationCollectionOrder left, VectorStoreFileAssociationCollectionOrder right); - public override readonly string ToString(); - } public class VectorStoreFileAssociationError : IJsonModel, IPersistableModel { public VectorStoreFileAssociationErrorCode Code { get; } public string Message { get; } diff --git a/.dotnet/examples/Assistants/Example01_RetrievalAugmentedGeneration.cs b/.dotnet/examples/Assistants/Example01_RetrievalAugmentedGeneration.cs index 530f2b744..9e1849842 100644 --- a/.dotnet/examples/Assistants/Example01_RetrievalAugmentedGeneration.cs +++ b/.dotnet/examples/Assistants/Example01_RetrievalAugmentedGeneration.cs @@ -98,7 +98,7 @@ public void Example01_RetrievalAugmentedGeneration() // Finally, we'll print out the full history for the thread that includes the augmented generation CollectionResult messages - = assistantClient.GetMessages(threadRun.ThreadId, new MessageCollectionOptions() { Order = MessageCollectionOrder.Ascending }); + = assistantClient.GetMessages(threadRun.ThreadId, new OpenAIPageOptions() { Order = OpenAIPageOrder.Ascending }); foreach (ThreadMessage message in messages) { diff --git a/.dotnet/examples/Assistants/Example01_RetrievalAugmentedGenerationAsync.cs b/.dotnet/examples/Assistants/Example01_RetrievalAugmentedGenerationAsync.cs index 7f07a57eb..a90454372 100644 --- a/.dotnet/examples/Assistants/Example01_RetrievalAugmentedGenerationAsync.cs +++ b/.dotnet/examples/Assistants/Example01_RetrievalAugmentedGenerationAsync.cs @@ -99,7 +99,7 @@ public async Task Example01_RetrievalAugmentedGenerationAsync() // Finally, we'll print out the full history for the thread that includes the augmented generation AsyncCollectionResult messages - = assistantClient.GetMessagesAsync(threadRun.ThreadId, new MessageCollectionOptions() { Order = MessageCollectionOrder.Ascending }); + = assistantClient.GetMessagesAsync(threadRun.ThreadId, new OpenAIPageOptions() { Order = OpenAIPageOrder.Ascending }); await foreach (ThreadMessage message in messages) { diff --git a/.dotnet/examples/Assistants/Example02_FunctionCalling.cs b/.dotnet/examples/Assistants/Example02_FunctionCalling.cs index aed48c9b1..13471919f 100644 --- a/.dotnet/examples/Assistants/Example02_FunctionCalling.cs +++ b/.dotnet/examples/Assistants/Example02_FunctionCalling.cs @@ -151,7 +151,7 @@ string GetCurrentWeather(string location, string unit = "celsius") if (run.Status == RunStatus.Completed) { CollectionResult messages - = client.GetMessages(run.ThreadId, new MessageCollectionOptions() { Order = MessageCollectionOrder.Ascending }); + = client.GetMessages(run.ThreadId, new OpenAIPageOptions() { Order = OpenAIPageOrder.Ascending }); foreach (ThreadMessage message in messages) { diff --git a/.dotnet/examples/Assistants/Example02_FunctionCallingAsync.cs b/.dotnet/examples/Assistants/Example02_FunctionCallingAsync.cs index 54ec21f31..fd0a4f4e9 100644 --- a/.dotnet/examples/Assistants/Example02_FunctionCallingAsync.cs +++ b/.dotnet/examples/Assistants/Example02_FunctionCallingAsync.cs @@ -151,7 +151,7 @@ string GetCurrentWeather(string location, string unit = "celsius") if (run.Status == RunStatus.Completed) { AsyncCollectionResult messages - = client.GetMessagesAsync(run.ThreadId, new MessageCollectionOptions() { Order = MessageCollectionOrder.Ascending }); + = client.GetMessagesAsync(run.ThreadId, new OpenAIPageOptions() { Order = OpenAIPageOrder.Ascending }); await foreach (ThreadMessage message in messages) { diff --git a/.dotnet/examples/Assistants/Example04_AllTheTools.cs b/.dotnet/examples/Assistants/Example04_AllTheTools.cs index af3ca34bd..e40a8d40d 100644 --- a/.dotnet/examples/Assistants/Example04_AllTheTools.cs +++ b/.dotnet/examples/Assistants/Example04_AllTheTools.cs @@ -136,7 +136,7 @@ static string GetNameOfFamilyMember(string relation) if (run.Status == RunStatus.Completed) { CollectionResult messages - = client.GetMessages(run.ThreadId, new MessageCollectionOptions() { Order = MessageCollectionOrder.Ascending }); + = client.GetMessages(run.ThreadId, new OpenAIPageOptions() { Order = OpenAIPageOrder.Ascending }); foreach (ThreadMessage message in messages) { Console.WriteLine($"[{message.Role.ToString().ToUpper()}]: "); @@ -171,9 +171,9 @@ CollectionResult messages CollectionResult runSteps = client.GetRunSteps( run.ThreadId, run.Id, - new RunStepCollectionOptions() + new OpenAIPageOptions() { - Order = RunStepCollectionOrder.Ascending + Order = OpenAIPageOrder.Ascending }); foreach (RunStep step in runSteps) { diff --git a/.dotnet/src/Custom/Assistants/AssistantClient.cs b/.dotnet/src/Custom/Assistants/AssistantClient.cs index 408bcb7e0..a4216f2de 100644 --- a/.dotnet/src/Custom/Assistants/AssistantClient.cs +++ b/.dotnet/src/Custom/Assistants/AssistantClient.cs @@ -1,3 +1,4 @@ +using OpenAI.Internal; using System; using System.ClientModel; using System.ClientModel.Primitives; @@ -22,8 +23,8 @@ namespace OpenAI.Assistants; [CodeGenSuppress("ModifyAssistant", typeof(string), typeof(AssistantModificationOptions))] [CodeGenSuppress("DeleteAssistantAsync", typeof(string))] [CodeGenSuppress("DeleteAssistant", typeof(string))] -[CodeGenSuppress("ListAssistantsAsync", typeof(int?), typeof(AssistantCollectionOrder?), typeof(string), typeof(string), typeof(CancellationToken))] -[CodeGenSuppress("ListAssistants", typeof(int?), typeof(AssistantCollectionOrder?), typeof(string), typeof(string), typeof(CancellationToken))] +[CodeGenSuppress("ListAssistantsAsync", typeof(int?), typeof(OpenAIPageOrder?), typeof(string), typeof(string), typeof(CancellationToken))] +[CodeGenSuppress("ListAssistants", typeof(int?), typeof(OpenAIPageOrder?), typeof(string), typeof(string), typeof(CancellationToken))] public partial class AssistantClient { private readonly InternalAssistantMessageClient _messageSubClient; @@ -124,7 +125,7 @@ public virtual ClientResult CreateAssistant(string model, AssistantCr /// A token that can be used to cancel this method call. /// A collection of . public virtual AsyncCollectionResult GetAssistantsAsync( - AssistantCollectionOptions options = default, + OpenAIPageOptions options = default, CancellationToken cancellationToken = default) { AsyncCollectionResult result = GetAssistantsAsync(options?.PageSizeLimit, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, cancellationToken.ToRequestOptions()); @@ -167,7 +168,7 @@ public virtual AsyncCollectionResult GetAssistantsAsync( /// A token that can be used to cancel this method call. /// A collection of . public virtual CollectionResult GetAssistants( - AssistantCollectionOptions options = default, + OpenAIPageOptions options = default, CancellationToken cancellationToken = default) { CollectionResult result = GetAssistants(options?.PageSizeLimit, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, cancellationToken.ToRequestOptions()); @@ -474,7 +475,7 @@ public virtual ClientResult CreateMessage( /// A collection of . public virtual AsyncCollectionResult GetMessagesAsync( string threadId, - MessageCollectionOptions options = default, + OpenAIPageOptions options = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); @@ -521,7 +522,7 @@ public virtual AsyncCollectionResult GetMessagesAsync( /// A collection of . public virtual CollectionResult GetMessages( string threadId, - MessageCollectionOptions options = default, + OpenAIPageOptions options = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); @@ -857,7 +858,7 @@ public virtual CollectionResult CreateThreadAndRunStreaming( /// A collection of . public virtual AsyncCollectionResult GetRunsAsync( string threadId, - RunCollectionOptions options = default, + OpenAIPageOptions options = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); @@ -904,7 +905,7 @@ public virtual AsyncCollectionResult GetRunsAsync( /// A collection of . public virtual CollectionResult GetRuns( string threadId, - RunCollectionOptions options = default, + OpenAIPageOptions options = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); @@ -1117,7 +1118,7 @@ public virtual ClientResult CancelRun(string threadId, string runId, public virtual AsyncCollectionResult GetRunStepsAsync( string threadId, string runId, - RunStepCollectionOptions options = default, + OpenAIPageOptions options = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); @@ -1138,7 +1139,7 @@ public virtual AsyncCollectionResult GetRunStepsAsync( public virtual CollectionResult GetRunSteps( string threadId, string runId, - RunStepCollectionOptions options = default, + OpenAIPageOptions options = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); diff --git a/.dotnet/src/Custom/Assistants/AssistantCollectionOptions.cs b/.dotnet/src/Custom/Assistants/AssistantCollectionOptions.cs deleted file mode 100644 index 8d219d5e8..000000000 --- a/.dotnet/src/Custom/Assistants/AssistantCollectionOptions.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace OpenAI.Assistants; - -/// The options to configure how objects are retrieved and paginated. -[Experimental("OPENAI001")] -public class AssistantCollectionOptions -{ - /// Initializes a new instance of . - public AssistantCollectionOptions() { } - - /// - /// A limit on the number of objects to be returned per page. - /// - public int? PageSizeLimit { get; set; } - - /// - /// The order in which to retrieve objects when sorted by their - /// timestamp. - /// - public AssistantCollectionOrder? Order { get; set; } - - /// - /// The used to retrieve the page of objects that come - /// after this one. - /// - public string AfterId { get; set; } - - /// - /// The used to retrieve the page of objects that come - /// before this one. - /// - public string BeforeId { get; set; } -} diff --git a/.dotnet/src/Custom/Assistants/AssistantCollectionOrder.cs b/.dotnet/src/Custom/Assistants/AssistantCollectionOrder.cs deleted file mode 100644 index 275d5d98d..000000000 --- a/.dotnet/src/Custom/Assistants/AssistantCollectionOrder.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace OpenAI.Assistants; - -// CUSTOM: Renamed. -[Experimental("OPENAI001")] -[CodeGenModel("ListAssistantsRequestOrder")] -public readonly partial struct AssistantCollectionOrder -{ - // CUSTOM: Renamed. - [CodeGenMember("Asc")] - public static AssistantCollectionOrder Ascending { get; } = new AssistantCollectionOrder(AscValue); - - // CUSTOM: Renamed. - [CodeGenMember("Desc")] - public static AssistantCollectionOrder Descending { get; } = new AssistantCollectionOrder(DescValue); -} diff --git a/.dotnet/src/Custom/Assistants/Internal/GeneratorStubs.Internal.cs b/.dotnet/src/Custom/Assistants/Internal/GeneratorStubs.Internal.cs index 0fc14de68..a3ab92b68 100644 --- a/.dotnet/src/Custom/Assistants/Internal/GeneratorStubs.Internal.cs +++ b/.dotnet/src/Custom/Assistants/Internal/GeneratorStubs.Internal.cs @@ -381,4 +381,7 @@ internal partial class InternalRunStepDetailsToolCallsFileSearchRankingOptionsOb internal readonly partial struct InternalRunStepDetailsToolCallsFileSearchRankingOptionsObjectRanker { } [CodeGenModel("IncludedRunStepProperty")] -internal readonly partial struct InternalIncludedRunStepProperty { } \ No newline at end of file +internal readonly partial struct InternalIncludedRunStepProperty { } + +[CodeGenModel("CreateThreadAndRunRequestAccept")] +internal readonly partial struct InternalCreateThreadAndRunRequestAccept { } diff --git a/.dotnet/src/Custom/Assistants/Internal/InternalAssistantMessageClient.cs b/.dotnet/src/Custom/Assistants/Internal/InternalAssistantMessageClient.cs index 111dcf265..c3806f68a 100644 --- a/.dotnet/src/Custom/Assistants/Internal/InternalAssistantMessageClient.cs +++ b/.dotnet/src/Custom/Assistants/Internal/InternalAssistantMessageClient.cs @@ -1,3 +1,4 @@ +using OpenAI.Internal; using System; using System.ClientModel; using System.ClientModel.Primitives; @@ -9,8 +10,8 @@ namespace OpenAI.Assistants; [CodeGenSuppress("InternalAssistantMessageClient", typeof(ClientPipeline), typeof(ApiKeyCredential), typeof(Uri))] [CodeGenSuppress("CreateMessageAsync", typeof(string), typeof(MessageCreationOptions), typeof(CancellationToken))] [CodeGenSuppress("CreateMessage", typeof(string), typeof(MessageCreationOptions), typeof(CancellationToken))] -[CodeGenSuppress("ListMessagesAsync", typeof(string), typeof(int?), typeof(MessageCollectionOrder?), typeof(string), typeof(string), typeof(CancellationToken))] -[CodeGenSuppress("ListMessages", typeof(string), typeof(int?), typeof(MessageCollectionOrder?), typeof(string), typeof(string), typeof(CancellationToken))] +[CodeGenSuppress("ListMessagesAsync", typeof(string), typeof(int?), typeof(OpenAIPageOrder?), typeof(string), typeof(string), typeof(CancellationToken))] +[CodeGenSuppress("ListMessages", typeof(string), typeof(int?), typeof(OpenAIPageOrder?), typeof(string), typeof(string), typeof(CancellationToken))] [CodeGenSuppress("GetMessageAsync", typeof(string), typeof(string), typeof(CancellationToken))] [CodeGenSuppress("GetMessage", typeof(string), typeof(string), typeof(CancellationToken))] [CodeGenSuppress("ModifyMessageAsync", typeof(string), typeof(string), typeof(MessageModificationOptions), typeof(CancellationToken))] diff --git a/.dotnet/src/Custom/Assistants/Internal/InternalAssistantRunClient.Protocol.cs b/.dotnet/src/Custom/Assistants/Internal/InternalAssistantRunClient.Protocol.cs index 86e942ae1..f03af414f 100644 --- a/.dotnet/src/Custom/Assistants/Internal/InternalAssistantRunClient.Protocol.cs +++ b/.dotnet/src/Custom/Assistants/Internal/InternalAssistantRunClient.Protocol.cs @@ -6,8 +6,12 @@ namespace OpenAI.Assistants; -[CodeGenSuppress("CreateRunAsync", typeof(string), typeof(BinaryContent), typeof(IEnumerable), typeof(RequestOptions))] -[CodeGenSuppress("CreateRun", typeof(string), typeof(BinaryContent), typeof(IEnumerable), typeof(RequestOptions))] +[CodeGenSuppress("CreateRunAsync", typeof(string), typeof(BinaryContent), typeof(string), typeof(IEnumerable), typeof(RequestOptions))] +[CodeGenSuppress("CreateRun", typeof(string), typeof(BinaryContent), typeof(string), typeof(IEnumerable), typeof(RequestOptions))] +[CodeGenSuppress("CreateThreadAndRunAsync", typeof(BinaryContent), typeof(string), typeof(RequestOptions))] +[CodeGenSuppress("CreateThreadAndRun", typeof(BinaryContent), typeof(string), typeof(RequestOptions))] +[CodeGenSuppress("SubmitToolOutputsToRunAsync", typeof(string), typeof(string), typeof(BinaryContent), typeof(string), typeof(RequestOptions))] +[CodeGenSuppress("SubmitToolOutputsToRun", typeof(string), typeof(string), typeof(BinaryContent), typeof(string), typeof(RequestOptions))] [CodeGenSuppress("ListRunStepsAsync", typeof(string), typeof(string), typeof(IEnumerable), typeof(int?), typeof(string), typeof(string), typeof(string), typeof(RequestOptions))] [CodeGenSuppress("ListRunSteps", typeof(string), typeof(string), typeof(IEnumerable), typeof(int?), typeof(string), typeof(string), typeof(string), typeof(RequestOptions))] [CodeGenSuppress("GetRunStepAsync", typeof(string), typeof(string), typeof(string), typeof(IEnumerable), typeof(RequestOptions))] @@ -29,7 +33,10 @@ public virtual async Task CreateThreadAndRunAsync(BinaryContent co PipelineMessage message = null; try { - message = CreateCreateThreadAndRunRequest(content, options); + string acceptHeaderValue = options?.BufferResponse == false + ? InternalCreateThreadAndRunRequestAccept.TextEventStream.ToString() + : InternalCreateThreadAndRunRequestAccept.ApplicationJson.ToString(); + message = CreateCreateThreadAndRunRequest(content, acceptHeaderValue, options); return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } finally @@ -56,7 +63,11 @@ public virtual ClientResult CreateThreadAndRun(BinaryContent content, RequestOpt PipelineMessage message = null; try { - message = CreateCreateThreadAndRunRequest(content, options); + string acceptHeaderValue = options?.BufferResponse == false + ? InternalCreateThreadAndRunRequestAccept.TextEventStream.ToString() + : InternalCreateThreadAndRunRequestAccept.ApplicationJson.ToString(); + + message = CreateCreateThreadAndRunRequest(content, acceptHeaderValue, options); return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } finally @@ -86,10 +97,14 @@ public virtual async Task CreateRunAsync(string threadId, BinaryCo PipelineMessage message = null; try { + string acceptHeaderValue = options?.BufferResponse == false + ? InternalCreateThreadAndRunRequestAccept.TextEventStream.ToString() + : InternalCreateThreadAndRunRequestAccept.ApplicationJson.ToString(); + // Always request the included properties. IEnumerable includedRunStepProperties = [InternalIncludedRunStepProperty.FileSearchResultContent]; - message = CreateCreateRunRequest(threadId, content, includedRunStepProperties, options); + message = CreateCreateRunRequest(threadId, content, acceptHeaderValue, includedRunStepProperties, options); return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } finally @@ -119,10 +134,14 @@ public virtual ClientResult CreateRun(string threadId, BinaryContent content, Re PipelineMessage message = null; try { + string acceptHeaderValue = options?.BufferResponse == false + ? InternalCreateThreadAndRunRequestAccept.TextEventStream.ToString() + : InternalCreateThreadAndRunRequestAccept.ApplicationJson.ToString(); + // Always request the included properties. IEnumerable includedRunStepProperties = [InternalIncludedRunStepProperty.FileSearchResultContent]; - message = CreateCreateRunRequest(threadId, content, includedRunStepProperties, options); + message = CreateCreateRunRequest(threadId, content, acceptHeaderValue, includedRunStepProperties, options); return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } finally @@ -274,7 +293,11 @@ public virtual async Task SubmitToolOutputsToRunAsync(string threa PipelineMessage message = null; try { - message = CreateSubmitToolOutputsToRunRequest(threadId, runId, content, options); + string acceptHeaderValue = options?.BufferResponse == false + ? InternalCreateThreadAndRunRequestAccept.TextEventStream.ToString() + : InternalCreateThreadAndRunRequestAccept.ApplicationJson.ToString(); + + message = CreateSubmitToolOutputsToRunRequest(threadId, runId, content, acceptHeaderValue, options); return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } finally @@ -308,7 +331,11 @@ public virtual ClientResult SubmitToolOutputsToRun(string threadId, string runId PipelineMessage message = null; try { - message = CreateSubmitToolOutputsToRunRequest(threadId, runId, content, options); + string acceptHeaderValue = options?.BufferResponse == false + ? InternalCreateThreadAndRunRequestAccept.TextEventStream.ToString() + : InternalCreateThreadAndRunRequestAccept.ApplicationJson.ToString(); + + message = CreateSubmitToolOutputsToRunRequest(threadId, runId, content, acceptHeaderValue, options); return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } finally diff --git a/.dotnet/src/Custom/Assistants/Internal/InternalAssistantRunClient.cs b/.dotnet/src/Custom/Assistants/Internal/InternalAssistantRunClient.cs index 21813f852..d364d6742 100644 --- a/.dotnet/src/Custom/Assistants/Internal/InternalAssistantRunClient.cs +++ b/.dotnet/src/Custom/Assistants/Internal/InternalAssistantRunClient.cs @@ -8,22 +8,22 @@ namespace OpenAI.Assistants; [CodeGenClient("Runs")] [CodeGenSuppress("InternalAssistantRunClient", typeof(ClientPipeline), typeof(ApiKeyCredential), typeof(Uri))] -[CodeGenSuppress("CreateThreadAndRunAsync", typeof(InternalCreateThreadAndRunRequest), typeof(CancellationToken))] -[CodeGenSuppress("CreateThreadAndRun", typeof(InternalCreateThreadAndRunRequest), typeof(CancellationToken))] -[CodeGenSuppress("CreateRunAsync", typeof(string), typeof(RunCreationOptions), typeof(IEnumerable), typeof(CancellationToken))] -[CodeGenSuppress("CreateRun", typeof(string), typeof(RunCreationOptions), typeof(IEnumerable), typeof(CancellationToken))] -[CodeGenSuppress("ListRunsAsync", typeof(string), typeof(int?), typeof(RunCollectionOrder?), typeof(string), typeof(string), typeof(CancellationToken))] -[CodeGenSuppress("ListRuns", typeof(string), typeof(int?), typeof(RunCollectionOrder?), typeof(string), typeof(string), typeof(CancellationToken))] +[CodeGenSuppress("CreateThreadAndRunAsync", typeof(InternalCreateThreadAndRunRequest), typeof(InternalCreateThreadAndRunRequestAccept), typeof(CancellationToken))] +[CodeGenSuppress("CreateThreadAndRun", typeof(InternalCreateThreadAndRunRequest), typeof(InternalCreateThreadAndRunRequestAccept), typeof(CancellationToken))] +[CodeGenSuppress("CreateRunAsync", typeof(string), typeof(RunCreationOptions), typeof(InternalCreateThreadAndRunRequestAccept), typeof(IEnumerable), typeof(CancellationToken))] +[CodeGenSuppress("CreateRun", typeof(string), typeof(RunCreationOptions), typeof(InternalCreateThreadAndRunRequestAccept), typeof(IEnumerable), typeof(CancellationToken))] +[CodeGenSuppress("ListRunsAsync", typeof(string), typeof(int?), typeof(OpenAIPageOrder?), typeof(string), typeof(string), typeof(CancellationToken))] +[CodeGenSuppress("ListRuns", typeof(string), typeof(int?), typeof(OpenAIPageOrder?), typeof(string), typeof(string), typeof(CancellationToken))] [CodeGenSuppress("GetRunAsync", typeof(string), typeof(string), typeof(CancellationToken))] [CodeGenSuppress("GetRun", typeof(string), typeof(string), typeof(CancellationToken))] [CodeGenSuppress("ModifyRunAsync", typeof(string), typeof(string), typeof(RunModificationOptions), typeof(CancellationToken))] [CodeGenSuppress("ModifyRun", typeof(string), typeof(string), typeof(RunModificationOptions), typeof(CancellationToken))] [CodeGenSuppress("CancelRunAsync", typeof(string), typeof(string), typeof(CancellationToken))] [CodeGenSuppress("CancelRun", typeof(string), typeof(string), typeof(CancellationToken))] -[CodeGenSuppress("SubmitToolOutputsToRunAsync", typeof(string), typeof(string), typeof(InternalSubmitToolOutputsRunRequest), typeof(CancellationToken))] -[CodeGenSuppress("SubmitToolOutputsToRun", typeof(string), typeof(string), typeof(InternalSubmitToolOutputsRunRequest), typeof(CancellationToken))] -[CodeGenSuppress("ListRunStepsAsync", typeof(string), typeof(string), typeof(int?), typeof(RunStepCollectionOrder?), typeof(string), typeof(string), typeof(IEnumerable), typeof(CancellationToken))] -[CodeGenSuppress("ListRunSteps", typeof(string), typeof(string), typeof(int?), typeof(RunStepCollectionOrder?), typeof(string), typeof(string), typeof(IEnumerable), typeof(CancellationToken))] +[CodeGenSuppress("SubmitToolOutputsToRunAsync", typeof(string), typeof(string), typeof(InternalSubmitToolOutputsRunRequest), typeof(InternalCreateThreadAndRunRequestAccept), typeof(CancellationToken))] +[CodeGenSuppress("SubmitToolOutputsToRun", typeof(string), typeof(string), typeof(InternalSubmitToolOutputsRunRequest), typeof(InternalCreateThreadAndRunRequestAccept), typeof(CancellationToken))] +[CodeGenSuppress("ListRunStepsAsync", typeof(string), typeof(string), typeof(int?), typeof(OpenAIPageOrder?), typeof(string), typeof(string), typeof(IEnumerable), typeof(CancellationToken))] +[CodeGenSuppress("ListRunSteps", typeof(string), typeof(string), typeof(int?), typeof(OpenAIPageOrder?), typeof(string), typeof(string), typeof(IEnumerable), typeof(CancellationToken))] [CodeGenSuppress("GetRunStepAsync", typeof(string), typeof(string), typeof(string), typeof(IEnumerable), typeof(CancellationToken))] [CodeGenSuppress("GetRunStep", typeof(string), typeof(string), typeof(string), typeof(IEnumerable), typeof(CancellationToken))] internal partial class InternalAssistantRunClient diff --git a/.dotnet/src/Custom/Assistants/MessageCollectionOptions.cs b/.dotnet/src/Custom/Assistants/MessageCollectionOptions.cs deleted file mode 100644 index 3e542b736..000000000 --- a/.dotnet/src/Custom/Assistants/MessageCollectionOptions.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace OpenAI.Assistants; - -/// The options to configure how objects are retrieved and paginated. -[Experimental("OPENAI001")] -public class MessageCollectionOptions -{ - /// Initializes a new instance of . - public MessageCollectionOptions() { } - - /// - /// A limit on the number of objects to be returned per page. - /// - public int? PageSizeLimit { get; set; } - - /// - /// The order in which to retrieve objects when sorted by their - /// timestamp. - /// - public MessageCollectionOrder? Order { get; set; } - - /// - /// The used to retrieve the page of objects that come - /// after this one. - /// - public string AfterId { get; set; } - - /// - /// The used to retrieve the page of objects that come - /// before this one. - /// - public string BeforeId { get; set; } -} \ No newline at end of file diff --git a/.dotnet/src/Custom/Assistants/MessageCollectionOrder.cs b/.dotnet/src/Custom/Assistants/MessageCollectionOrder.cs deleted file mode 100644 index 47d03e935..000000000 --- a/.dotnet/src/Custom/Assistants/MessageCollectionOrder.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace OpenAI.Assistants; - -// CUSTOM: Renamed. -[Experimental("OPENAI001")] -[CodeGenModel("ListMessagesRequestOrder")] -public readonly partial struct MessageCollectionOrder -{ - // CUSTOM: Renamed. - [CodeGenMember("Asc")] - public static MessageCollectionOrder Ascending { get; } = new MessageCollectionOrder(AscValue); - - // CUSTOM: Renamed. - [CodeGenMember("Desc")] - public static MessageCollectionOrder Descending { get; } = new MessageCollectionOrder(DescValue); -} diff --git a/.dotnet/src/Custom/Assistants/RunCollectionOptions.cs b/.dotnet/src/Custom/Assistants/RunCollectionOptions.cs deleted file mode 100644 index 078a3070a..000000000 --- a/.dotnet/src/Custom/Assistants/RunCollectionOptions.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace OpenAI.Assistants; - -/// The options to configure how objects are retrieved and paginated. -[Experimental("OPENAI001")] -public class RunCollectionOptions -{ - /// Initializes a new instance of . - public RunCollectionOptions() { } - - /// - /// A limit on the number of objects to be returned per page. - /// - public int? PageSizeLimit { get; set; } - - /// - /// The order in which to retrieve objects when sorted by their - /// timestamp. - /// - public RunCollectionOrder? Order { get; set; } - - /// - /// The used to retrieve the page of objects that come - /// after this one. - /// - public string AfterId { get; set; } - - /// - /// The used to retrieve the page of objects that come - /// before this one. - /// - public string BeforeId { get; set; } -} diff --git a/.dotnet/src/Custom/Assistants/RunCollectionOrder.cs b/.dotnet/src/Custom/Assistants/RunCollectionOrder.cs deleted file mode 100644 index 0b2f91749..000000000 --- a/.dotnet/src/Custom/Assistants/RunCollectionOrder.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace OpenAI.Assistants; - -// CUSTOM: Renamed. -[Experimental("OPENAI001")] -[CodeGenModel("ListRunsRequestOrder")] -public readonly partial struct RunCollectionOrder -{ - // CUSTOM: Renamed. - [CodeGenMember("Asc")] - public static RunCollectionOrder Ascending { get; } = new RunCollectionOrder(AscValue); - - // CUSTOM: Renamed. - [CodeGenMember("Desc")] - public static RunCollectionOrder Descending { get; } = new RunCollectionOrder(DescValue); -} diff --git a/.dotnet/src/Custom/Assistants/RunStepCollectionOptions.cs b/.dotnet/src/Custom/Assistants/RunStepCollectionOptions.cs deleted file mode 100644 index 95d58793c..000000000 --- a/.dotnet/src/Custom/Assistants/RunStepCollectionOptions.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace OpenAI.Assistants; - -/// The options to configure how objects are retrieved and paginated. -[Experimental("OPENAI001")] -public class RunStepCollectionOptions -{ - /// Initializes a new instance of . - public RunStepCollectionOptions() { } - - /// - /// A limit on the number of objects to be returned per page. - /// - public int? PageSizeLimit { get; set; } - - /// - /// The order in which to retrieve objects when sorted by their - /// timestamp. - /// - public RunStepCollectionOrder? Order { get; set; } - - /// - /// The used to retrieve the page of objects that come - /// after this one. - /// - public string AfterId { get; set; } - - /// - /// The used to retrieve the page of objects that come - /// before this one. - /// - public string BeforeId { get; set; } -} diff --git a/.dotnet/src/Custom/Assistants/RunStepCollectionOrder.cs b/.dotnet/src/Custom/Assistants/RunStepCollectionOrder.cs deleted file mode 100644 index 5cc86bd75..000000000 --- a/.dotnet/src/Custom/Assistants/RunStepCollectionOrder.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace OpenAI.Assistants; - -// CUSTOM: Renamed. -[Experimental("OPENAI001")] -[CodeGenModel("ListRunStepsRequestOrder")] -public readonly partial struct RunStepCollectionOrder -{ - // CUSTOM: Renamed. - [CodeGenMember("Asc")] - public static RunStepCollectionOrder Ascending { get; } = new RunStepCollectionOrder(AscValue); - - // CUSTOM: Renamed. - [CodeGenMember("Desc")] - public static RunStepCollectionOrder Descending { get; } = new RunStepCollectionOrder(DescValue); -} diff --git a/.dotnet/src/Custom/Batch/BatchClient.cs b/.dotnet/src/Custom/Batch/BatchClient.cs index c6f6fd867..06cf053a3 100644 --- a/.dotnet/src/Custom/Batch/BatchClient.cs +++ b/.dotnet/src/Custom/Batch/BatchClient.cs @@ -81,6 +81,6 @@ protected internal BatchClient(ClientPipeline pipeline, OpenAIClientOptions opti internal virtual CreateBatchOperation CreateCreateBatchOperation(string batchId, string status, PipelineResponse response) { - return new CreateBatchOperation(Pipeline, _endpoint, batchId, status, response); + return new CreateBatchOperation(this, _endpoint, batchId, status, response); } } diff --git a/.dotnet/src/Custom/Batch/CreateBatchOperation.Protocol.cs b/.dotnet/src/Custom/Batch/CreateBatchOperation.Protocol.cs index 2a096567c..7c9b4041c 100644 --- a/.dotnet/src/Custom/Batch/CreateBatchOperation.Protocol.cs +++ b/.dotnet/src/Custom/Batch/CreateBatchOperation.Protocol.cs @@ -17,20 +17,19 @@ namespace OpenAI.Batch; [Experimental("OPENAI001")] public class CreateBatchOperation : OperationResult { - private readonly ClientPipeline _pipeline; + private readonly BatchClient _parentClient; private readonly Uri _endpoint; - private readonly string _batchId; internal CreateBatchOperation( - ClientPipeline pipeline, + BatchClient parentClient, Uri endpoint, string batchId, string status, PipelineResponse response) - : base(response) + : base(response) { - _pipeline = pipeline; + _parentClient = parentClient; _endpoint = endpoint; _batchId = batchId; @@ -160,8 +159,8 @@ private static bool GetHasCompleted(string? status) /// The response returned from the service. public virtual async Task GetBatchAsync(RequestOptions? options) { - using PipelineMessage message = CreateRetrieveBatchRequest(_batchId, options); - return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = _parentClient.CreateRetrieveBatchRequest(_batchId, options); + return ClientResult.FromResponse(await _parentClient.Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// @@ -172,8 +171,8 @@ public virtual async Task GetBatchAsync(RequestOptions? options) /// The response returned from the service. public virtual ClientResult GetBatch(RequestOptions? options) { - using PipelineMessage message = CreateRetrieveBatchRequest(_batchId, options); - return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); + using PipelineMessage message = _parentClient.CreateRetrieveBatchRequest(_batchId, options); + return ClientResult.FromResponse(_parentClient.Pipeline.ProcessMessage(message, options)); } /// @@ -184,8 +183,8 @@ public virtual ClientResult GetBatch(RequestOptions? options) /// The response returned from the service. public virtual async Task CancelAsync(RequestOptions? options) { - using PipelineMessage message = CreateCancelBatchRequest(_batchId, options); - return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = _parentClient.CreateCancelBatchRequest(_batchId, options); + return ClientResult.FromResponse(await _parentClient.Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// @@ -196,43 +195,7 @@ public virtual async Task CancelAsync(RequestOptions? options) /// The response returned from the service. public virtual ClientResult Cancel(RequestOptions? options) { - using PipelineMessage message = CreateCancelBatchRequest(_batchId, options); - return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); - } - - internal virtual PipelineMessage CreateRetrieveBatchRequest(string batchId, RequestOptions? options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/batches/", false); - uri.AppendPath(batchId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + using PipelineMessage message = _parentClient.CreateCancelBatchRequest(_batchId, options); + return ClientResult.FromResponse(_parentClient.Pipeline.ProcessMessage(message, options)); } - - internal virtual PipelineMessage CreateCancelBatchRequest(string batchId, RequestOptions? options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/batches/", false); - uri.AppendPath(batchId, true); - uri.AppendPath("/cancel", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } - - private static PipelineMessageClassifier? _pipelineMessageClassifier200; - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); } \ No newline at end of file diff --git a/.dotnet/src/Custom/Common/OpenAIPageOptions.cs b/.dotnet/src/Custom/Common/OpenAIPageOptions.cs new file mode 100644 index 000000000..2ab7f9d32 --- /dev/null +++ b/.dotnet/src/Custom/Common/OpenAIPageOptions.cs @@ -0,0 +1,35 @@ +using System.Diagnostics.CodeAnalysis; + +namespace OpenAI; + +/// The options to configure how paginated objects are retrieved and processed. +[Experimental("OPENAI001")] +[CodeGenModel("CommonPageQueryParameters")] +public class OpenAIPageOptions +{ + /// Initializes a new instance of . + public OpenAIPageOptions() { } + + /// + /// A limit on the number of objects to be returned per page. + /// + public int? PageSizeLimit { get; set; } + + /// + /// The order in which to retrieve objects when sorted by their + /// created timestamps. + /// + public OpenAIPageOrder? Order { get; set; } + + /// + /// The object ID used to retrieve the page of objects that come + /// after this one. + /// + public string AfterId { get; set; } + + /// + /// The object ID used to retrieve the page of objects that come + /// before this one. + /// + public string BeforeId { get; set; } +} \ No newline at end of file diff --git a/.dotnet/src/Custom/Common/OpenAIPageOrder.cs b/.dotnet/src/Custom/Common/OpenAIPageOrder.cs new file mode 100644 index 000000000..132e9054a --- /dev/null +++ b/.dotnet/src/Custom/Common/OpenAIPageOrder.cs @@ -0,0 +1,15 @@ +using System; +using System.Diagnostics.CodeAnalysis; + +namespace OpenAI; + +[CodeGenModel("PageOrder")] +[Experimental("OPENAI001")] +public readonly partial struct OpenAIPageOrder +{ + [CodeGenMember("Desc")] + public static OpenAIPageOrder Descending { get; } = new(DescValue); + + [CodeGenMember("Asc")] + public static OpenAIPageOrder Ascending { get; } = new(AscValue); +} \ No newline at end of file diff --git a/.dotnet/src/Custom/OpenAIClient.cs b/.dotnet/src/Custom/OpenAIClient.cs index b3a54e950..82ceabb5a 100644 --- a/.dotnet/src/Custom/OpenAIClient.cs +++ b/.dotnet/src/Custom/OpenAIClient.cs @@ -65,11 +65,9 @@ namespace OpenAI; public partial class OpenAIClient { private const string OpenAIV1Endpoint = "https://api.openai.com/v1"; - private const string OpenAIBetaHeaderValue = "assistants=v2"; private static class KnownHeaderNames { - public const string OpenAIBeta = "OpenAI-Beta"; public const string OpenAIOrganization = "OpenAI-Organization"; public const string OpenAIProject = "OpenAI-Project"; public const string UserAgent = "User-Agent"; @@ -261,7 +259,6 @@ internal static ClientPipeline CreatePipeline(ApiKeyCredential credential, OpenA return ClientPipeline.Create( options, perCallPolicies: [ - CreateAddBetaFeatureHeaderPolicy(), CreateAddCustomHeadersPolicy(options), ], perTryPolicies: [ @@ -276,17 +273,6 @@ internal static Uri GetEndpoint(OpenAIClientOptions options = null) return options?.Endpoint ?? new(OpenAIV1Endpoint); } - private static PipelinePolicy CreateAddBetaFeatureHeaderPolicy() - { - return new GenericActionPipelinePolicy((message) => - { - if (message?.Request?.Headers?.TryGetValue(KnownHeaderNames.OpenAIBeta, out string _) == false) - { - message.Request.Headers.Set(KnownHeaderNames.OpenAIBeta, OpenAIBetaHeaderValue); - } - }); - } - private static PipelinePolicy CreateAddCustomHeadersPolicy(OpenAIClientOptions options = null) { TelemetryDetails telemetryDetails = new(typeof(OpenAIClientOptions).Assembly, options?.UserAgentApplicationId); diff --git a/.dotnet/src/Custom/VectorStores/AddFileToVectorStoreOperation.Protocol.cs b/.dotnet/src/Custom/VectorStores/AddFileToVectorStoreOperation.Protocol.cs index 254232f1a..fdc68741c 100644 --- a/.dotnet/src/Custom/VectorStores/AddFileToVectorStoreOperation.Protocol.cs +++ b/.dotnet/src/Custom/VectorStores/AddFileToVectorStoreOperation.Protocol.cs @@ -10,7 +10,7 @@ namespace OpenAI.VectorStores; public partial class AddFileToVectorStoreOperation : OperationResult { - private readonly ClientPipeline _pipeline; + private readonly VectorStoreClient _parentClient; private readonly Uri _endpoint; private readonly string _vectorStoreId; @@ -28,8 +28,8 @@ public partial class AddFileToVectorStoreOperation : OperationResult [EditorBrowsable(EditorBrowsableState.Never)] public virtual async Task GetFileAssociationAsync(RequestOptions? options) { - using PipelineMessage message = CreateGetVectorStoreFileRequest(_vectorStoreId, _fileId, options); - return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = _parentClient.CreateGetVectorStoreFileRequest(_vectorStoreId, _fileId, options); + return ClientResult.FromResponse(await _parentClient.Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// @@ -41,26 +41,8 @@ public virtual async Task GetFileAssociationAsync(RequestOptions? [EditorBrowsable(EditorBrowsableState.Never)] public virtual ClientResult GetFileAssociation(RequestOptions? options) { - using PipelineMessage message = CreateGetVectorStoreFileRequest(_vectorStoreId, _fileId, options); - return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); - } - - internal virtual PipelineMessage CreateGetVectorStoreFileRequest(string vectorStoreId, string fileId, RequestOptions? options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/files/", false); - uri.AppendPath(fileId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + using PipelineMessage message = _parentClient.CreateGetVectorStoreFileRequest(_vectorStoreId, _fileId, options); + return ClientResult.FromResponse(_parentClient.Pipeline.ProcessMessage(message, options)); } private static PipelineMessageClassifier? _pipelineMessageClassifier200; diff --git a/.dotnet/src/Custom/VectorStores/AddFileToVectorStoreOperation.cs b/.dotnet/src/Custom/VectorStores/AddFileToVectorStoreOperation.cs index d160fb301..99b9325c7 100644 --- a/.dotnet/src/Custom/VectorStores/AddFileToVectorStoreOperation.cs +++ b/.dotnet/src/Custom/VectorStores/AddFileToVectorStoreOperation.cs @@ -13,12 +13,12 @@ namespace OpenAI.VectorStores; public partial class AddFileToVectorStoreOperation : OperationResult { internal AddFileToVectorStoreOperation( - ClientPipeline pipeline, + VectorStoreClient parentClient, Uri endpoint, ClientResult result) : base(result.GetRawResponse()) { - _pipeline = pipeline; + _parentClient = parentClient; _endpoint = endpoint; Value = result; diff --git a/.dotnet/src/Custom/VectorStores/CreateBatchFileJobOperation.Protocol.cs b/.dotnet/src/Custom/VectorStores/CreateBatchFileJobOperation.Protocol.cs index 8b649718e..1e0e2598b 100644 --- a/.dotnet/src/Custom/VectorStores/CreateBatchFileJobOperation.Protocol.cs +++ b/.dotnet/src/Custom/VectorStores/CreateBatchFileJobOperation.Protocol.cs @@ -14,7 +14,7 @@ namespace OpenAI.VectorStores; /// public partial class CreateBatchFileJobOperation : OperationResult { - private readonly ClientPipeline _pipeline; + private readonly VectorStoreClient _parentClient; private readonly Uri _endpoint; private readonly string _vectorStoreId; @@ -34,8 +34,8 @@ public partial class CreateBatchFileJobOperation : OperationResult [EditorBrowsable(EditorBrowsableState.Never)] public virtual async Task GetFileBatchAsync(RequestOptions? options) { - using PipelineMessage message = CreateGetVectorStoreFileBatchRequest(_vectorStoreId, _batchId, options); - return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = _parentClient.CreateGetVectorStoreFileBatchRequest(_vectorStoreId, _batchId, options); + return ClientResult.FromResponse(await _parentClient.Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// @@ -47,8 +47,8 @@ public virtual async Task GetFileBatchAsync(RequestOptions? option [EditorBrowsable(EditorBrowsableState.Never)] public virtual ClientResult GetFileBatch(RequestOptions? options) { - using PipelineMessage message = CreateGetVectorStoreFileBatchRequest(_vectorStoreId, _batchId, options); - return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); + using PipelineMessage message = _parentClient.CreateGetVectorStoreFileBatchRequest(_vectorStoreId, _batchId, options); + return ClientResult.FromResponse(_parentClient.Pipeline.ProcessMessage(message, options)); } /// @@ -60,8 +60,8 @@ public virtual ClientResult GetFileBatch(RequestOptions? options) [EditorBrowsable(EditorBrowsableState.Never)] public virtual async Task CancelAsync(RequestOptions? options) { - using PipelineMessage message = CreateCancelVectorStoreFileBatchRequest(_vectorStoreId, _batchId, options); - return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = _parentClient.CreateCancelVectorStoreFileBatchRequest(_vectorStoreId, _batchId, options); + return ClientResult.FromResponse(await _parentClient.Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// @@ -73,45 +73,8 @@ public virtual async Task CancelAsync(RequestOptions? options) [EditorBrowsable(EditorBrowsableState.Never)] public virtual ClientResult Cancel(RequestOptions? options) { - using PipelineMessage message = CreateCancelVectorStoreFileBatchRequest(_vectorStoreId, _batchId, options); - return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); - } - - internal virtual PipelineMessage CreateGetVectorStoreFileBatchRequest(string vectorStoreId, string batchId, RequestOptions? options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/file_batches/", false); - uri.AppendPath(batchId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } - - internal virtual PipelineMessage CreateCancelVectorStoreFileBatchRequest(string vectorStoreId, string batchId, RequestOptions? options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/file_batches/", false); - uri.AppendPath(batchId, true); - uri.AppendPath("/cancel", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + using PipelineMessage message = _parentClient.CreateCancelVectorStoreFileBatchRequest(_vectorStoreId, _batchId, options); + return ClientResult.FromResponse(_parentClient.Pipeline.ProcessMessage(message, options)); } private static PipelineMessageClassifier? _pipelineMessageClassifier200; diff --git a/.dotnet/src/Custom/VectorStores/CreateBatchFileJobOperation.cs b/.dotnet/src/Custom/VectorStores/CreateBatchFileJobOperation.cs index ad5acece8..7b299f28e 100644 --- a/.dotnet/src/Custom/VectorStores/CreateBatchFileJobOperation.cs +++ b/.dotnet/src/Custom/VectorStores/CreateBatchFileJobOperation.cs @@ -16,12 +16,12 @@ namespace OpenAI.VectorStores; public partial class CreateBatchFileJobOperation : OperationResult { internal CreateBatchFileJobOperation( - ClientPipeline pipeline, + VectorStoreClient parentClient, Uri endpoint, ClientResult result) : base(result.GetRawResponse()) { - _pipeline = pipeline; + _parentClient = parentClient; _endpoint = endpoint; Value = result; diff --git a/.dotnet/src/Custom/VectorStores/CreateVectorStoreOperation.Protocol.cs b/.dotnet/src/Custom/VectorStores/CreateVectorStoreOperation.Protocol.cs index 343c37155..1faeada23 100644 --- a/.dotnet/src/Custom/VectorStores/CreateVectorStoreOperation.Protocol.cs +++ b/.dotnet/src/Custom/VectorStores/CreateVectorStoreOperation.Protocol.cs @@ -10,7 +10,7 @@ namespace OpenAI.VectorStores; public partial class CreateVectorStoreOperation : OperationResult { - private readonly ClientPipeline _pipeline; + private readonly VectorStoreClient _parentClient; private readonly Uri _endpoint; private readonly string _vectorStoreId; @@ -27,8 +27,8 @@ public partial class CreateVectorStoreOperation : OperationResult [EditorBrowsable(EditorBrowsableState.Never)] public virtual async Task GetVectorStoreAsync(RequestOptions? options) { - using PipelineMessage message = CreateGetVectorStoreRequest(_vectorStoreId, options); - return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + using PipelineMessage message = _parentClient.CreateGetVectorStoreRequest(_vectorStoreId, options); + return ClientResult.FromResponse(await _parentClient.Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } /// @@ -40,24 +40,8 @@ public virtual async Task GetVectorStoreAsync(RequestOptions? opti [EditorBrowsable(EditorBrowsableState.Never)] public virtual ClientResult GetVectorStore(RequestOptions? options) { - using PipelineMessage message = CreateGetVectorStoreRequest(_vectorStoreId, options); - return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); - } - - internal virtual PipelineMessage CreateGetVectorStoreRequest(string vectorStoreId, RequestOptions? options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; + using PipelineMessage message = _parentClient.CreateGetVectorStoreRequest(_vectorStoreId, options); + return ClientResult.FromResponse(_parentClient.Pipeline.ProcessMessage(message, options)); } private static PipelineMessageClassifier? _pipelineMessageClassifier200; diff --git a/.dotnet/src/Custom/VectorStores/CreateVectorStoreOperation.cs b/.dotnet/src/Custom/VectorStores/CreateVectorStoreOperation.cs index d140e7473..00d71b037 100644 --- a/.dotnet/src/Custom/VectorStores/CreateVectorStoreOperation.cs +++ b/.dotnet/src/Custom/VectorStores/CreateVectorStoreOperation.cs @@ -13,12 +13,12 @@ namespace OpenAI.VectorStores; public partial class CreateVectorStoreOperation : OperationResult { internal CreateVectorStoreOperation( - ClientPipeline pipeline, + VectorStoreClient parentClient, Uri endpoint, ClientResult result) : base(result.GetRawResponse()) { - _pipeline = pipeline; + _parentClient = parentClient; _endpoint = endpoint; Value = result; diff --git a/.dotnet/src/Custom/VectorStores/Internal/GeneratorStubs.cs b/.dotnet/src/Custom/VectorStores/Internal/GeneratorStubs.cs index 1ca77f775..6a5a80807 100644 --- a/.dotnet/src/Custom/VectorStores/Internal/GeneratorStubs.cs +++ b/.dotnet/src/Custom/VectorStores/Internal/GeneratorStubs.cs @@ -61,6 +61,3 @@ internal partial class InternalUnknownChunkingStrategy { } [CodeGenModel("UnknownFileChunkingStrategyResponseParam")] internal partial class InternalUnknownFileChunkingStrategyResponseParamProxy { } - -[CodeGenModel("ListFilesInVectorStoreBatchRequestOrder")] -internal readonly partial struct InternalListFilesInVectorStoreBatchRequestOrder { } \ No newline at end of file diff --git a/.dotnet/src/Custom/VectorStores/Internal/Pagination/AsyncVectorStoreCollectionResult.cs b/.dotnet/src/Custom/VectorStores/Internal/Pagination/AsyncVectorStoreCollectionResult.cs index 9eb429289..90e260d97 100644 --- a/.dotnet/src/Custom/VectorStores/Internal/Pagination/AsyncVectorStoreCollectionResult.cs +++ b/.dotnet/src/Custom/VectorStores/Internal/Pagination/AsyncVectorStoreCollectionResult.cs @@ -83,7 +83,7 @@ public static bool HasNextPage(ClientResult result) internal virtual async Task GetVectorStoresAsync(int? limit, string? order, string? after, string? before, RequestOptions? options) { - using PipelineMessage message = _vectorStoreClient.CreateGetVectorStoresRequest(limit, order, after, before, options); + using PipelineMessage message = _vectorStoreClient.CreateListVectorStoresRequest(limit, order, after, before, options); return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } } diff --git a/.dotnet/src/Custom/VectorStores/Internal/Pagination/AsyncVectorStoreFileBatchCollectionResult.cs b/.dotnet/src/Custom/VectorStores/Internal/Pagination/AsyncVectorStoreFileBatchCollectionResult.cs index 80707e361..5d3af5a96 100644 --- a/.dotnet/src/Custom/VectorStores/Internal/Pagination/AsyncVectorStoreFileBatchCollectionResult.cs +++ b/.dotnet/src/Custom/VectorStores/Internal/Pagination/AsyncVectorStoreFileBatchCollectionResult.cs @@ -95,7 +95,7 @@ internal virtual async Task GetFileAssociationsAsync(string vector Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); - using PipelineMessage message = _vectorStoreClient.CreateGetFilesInVectorStoreBatchesRequest(vectorStoreId, batchId, limit, order, after, before, filter, options); + using PipelineMessage message = _vectorStoreClient.CreateListFilesInVectorStoreBatchRequest(vectorStoreId, batchId, limit, order, after, before, filter, options); return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } } diff --git a/.dotnet/src/Custom/VectorStores/Internal/Pagination/AsyncVectorStoreFileCollectionResult.cs b/.dotnet/src/Custom/VectorStores/Internal/Pagination/AsyncVectorStoreFileCollectionResult.cs index 0fdc218fc..cf35bff0b 100644 --- a/.dotnet/src/Custom/VectorStores/Internal/Pagination/AsyncVectorStoreFileCollectionResult.cs +++ b/.dotnet/src/Custom/VectorStores/Internal/Pagination/AsyncVectorStoreFileCollectionResult.cs @@ -92,7 +92,7 @@ internal virtual async Task GetFileAssociationsAsync(string vector { Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - using PipelineMessage message = _vectorStoreClient.CreateGetVectorStoreFilesRequest(vectorStoreId, limit, order, after, before, filter, options); + using PipelineMessage message = _vectorStoreClient.CreateListVectorStoreFilesRequest(vectorStoreId, limit, order, after, before, filter, options); return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } } diff --git a/.dotnet/src/Custom/VectorStores/Internal/Pagination/VectorStoreCollectionResult.cs b/.dotnet/src/Custom/VectorStores/Internal/Pagination/VectorStoreCollectionResult.cs index f8faf783f..edcefd922 100644 --- a/.dotnet/src/Custom/VectorStores/Internal/Pagination/VectorStoreCollectionResult.cs +++ b/.dotnet/src/Custom/VectorStores/Internal/Pagination/VectorStoreCollectionResult.cs @@ -90,7 +90,7 @@ public static bool HasNextPage(ClientResult result) internal virtual ClientResult GetVectorStores(int? limit, string? order, string? after, string? before, RequestOptions? options) { - using PipelineMessage message = _vectorStoreClient.CreateGetVectorStoresRequest(limit, order, after, before, options); + using PipelineMessage message = _vectorStoreClient.CreateListVectorStoresRequest(limit, order, after, before, options); return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); } } diff --git a/.dotnet/src/Custom/VectorStores/Internal/Pagination/VectorStoreFileBatchCollectionResult.cs b/.dotnet/src/Custom/VectorStores/Internal/Pagination/VectorStoreFileBatchCollectionResult.cs index 7f8345cf6..4f76f6337 100644 --- a/.dotnet/src/Custom/VectorStores/Internal/Pagination/VectorStoreFileBatchCollectionResult.cs +++ b/.dotnet/src/Custom/VectorStores/Internal/Pagination/VectorStoreFileBatchCollectionResult.cs @@ -100,7 +100,7 @@ internal virtual ClientResult GetFileAssociations(string vectorStoreId, string b Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); - using PipelineMessage message = _vectorStoreClient.CreateGetFilesInVectorStoreBatchesRequest(vectorStoreId, batchId, limit, order, after, before, filter, options); + using PipelineMessage message = _vectorStoreClient.CreateListFilesInVectorStoreBatchRequest(vectorStoreId, batchId, limit, order, after, before, filter, options); return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); } } diff --git a/.dotnet/src/Custom/VectorStores/Internal/Pagination/VectorStoreFileCollectionResult.cs b/.dotnet/src/Custom/VectorStores/Internal/Pagination/VectorStoreFileCollectionResult.cs index 4b4a038f5..11536f27c 100644 --- a/.dotnet/src/Custom/VectorStores/Internal/Pagination/VectorStoreFileCollectionResult.cs +++ b/.dotnet/src/Custom/VectorStores/Internal/Pagination/VectorStoreFileCollectionResult.cs @@ -97,7 +97,7 @@ internal virtual ClientResult GetFileAssociations(string vectorStoreId, int? lim { Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - using PipelineMessage message = _vectorStoreClient.CreateGetVectorStoreFilesRequest(vectorStoreId, limit, order, after, before, filter, options); + using PipelineMessage message = _vectorStoreClient.CreateListVectorStoreFilesRequest(vectorStoreId, limit, order, after, before, filter, options); return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); } } diff --git a/.dotnet/src/Custom/VectorStores/VectorStoreClient.Protocol.cs b/.dotnet/src/Custom/VectorStores/VectorStoreClient.Protocol.cs index 810460b8d..f6279e82c 100644 --- a/.dotnet/src/Custom/VectorStores/VectorStoreClient.Protocol.cs +++ b/.dotnet/src/Custom/VectorStores/VectorStoreClient.Protocol.cs @@ -683,289 +683,4 @@ internal virtual ClientResult GetBatchFileJob(string vectorStoreId, string batch using PipelineMessage message = CreateGetVectorStoreFileBatchRequest(vectorStoreId, batchId, options); return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } - - internal virtual PipelineMessage CreateCreateVectorStoreRequest(BinaryContent content, RequestOptions options) - { - var message = Pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } - - internal virtual PipelineMessage CreateGetVectorStoresRequest(int? limit, string order, string after, string before, RequestOptions options) - { - var message = Pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores", false); - if (limit != null) - { - uri.AppendQuery("limit", limit.Value, true); - } - if (order != null) - { - uri.AppendQuery("order", order, true); - } - if (after != null) - { - uri.AppendQuery("after", after, true); - } - if (before != null) - { - uri.AppendQuery("before", before, true); - } - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } - - internal virtual PipelineMessage CreateGetVectorStoreRequest(string vectorStoreId, RequestOptions options) - { - var message = Pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } - - internal virtual PipelineMessage CreateModifyVectorStoreRequest(string vectorStoreId, BinaryContent content, RequestOptions options) - { - var message = Pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } - - internal virtual PipelineMessage CreateDeleteVectorStoreRequest(string vectorStoreId, RequestOptions options) - { - var message = Pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "DELETE"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } - - internal virtual PipelineMessage CreateGetVectorStoreFilesRequest(string vectorStoreId, int? limit, string order, string after, string before, string filter, RequestOptions options) - { - var message = Pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/files", false); - if (limit != null) - { - uri.AppendQuery("limit", limit.Value, true); - } - if (order != null) - { - uri.AppendQuery("order", order, true); - } - if (after != null) - { - uri.AppendQuery("after", after, true); - } - if (before != null) - { - uri.AppendQuery("before", before, true); - } - if (filter != null) - { - uri.AppendQuery("filter", filter, true); - } - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } - - internal virtual PipelineMessage CreateCreateVectorStoreFileRequest(string vectorStoreId, BinaryContent content, RequestOptions options) - { - var message = Pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/files", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } - - internal virtual PipelineMessage CreateDeleteVectorStoreFileRequest(string vectorStoreId, string fileId, RequestOptions options) - { - var message = Pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "DELETE"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/files/", false); - uri.AppendPath(fileId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } - - internal virtual PipelineMessage CreateCancelVectorStoreFileBatchRequest(string vectorStoreId, string batchId, RequestOptions options) - { - var message = Pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/file_batches/", false); - uri.AppendPath(batchId, true); - uri.AppendPath("/cancel", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } - - internal virtual PipelineMessage CreateCreateVectorStoreFileBatchRequest(string vectorStoreId, BinaryContent content, RequestOptions options) - { - var message = Pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "POST"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/file_batches", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } - - internal virtual PipelineMessage CreateGetVectorStoreFileRequest(string vectorStoreId, string fileId, RequestOptions options) - { - var message = Pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/files/", false); - uri.AppendPath(fileId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } - - internal virtual PipelineMessage CreateGetVectorStoreFileBatchRequest(string vectorStoreId, string batchId, RequestOptions options) - { - var message = Pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/file_batches/", false); - uri.AppendPath(batchId, true); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } - - internal virtual PipelineMessage CreateGetFilesInVectorStoreBatchesRequest(string vectorStoreId, string batchId, int? limit, string order, string after, string before, string filter, RequestOptions options) - { - var message = Pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/vector_stores/", false); - uri.AppendPath(vectorStoreId, true); - uri.AppendPath("/file_batches/", false); - uri.AppendPath(batchId, true); - uri.AppendPath("/files", false); - if (limit != null) - { - uri.AppendQuery("limit", limit.Value, true); - } - if (order != null) - { - uri.AppendQuery("order", order, true); - } - if (after != null) - { - uri.AppendQuery("after", after, true); - } - if (before != null) - { - uri.AppendQuery("before", before, true); - } - if (filter != null) - { - uri.AppendQuery("filter", filter, true); - } - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } } diff --git a/.dotnet/src/Custom/VectorStores/VectorStoreClient.cs b/.dotnet/src/Custom/VectorStores/VectorStoreClient.cs index 5f42766e6..fcfdc1f33 100644 --- a/.dotnet/src/Custom/VectorStores/VectorStoreClient.cs +++ b/.dotnet/src/Custom/VectorStores/VectorStoreClient.cs @@ -1,4 +1,5 @@ using OpenAI.Files; +using OpenAI.Internal; using System; using System.ClientModel; using System.ClientModel.Primitives; @@ -17,10 +18,10 @@ namespace OpenAI.VectorStores; [CodeGenSuppress("VectorStoreClient", typeof(ClientPipeline), typeof(ApiKeyCredential), typeof(Uri))] [CodeGenSuppress("CreateVectorStoreAsync", typeof(VectorStoreCreationOptions), typeof(CancellationToken))] [CodeGenSuppress("CreateVectorStore", typeof(VectorStoreCreationOptions), typeof(CancellationToken))] -[CodeGenSuppress("ListVectorStoresAsync", typeof(int?), typeof(VectorStoreCollectionOrder?), typeof(string), typeof(string), typeof(CancellationToken))] -[CodeGenSuppress("ListVectorStores", typeof(int?), typeof(VectorStoreCollectionOrder?), typeof(string), typeof(string), typeof(CancellationToken))] -[CodeGenSuppress("ListVectorStoreFilesAsync", typeof(string), typeof(int?), typeof(VectorStoreFileAssociationCollectionOrder?), typeof(string), typeof(string), typeof(VectorStoreFileStatusFilter?), typeof(CancellationToken))] -[CodeGenSuppress("ListVectorStoreFiles", typeof(string), typeof(int?), typeof(VectorStoreFileAssociationCollectionOrder?), typeof(string), typeof(string), typeof(VectorStoreFileStatusFilter?), typeof(CancellationToken))] +[CodeGenSuppress("ListVectorStoresAsync", typeof(int?), typeof(OpenAIPageOrder?), typeof(string), typeof(string), typeof(CancellationToken))] +[CodeGenSuppress("ListVectorStores", typeof(int?), typeof(OpenAIPageOrder?), typeof(string), typeof(string), typeof(CancellationToken))] +[CodeGenSuppress("ListVectorStoreFilesAsync", typeof(string), typeof(int?), typeof(OpenAIPageOrder?), typeof(string), typeof(string), typeof(VectorStoreFileStatusFilter?), typeof(CancellationToken))] +[CodeGenSuppress("ListVectorStoreFiles", typeof(string), typeof(int?), typeof(OpenAIPageOrder?), typeof(string), typeof(string), typeof(VectorStoreFileStatusFilter?), typeof(CancellationToken))] [CodeGenSuppress("CreateVectorStoreFileAsync", typeof(string), typeof(InternalCreateVectorStoreFileRequest), typeof(CancellationToken))] [CodeGenSuppress("CreateVectorStoreFile", typeof(string), typeof(InternalCreateVectorStoreFileRequest), typeof(CancellationToken))] [CodeGenSuppress("GetVectorStoreFileAsync", typeof(string), typeof(string), typeof(CancellationToken))] @@ -33,8 +34,8 @@ namespace OpenAI.VectorStores; [CodeGenSuppress("GetVectorStoreFileBatch", typeof(string), typeof(string), typeof(CancellationToken))] [CodeGenSuppress("CancelVectorStoreFileBatchAsync", typeof(string), typeof(string), typeof(CancellationToken))] [CodeGenSuppress("CancelVectorStoreFileBatch", typeof(string), typeof(string), typeof(CancellationToken))] -[CodeGenSuppress("ListFilesInVectorStoreBatchAsync", typeof(string), typeof(string), typeof(int?), typeof(InternalListFilesInVectorStoreBatchRequestOrder?), typeof(string), typeof(string), typeof(VectorStoreFileStatusFilter?), typeof(CancellationToken))] -[CodeGenSuppress("ListFilesInVectorStoreBatch", typeof(string), typeof(string), typeof(int?), typeof(InternalListFilesInVectorStoreBatchRequestOrder?), typeof(string), typeof(string), typeof(VectorStoreFileStatusFilter?), typeof(CancellationToken))] +[CodeGenSuppress("ListFilesInVectorStoreBatchAsync", typeof(string), typeof(string), typeof(int?), typeof(OpenAIPageOrder?), typeof(string), typeof(string), typeof(VectorStoreFileStatusFilter?), typeof(CancellationToken))] +[CodeGenSuppress("ListFilesInVectorStoreBatch", typeof(string), typeof(string), typeof(int?), typeof(OpenAIPageOrder?), typeof(string), typeof(string), typeof(VectorStoreFileStatusFilter?), typeof(CancellationToken))] public partial class VectorStoreClient { // CUSTOM: Added as a convenience. @@ -89,17 +90,17 @@ protected internal VectorStoreClient(ClientPipeline pipeline, OpenAIClientOption internal virtual CreateVectorStoreOperation CreateCreateVectorStoreOperation(ClientResult result) { - return new CreateVectorStoreOperation(Pipeline, _endpoint, result); + return new CreateVectorStoreOperation(this, _endpoint, result); } internal virtual AddFileToVectorStoreOperation CreateAddFileToVectorStoreOperation(ClientResult result) { - return new AddFileToVectorStoreOperation(Pipeline, _endpoint, result); + return new AddFileToVectorStoreOperation(this, _endpoint, result); } internal virtual CreateBatchFileJobOperation CreateBatchFileJobOperation(ClientResult result) { - return new CreateBatchFileJobOperation(Pipeline, _endpoint, result); + return new CreateBatchFileJobOperation(this, _endpoint, result); } /// Creates a vector store. @@ -237,7 +238,7 @@ public virtual ClientResult DeleteVectorStore(string /// A token that can be used to cancel this method call. /// A collection of . public virtual AsyncCollectionResult GetVectorStoresAsync( - VectorStoreCollectionOptions options = default, + OpenAIPageOptions options = default, CancellationToken cancellationToken = default) { return GetVectorStoresAsync(options?.PageSizeLimit, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, cancellationToken.ToRequestOptions()) @@ -268,7 +269,7 @@ public virtual AsyncCollectionResult GetVectorStoresAsync( /// A token that can be used to cancel this method call. /// A collection of . public virtual CollectionResult GetVectorStores( - VectorStoreCollectionOptions options = default, + OpenAIPageOptions options = default, CancellationToken cancellationToken = default) { return GetVectorStores(options?.PageSizeLimit, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, cancellationToken.ToRequestOptions()) @@ -344,16 +345,18 @@ public virtual AddFileToVectorStoreOperation AddFileToVectorStore(string vectorS /// The ID of the vector store to enumerate the file associations of. /// /// Options describing the collection to return. + /// A to match retrieved items to. /// A token that can be used to cancel this method call. /// A collection of . public virtual AsyncCollectionResult GetFileAssociationsAsync( string vectorStoreId, - VectorStoreFileAssociationCollectionOptions options = default, + OpenAIPageOptions options = default, + VectorStoreFileStatusFilter? fileStatusFilter = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - return GetFileAssociationsAsync(vectorStoreId, options?.PageSizeLimit, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, options?.Filter?.ToString(), cancellationToken.ToRequestOptions()) + return GetFileAssociationsAsync(vectorStoreId, options?.PageSizeLimit, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, fileStatusFilter?.ToString(), cancellationToken.ToRequestOptions()) as AsyncCollectionResult; } @@ -382,16 +385,18 @@ public virtual AsyncCollectionResult GetFileAssociat /// The ID of the vector store to enumerate the file associations of. /// /// Options describing the collection to return. + /// A to match retrieved items to. /// A token that can be used to cancel this method call. /// A collection of . public virtual CollectionResult GetFileAssociations( string vectorStoreId, - VectorStoreFileAssociationCollectionOptions options = default, + OpenAIPageOptions options = default, + VectorStoreFileStatusFilter? fileStatusFilter = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - return GetFileAssociations(vectorStoreId, options?.PageSizeLimit, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, options?.Filter?.ToString(), cancellationToken.ToRequestOptions()) + return GetFileAssociations(vectorStoreId, options?.PageSizeLimit, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, fileStatusFilter?.ToString(), cancellationToken.ToRequestOptions()) as CollectionResult; } @@ -559,18 +564,20 @@ public virtual CreateBatchFileJobOperation CreateBatchFileJob( /// The ID of the batch file job that was previously scheduled. /// /// Options describing the collection to return. + /// A to match retrieved items to. /// A token that can be used to cancel this method call. /// A collection of . public virtual AsyncCollectionResult GetFileAssociationsAsync( string vectorStoreId, string batchJobId, - VectorStoreFileAssociationCollectionOptions options = default, + OpenAIPageOptions options = default, + VectorStoreFileStatusFilter? fileStatusFilter = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); Argument.AssertNotNullOrEmpty(batchJobId, nameof(batchJobId)); - return GetFileAssociationsAsync(vectorStoreId, batchJobId, options?.PageSizeLimit, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, options?.Filter?.ToString(), cancellationToken.ToRequestOptions()) + return GetFileAssociationsAsync(vectorStoreId, batchJobId, options?.PageSizeLimit, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, fileStatusFilter?.ToString(), cancellationToken.ToRequestOptions()) as AsyncCollectionResult; } @@ -625,18 +632,20 @@ public virtual AsyncCollectionResult GetFileAssociat /// The ID of the batch file job that was previously scheduled. /// /// Options describing the collection to return. + /// A to match retrieved items to. /// A token that can be used to cancel this method call. /// A collection of . public virtual CollectionResult GetFileAssociations( string vectorStoreId, string batchJobId, - VectorStoreFileAssociationCollectionOptions options = default, + OpenAIPageOptions options = default, + VectorStoreFileStatusFilter? fileStatusFilter = default, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); Argument.AssertNotNullOrEmpty(batchJobId, nameof(batchJobId)); - return GetFileAssociations(vectorStoreId, batchJobId, options?.PageSizeLimit, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, options?.Filter?.ToString(), cancellationToken.ToRequestOptions()) + return GetFileAssociations(vectorStoreId, batchJobId, options?.PageSizeLimit, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, fileStatusFilter?.ToString(), cancellationToken.ToRequestOptions()) as CollectionResult; } diff --git a/.dotnet/src/Custom/VectorStores/VectorStoreCollectionOptions.cs b/.dotnet/src/Custom/VectorStores/VectorStoreCollectionOptions.cs deleted file mode 100644 index 546ee6c95..000000000 --- a/.dotnet/src/Custom/VectorStores/VectorStoreCollectionOptions.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace OpenAI.VectorStores; - -/// The options to configure how objects are retrieved and paginated. -[Experimental("OPENAI001")] -public class VectorStoreCollectionOptions -{ - /// Initializes a new instance of . - public VectorStoreCollectionOptions() { } - - /// - /// A limit on the number of objects to be returned per page. - /// - public int? PageSizeLimit { get; set; } - - /// - /// The order in which to retrieve objects when sorted by their - /// timestamp. - /// - public VectorStoreCollectionOrder? Order { get; set; } - - /// - /// The used to retrieve the page of objects that come - /// after this one. - /// - public string AfterId { get; set; } - - /// - /// The used to retrieve the page of objects that come - /// before this one. - /// - public string BeforeId { get; set; } -} diff --git a/.dotnet/src/Custom/VectorStores/VectorStoreCollectionOrder.cs b/.dotnet/src/Custom/VectorStores/VectorStoreCollectionOrder.cs deleted file mode 100644 index 89aa5eda2..000000000 --- a/.dotnet/src/Custom/VectorStores/VectorStoreCollectionOrder.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace OpenAI.VectorStores; - -// CUSTOM: Renamed. -[Experimental("OPENAI001")] -[CodeGenModel("ListVectorStoresRequestOrder")] -public readonly partial struct VectorStoreCollectionOrder -{ - // CUSTOM: Renamed. - [CodeGenMember("Asc")] - public static VectorStoreCollectionOrder Ascending { get; } = new VectorStoreCollectionOrder(AscValue); - - // CUSTOM: Renamed. - [CodeGenMember("Desc")] - public static VectorStoreCollectionOrder Descending { get; } = new VectorStoreCollectionOrder(DescValue); -} diff --git a/.dotnet/src/Custom/VectorStores/VectorStoreFileAssociationCollectionOptions.cs b/.dotnet/src/Custom/VectorStores/VectorStoreFileAssociationCollectionOptions.cs deleted file mode 100644 index 71b2a8b0c..000000000 --- a/.dotnet/src/Custom/VectorStores/VectorStoreFileAssociationCollectionOptions.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace OpenAI.VectorStores; - -/// The options to configure how objects are retrieved and paginated. -[Experimental("OPENAI001")] -public class VectorStoreFileAssociationCollectionOptions -{ - /// Initializes a new instance of . - public VectorStoreFileAssociationCollectionOptions() { } - - /// - /// A limit on the number of objects to be returned per page. - /// - public int? PageSizeLimit { get; set; } - - /// - /// The order in which to retrieve objects when sorted by their - /// timestamp. - /// - public VectorStoreFileAssociationCollectionOrder? Order { get; set; } - - /// - /// The used to retrieve the page of objects that come - /// after this one. - /// - public string AfterId { get; set; } - - /// - /// The used to retrieve the page of objects that come - /// before this one. - /// - public string BeforeId { get; set; } - - /// - /// A filter to only retrieve the objects with a matching - /// . - /// - public VectorStoreFileStatusFilter? Filter { get; set; } -} diff --git a/.dotnet/src/Custom/VectorStores/VectorStoreFileAssociationCollectionOrder.cs b/.dotnet/src/Custom/VectorStores/VectorStoreFileAssociationCollectionOrder.cs deleted file mode 100644 index a71f40fa3..000000000 --- a/.dotnet/src/Custom/VectorStores/VectorStoreFileAssociationCollectionOrder.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Diagnostics.CodeAnalysis; - -namespace OpenAI.VectorStores; - -// CUSTOM: Renamed. -[Experimental("OPENAI001")] -[CodeGenModel("ListVectorStoreFilesRequestOrder")] -public readonly partial struct VectorStoreFileAssociationCollectionOrder -{ - // CUSTOM: Renamed. - [CodeGenMember("Asc")] - public static VectorStoreFileAssociationCollectionOrder Ascending { get; } = new VectorStoreFileAssociationCollectionOrder(AscValue); - - // CUSTOM: Renamed. - [CodeGenMember("Desc")] - public static VectorStoreFileAssociationCollectionOrder Descending { get; } = new VectorStoreFileAssociationCollectionOrder(DescValue); -} diff --git a/.dotnet/src/Generated/AssistantClient.RestClient.cs b/.dotnet/src/Generated/AssistantClient.RestClient.cs index aceab6704..fb09295ec 100644 --- a/.dotnet/src/Generated/AssistantClient.RestClient.cs +++ b/.dotnet/src/Generated/AssistantClient.RestClient.cs @@ -14,7 +14,7 @@ public partial class AssistantClient private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - internal PipelineMessage CreateCreateAssistantRequest(BinaryContent content, RequestOptions options) + internal virtual PipelineMessage CreateCreateAssistantRequest(BinaryContent content, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -25,13 +25,14 @@ internal PipelineMessage CreateCreateAssistantRequest(BinaryContent content, Req uri.AppendPath("/assistants", false); request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); request.Headers.Set("Content-Type", "application/json"); request.Content = content; message.Apply(options); return message; } - internal PipelineMessage CreateListAssistantsRequest(int? limit, string order, string after, string before, RequestOptions options) + internal virtual PipelineMessage CreateListAssistantsRequest(int? limit, string order, string after, string before, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -58,11 +59,12 @@ internal PipelineMessage CreateListAssistantsRequest(int? limit, string order, s } request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); message.Apply(options); return message; } - internal PipelineMessage CreateGetAssistantRequest(string assistantId, RequestOptions options) + internal virtual PipelineMessage CreateGetAssistantRequest(string assistantId, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -74,11 +76,12 @@ internal PipelineMessage CreateGetAssistantRequest(string assistantId, RequestOp uri.AppendPath(assistantId, true); request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); message.Apply(options); return message; } - internal PipelineMessage CreateModifyAssistantRequest(string assistantId, BinaryContent content, RequestOptions options) + internal virtual PipelineMessage CreateModifyAssistantRequest(string assistantId, BinaryContent content, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -90,13 +93,14 @@ internal PipelineMessage CreateModifyAssistantRequest(string assistantId, Binary uri.AppendPath(assistantId, true); request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); request.Headers.Set("Content-Type", "application/json"); request.Content = content; message.Apply(options); return message; } - internal PipelineMessage CreateDeleteAssistantRequest(string assistantId, RequestOptions options) + internal virtual PipelineMessage CreateDeleteAssistantRequest(string assistantId, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -108,6 +112,7 @@ internal PipelineMessage CreateDeleteAssistantRequest(string assistantId, Reques uri.AppendPath(assistantId, true); request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); message.Apply(options); return message; } diff --git a/.dotnet/src/Generated/AudioClient.RestClient.cs b/.dotnet/src/Generated/AudioClient.RestClient.cs index 32414e385..719788acf 100644 --- a/.dotnet/src/Generated/AudioClient.RestClient.cs +++ b/.dotnet/src/Generated/AudioClient.RestClient.cs @@ -14,7 +14,7 @@ public partial class AudioClient private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - internal PipelineMessage CreateCreateSpeechRequest(BinaryContent content, RequestOptions options) + internal virtual PipelineMessage CreateCreateSpeechRequest(BinaryContent content, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -31,7 +31,7 @@ internal PipelineMessage CreateCreateSpeechRequest(BinaryContent content, Reques return message; } - internal PipelineMessage CreateCreateTranscriptionRequest(BinaryContent content, string contentType, RequestOptions options) + internal virtual PipelineMessage CreateCreateTranscriptionRequest(BinaryContent content, string contentType, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -48,7 +48,7 @@ internal PipelineMessage CreateCreateTranscriptionRequest(BinaryContent content, return message; } - internal PipelineMessage CreateCreateTranslationRequest(BinaryContent content, string contentType, RequestOptions options) + internal virtual PipelineMessage CreateCreateTranslationRequest(BinaryContent content, string contentType, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; diff --git a/.dotnet/src/Generated/BatchClient.RestClient.cs b/.dotnet/src/Generated/BatchClient.RestClient.cs index 5e7c89126..18728659b 100644 --- a/.dotnet/src/Generated/BatchClient.RestClient.cs +++ b/.dotnet/src/Generated/BatchClient.RestClient.cs @@ -13,7 +13,7 @@ public partial class BatchClient private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - internal PipelineMessage CreateListBatchesRequest(string after, int? limit, RequestOptions options) + internal virtual PipelineMessage CreateListBatchesRequest(string after, int? limit, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; diff --git a/.dotnet/src/Generated/ChatClient.RestClient.cs b/.dotnet/src/Generated/ChatClient.RestClient.cs index 2b61a84e4..cebe4507a 100644 --- a/.dotnet/src/Generated/ChatClient.RestClient.cs +++ b/.dotnet/src/Generated/ChatClient.RestClient.cs @@ -14,7 +14,7 @@ public partial class ChatClient private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - internal PipelineMessage CreateCreateChatCompletionRequest(BinaryContent content, RequestOptions options) + internal virtual PipelineMessage CreateCreateChatCompletionRequest(BinaryContent content, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; diff --git a/.dotnet/src/Generated/EmbeddingClient.RestClient.cs b/.dotnet/src/Generated/EmbeddingClient.RestClient.cs index 5854624b1..ec3641cc6 100644 --- a/.dotnet/src/Generated/EmbeddingClient.RestClient.cs +++ b/.dotnet/src/Generated/EmbeddingClient.RestClient.cs @@ -14,7 +14,7 @@ public partial class EmbeddingClient private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - internal PipelineMessage CreateCreateEmbeddingRequest(BinaryContent content, RequestOptions options) + internal virtual PipelineMessage CreateCreateEmbeddingRequest(BinaryContent content, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; diff --git a/.dotnet/src/Generated/FineTuningClient.RestClient.cs b/.dotnet/src/Generated/FineTuningClient.RestClient.cs index 190bee083..2997b3f6c 100644 --- a/.dotnet/src/Generated/FineTuningClient.RestClient.cs +++ b/.dotnet/src/Generated/FineTuningClient.RestClient.cs @@ -13,7 +13,7 @@ public partial class FineTuningClient private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - internal PipelineMessage CreateListPaginatedFineTuningJobsRequest(string after, int? limit, RequestOptions options) + internal virtual PipelineMessage CreateListPaginatedFineTuningJobsRequest(string after, int? limit, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -36,7 +36,7 @@ internal PipelineMessage CreateListPaginatedFineTuningJobsRequest(string after, return message; } - internal PipelineMessage CreateCancelFineTuningJobRequest(string fineTuningJobId, RequestOptions options) + internal virtual PipelineMessage CreateCancelFineTuningJobRequest(string fineTuningJobId, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -53,7 +53,7 @@ internal PipelineMessage CreateCancelFineTuningJobRequest(string fineTuningJobId return message; } - internal PipelineMessage CreateListFineTuningJobCheckpointsRequest(string fineTuningJobId, string after, int? limit, RequestOptions options) + internal virtual PipelineMessage CreateListFineTuningJobCheckpointsRequest(string fineTuningJobId, string after, int? limit, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -78,7 +78,7 @@ internal PipelineMessage CreateListFineTuningJobCheckpointsRequest(string fineTu return message; } - internal PipelineMessage CreateListFineTuningEventsRequest(string fineTuningJobId, string after, int? limit, RequestOptions options) + internal virtual PipelineMessage CreateListFineTuningEventsRequest(string fineTuningJobId, string after, int? limit, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; diff --git a/.dotnet/src/Generated/ImageClient.RestClient.cs b/.dotnet/src/Generated/ImageClient.RestClient.cs index 7118e55c4..51efb2d3c 100644 --- a/.dotnet/src/Generated/ImageClient.RestClient.cs +++ b/.dotnet/src/Generated/ImageClient.RestClient.cs @@ -14,7 +14,7 @@ public partial class ImageClient private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - internal PipelineMessage CreateCreateImageRequest(BinaryContent content, RequestOptions options) + internal virtual PipelineMessage CreateCreateImageRequest(BinaryContent content, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -31,7 +31,7 @@ internal PipelineMessage CreateCreateImageRequest(BinaryContent content, Request return message; } - internal PipelineMessage CreateCreateImageEditRequest(BinaryContent content, string contentType, RequestOptions options) + internal virtual PipelineMessage CreateCreateImageEditRequest(BinaryContent content, string contentType, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -48,7 +48,7 @@ internal PipelineMessage CreateCreateImageEditRequest(BinaryContent content, str return message; } - internal PipelineMessage CreateCreateImageVariationRequest(BinaryContent content, string contentType, RequestOptions options) + internal virtual PipelineMessage CreateCreateImageVariationRequest(BinaryContent content, string contentType, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; diff --git a/.dotnet/src/Generated/InternalAssistantMessageClient.RestClient.cs b/.dotnet/src/Generated/InternalAssistantMessageClient.RestClient.cs index ee4043f1a..d095f507b 100644 --- a/.dotnet/src/Generated/InternalAssistantMessageClient.RestClient.cs +++ b/.dotnet/src/Generated/InternalAssistantMessageClient.RestClient.cs @@ -14,7 +14,7 @@ internal partial class InternalAssistantMessageClient private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - internal PipelineMessage CreateCreateMessageRequest(string threadId, BinaryContent content, RequestOptions options) + internal virtual PipelineMessage CreateCreateMessageRequest(string threadId, BinaryContent content, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -27,13 +27,14 @@ internal PipelineMessage CreateCreateMessageRequest(string threadId, BinaryConte uri.AppendPath("/messages", false); request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); request.Headers.Set("Content-Type", "application/json"); request.Content = content; message.Apply(options); return message; } - internal PipelineMessage CreateListMessagesRequest(string threadId, int? limit, string order, string after, string before, RequestOptions options) + internal virtual PipelineMessage CreateListMessagesRequest(string threadId, int? limit, string order, string after, string before, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -62,11 +63,12 @@ internal PipelineMessage CreateListMessagesRequest(string threadId, int? limit, } request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); message.Apply(options); return message; } - internal PipelineMessage CreateGetMessageRequest(string threadId, string messageId, RequestOptions options) + internal virtual PipelineMessage CreateGetMessageRequest(string threadId, string messageId, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -80,11 +82,12 @@ internal PipelineMessage CreateGetMessageRequest(string threadId, string message uri.AppendPath(messageId, true); request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); message.Apply(options); return message; } - internal PipelineMessage CreateModifyMessageRequest(string threadId, string messageId, BinaryContent content, RequestOptions options) + internal virtual PipelineMessage CreateModifyMessageRequest(string threadId, string messageId, BinaryContent content, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -98,13 +101,14 @@ internal PipelineMessage CreateModifyMessageRequest(string threadId, string mess uri.AppendPath(messageId, true); request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); request.Headers.Set("Content-Type", "application/json"); request.Content = content; message.Apply(options); return message; } - internal PipelineMessage CreateDeleteMessageRequest(string threadId, string messageId, RequestOptions options) + internal virtual PipelineMessage CreateDeleteMessageRequest(string threadId, string messageId, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -118,6 +122,7 @@ internal PipelineMessage CreateDeleteMessageRequest(string threadId, string mess uri.AppendPath(messageId, true); request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); message.Apply(options); return message; } diff --git a/.dotnet/src/Generated/InternalAssistantRunClient.RestClient.cs b/.dotnet/src/Generated/InternalAssistantRunClient.RestClient.cs index d0e3a535a..ae66bbf15 100644 --- a/.dotnet/src/Generated/InternalAssistantRunClient.RestClient.cs +++ b/.dotnet/src/Generated/InternalAssistantRunClient.RestClient.cs @@ -15,7 +15,7 @@ internal partial class InternalAssistantRunClient private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - internal PipelineMessage CreateCreateThreadAndRunRequest(BinaryContent content, RequestOptions options) + internal virtual PipelineMessage CreateCreateThreadAndRunRequest(BinaryContent content, string accept, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -25,14 +25,15 @@ internal PipelineMessage CreateCreateThreadAndRunRequest(BinaryContent content, uri.Reset(_endpoint); uri.AppendPath("/threads/runs", false); request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Accept", accept); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); request.Headers.Set("Content-Type", "application/json"); request.Content = content; message.Apply(options); return message; } - internal PipelineMessage CreateCreateRunRequest(string threadId, BinaryContent content, IEnumerable include, RequestOptions options) + internal virtual PipelineMessage CreateCreateRunRequest(string threadId, BinaryContent content, string accept, IEnumerable include, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -48,14 +49,15 @@ internal PipelineMessage CreateCreateRunRequest(string threadId, BinaryContent c uri.AppendQueryDelimited("include[]", include, ",", null, true); } request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Accept", accept); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); request.Headers.Set("Content-Type", "application/json"); request.Content = content; message.Apply(options); return message; } - internal PipelineMessage CreateListRunsRequest(string threadId, int? limit, string order, string after, string before, RequestOptions options) + internal virtual PipelineMessage CreateListRunsRequest(string threadId, int? limit, string order, string after, string before, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -84,11 +86,12 @@ internal PipelineMessage CreateListRunsRequest(string threadId, int? limit, stri } request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); message.Apply(options); return message; } - internal PipelineMessage CreateGetRunRequest(string threadId, string runId, RequestOptions options) + internal virtual PipelineMessage CreateGetRunRequest(string threadId, string runId, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -102,11 +105,12 @@ internal PipelineMessage CreateGetRunRequest(string threadId, string runId, Requ uri.AppendPath(runId, true); request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); message.Apply(options); return message; } - internal PipelineMessage CreateModifyRunRequest(string threadId, string runId, BinaryContent content, RequestOptions options) + internal virtual PipelineMessage CreateModifyRunRequest(string threadId, string runId, BinaryContent content, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -120,13 +124,14 @@ internal PipelineMessage CreateModifyRunRequest(string threadId, string runId, B uri.AppendPath(runId, true); request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); request.Headers.Set("Content-Type", "application/json"); request.Content = content; message.Apply(options); return message; } - internal PipelineMessage CreateCancelRunRequest(string threadId, string runId, RequestOptions options) + internal virtual PipelineMessage CreateCancelRunRequest(string threadId, string runId, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -141,11 +146,12 @@ internal PipelineMessage CreateCancelRunRequest(string threadId, string runId, R uri.AppendPath("/cancel", false); request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); message.Apply(options); return message; } - internal PipelineMessage CreateSubmitToolOutputsToRunRequest(string threadId, string runId, BinaryContent content, RequestOptions options) + internal virtual PipelineMessage CreateSubmitToolOutputsToRunRequest(string threadId, string runId, BinaryContent content, string accept, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -159,14 +165,15 @@ internal PipelineMessage CreateSubmitToolOutputsToRunRequest(string threadId, st uri.AppendPath(runId, true); uri.AppendPath("/submit_tool_outputs", false); request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); + request.Headers.Set("Accept", accept); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); request.Headers.Set("Content-Type", "application/json"); request.Content = content; message.Apply(options); return message; } - internal PipelineMessage CreateListRunStepsRequest(string threadId, string runId, int? limit, string order, string after, string before, IEnumerable include, RequestOptions options) + internal virtual PipelineMessage CreateListRunStepsRequest(string threadId, string runId, int? limit, string order, string after, string before, IEnumerable include, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -201,11 +208,12 @@ internal PipelineMessage CreateListRunStepsRequest(string threadId, string runId } request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); message.Apply(options); return message; } - internal PipelineMessage CreateGetRunStepRequest(string threadId, string runId, string stepId, IEnumerable include, RequestOptions options) + internal virtual PipelineMessage CreateGetRunStepRequest(string threadId, string runId, string stepId, IEnumerable include, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -225,6 +233,7 @@ internal PipelineMessage CreateGetRunStepRequest(string threadId, string runId, } request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); message.Apply(options); return message; } diff --git a/.dotnet/src/Generated/InternalAssistantThreadClient.RestClient.cs b/.dotnet/src/Generated/InternalAssistantThreadClient.RestClient.cs index 1064c666e..7608eceaa 100644 --- a/.dotnet/src/Generated/InternalAssistantThreadClient.RestClient.cs +++ b/.dotnet/src/Generated/InternalAssistantThreadClient.RestClient.cs @@ -14,7 +14,7 @@ internal partial class InternalAssistantThreadClient private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - internal PipelineMessage CreateCreateThreadRequest(BinaryContent content, RequestOptions options) + internal virtual PipelineMessage CreateCreateThreadRequest(BinaryContent content, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -25,13 +25,14 @@ internal PipelineMessage CreateCreateThreadRequest(BinaryContent content, Reques uri.AppendPath("/threads", false); request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); request.Headers.Set("Content-Type", "application/json"); request.Content = content; message.Apply(options); return message; } - internal PipelineMessage CreateGetThreadRequest(string threadId, RequestOptions options) + internal virtual PipelineMessage CreateGetThreadRequest(string threadId, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -43,11 +44,12 @@ internal PipelineMessage CreateGetThreadRequest(string threadId, RequestOptions uri.AppendPath(threadId, true); request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); message.Apply(options); return message; } - internal PipelineMessage CreateModifyThreadRequest(string threadId, BinaryContent content, RequestOptions options) + internal virtual PipelineMessage CreateModifyThreadRequest(string threadId, BinaryContent content, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -59,13 +61,14 @@ internal PipelineMessage CreateModifyThreadRequest(string threadId, BinaryConten uri.AppendPath(threadId, true); request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); request.Headers.Set("Content-Type", "application/json"); request.Content = content; message.Apply(options); return message; } - internal PipelineMessage CreateDeleteThreadRequest(string threadId, RequestOptions options) + internal virtual PipelineMessage CreateDeleteThreadRequest(string threadId, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -77,6 +80,7 @@ internal PipelineMessage CreateDeleteThreadRequest(string threadId, RequestOptio uri.AppendPath(threadId, true); request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); message.Apply(options); return message; } diff --git a/.dotnet/src/Generated/InternalUploadsClient.RestClient.cs b/.dotnet/src/Generated/InternalUploadsClient.RestClient.cs index e107394fd..37ec553a5 100644 --- a/.dotnet/src/Generated/InternalUploadsClient.RestClient.cs +++ b/.dotnet/src/Generated/InternalUploadsClient.RestClient.cs @@ -14,7 +14,7 @@ internal partial class InternalUploadsClient private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - internal PipelineMessage CreateCreateUploadRequest(BinaryContent content, RequestOptions options) + internal virtual PipelineMessage CreateCreateUploadRequest(BinaryContent content, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -31,7 +31,7 @@ internal PipelineMessage CreateCreateUploadRequest(BinaryContent content, Reques return message; } - internal PipelineMessage CreateAddUploadPartRequest(string uploadId, BinaryContent content, string contentType, RequestOptions options) + internal virtual PipelineMessage CreateAddUploadPartRequest(string uploadId, BinaryContent content, string contentType, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -50,7 +50,7 @@ internal PipelineMessage CreateAddUploadPartRequest(string uploadId, BinaryConte return message; } - internal PipelineMessage CreateCompleteUploadRequest(string uploadId, BinaryContent content, RequestOptions options) + internal virtual PipelineMessage CreateCompleteUploadRequest(string uploadId, BinaryContent content, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -69,7 +69,7 @@ internal PipelineMessage CreateCompleteUploadRequest(string uploadId, BinaryCont return message; } - internal PipelineMessage CreateCancelUploadRequest(string uploadId, RequestOptions options) + internal virtual PipelineMessage CreateCancelUploadRequest(string uploadId, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; diff --git a/.dotnet/src/Generated/LegacyCompletionClient.RestClient.cs b/.dotnet/src/Generated/LegacyCompletionClient.RestClient.cs index 2ef638da5..e4a52c7b5 100644 --- a/.dotnet/src/Generated/LegacyCompletionClient.RestClient.cs +++ b/.dotnet/src/Generated/LegacyCompletionClient.RestClient.cs @@ -14,7 +14,7 @@ internal partial class LegacyCompletionClient private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - internal PipelineMessage CreateCreateCompletionRequest(BinaryContent content, RequestOptions options) + internal virtual PipelineMessage CreateCreateCompletionRequest(BinaryContent content, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; diff --git a/.dotnet/src/Generated/Models/AssistantCollectionOrder.cs b/.dotnet/src/Generated/Models/AssistantCollectionOrder.cs deleted file mode 100644 index 41d2f8d50..000000000 --- a/.dotnet/src/Generated/Models/AssistantCollectionOrder.cs +++ /dev/null @@ -1,40 +0,0 @@ -// - -#nullable disable - -using System; -using System.ComponentModel; -using OpenAI; - -namespace OpenAI.Assistants -{ - public readonly partial struct AssistantCollectionOrder : IEquatable - { - private readonly string _value; - private const string AscValue = "asc"; - private const string DescValue = "desc"; - - public AssistantCollectionOrder(string value) - { - Argument.AssertNotNull(value, nameof(value)); - - _value = value; - } - - public static bool operator ==(AssistantCollectionOrder left, AssistantCollectionOrder right) => left.Equals(right); - - public static bool operator !=(AssistantCollectionOrder left, AssistantCollectionOrder right) => !left.Equals(right); - - public static implicit operator AssistantCollectionOrder(string value) => new AssistantCollectionOrder(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is AssistantCollectionOrder other && Equals(other); - - public bool Equals(AssistantCollectionOrder other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - - public override string ToString() => _value; - } -} diff --git a/.dotnet/src/Generated/Models/InternalCreateThreadAndRunRequestAccept.cs b/.dotnet/src/Generated/Models/InternalCreateThreadAndRunRequestAccept.cs new file mode 100644 index 000000000..96d276a0f --- /dev/null +++ b/.dotnet/src/Generated/Models/InternalCreateThreadAndRunRequestAccept.cs @@ -0,0 +1,44 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using OpenAI; + +namespace OpenAI.Assistants +{ + internal readonly partial struct InternalCreateThreadAndRunRequestAccept : IEquatable + { + private readonly string _value; + private const string ApplicationJsonValue = "application/json"; + private const string TextEventStreamValue = "text/event-stream"; + + public InternalCreateThreadAndRunRequestAccept(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static InternalCreateThreadAndRunRequestAccept ApplicationJson { get; } = new InternalCreateThreadAndRunRequestAccept(ApplicationJsonValue); + + public static InternalCreateThreadAndRunRequestAccept TextEventStream { get; } = new InternalCreateThreadAndRunRequestAccept(TextEventStreamValue); + + public static bool operator ==(InternalCreateThreadAndRunRequestAccept left, InternalCreateThreadAndRunRequestAccept right) => left.Equals(right); + + public static bool operator !=(InternalCreateThreadAndRunRequestAccept left, InternalCreateThreadAndRunRequestAccept right) => !left.Equals(right); + + public static implicit operator InternalCreateThreadAndRunRequestAccept(string value) => new InternalCreateThreadAndRunRequestAccept(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalCreateThreadAndRunRequestAccept other && Equals(other); + + public bool Equals(InternalCreateThreadAndRunRequestAccept other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/.dotnet/src/Generated/Models/InternalListFilesInVectorStoreBatchRequestOrder.cs b/.dotnet/src/Generated/Models/InternalListFilesInVectorStoreBatchRequestOrder.cs deleted file mode 100644 index 621f99ed5..000000000 --- a/.dotnet/src/Generated/Models/InternalListFilesInVectorStoreBatchRequestOrder.cs +++ /dev/null @@ -1,44 +0,0 @@ -// - -#nullable disable - -using System; -using System.ComponentModel; -using OpenAI; - -namespace OpenAI.VectorStores -{ - internal readonly partial struct InternalListFilesInVectorStoreBatchRequestOrder : IEquatable - { - private readonly string _value; - private const string AscValue = "asc"; - private const string DescValue = "desc"; - - public InternalListFilesInVectorStoreBatchRequestOrder(string value) - { - Argument.AssertNotNull(value, nameof(value)); - - _value = value; - } - - public static InternalListFilesInVectorStoreBatchRequestOrder Asc { get; } = new InternalListFilesInVectorStoreBatchRequestOrder(AscValue); - - public static InternalListFilesInVectorStoreBatchRequestOrder Desc { get; } = new InternalListFilesInVectorStoreBatchRequestOrder(DescValue); - - public static bool operator ==(InternalListFilesInVectorStoreBatchRequestOrder left, InternalListFilesInVectorStoreBatchRequestOrder right) => left.Equals(right); - - public static bool operator !=(InternalListFilesInVectorStoreBatchRequestOrder left, InternalListFilesInVectorStoreBatchRequestOrder right) => !left.Equals(right); - - public static implicit operator InternalListFilesInVectorStoreBatchRequestOrder(string value) => new InternalListFilesInVectorStoreBatchRequestOrder(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalListFilesInVectorStoreBatchRequestOrder other && Equals(other); - - public bool Equals(InternalListFilesInVectorStoreBatchRequestOrder other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - - public override string ToString() => _value; - } -} diff --git a/.dotnet/src/Generated/Models/MessageCollectionOrder.cs b/.dotnet/src/Generated/Models/MessageCollectionOrder.cs deleted file mode 100644 index 6c8a4153c..000000000 --- a/.dotnet/src/Generated/Models/MessageCollectionOrder.cs +++ /dev/null @@ -1,40 +0,0 @@ -// - -#nullable disable - -using System; -using System.ComponentModel; -using OpenAI; - -namespace OpenAI.Assistants -{ - public readonly partial struct MessageCollectionOrder : IEquatable - { - private readonly string _value; - private const string AscValue = "asc"; - private const string DescValue = "desc"; - - public MessageCollectionOrder(string value) - { - Argument.AssertNotNull(value, nameof(value)); - - _value = value; - } - - public static bool operator ==(MessageCollectionOrder left, MessageCollectionOrder right) => left.Equals(right); - - public static bool operator !=(MessageCollectionOrder left, MessageCollectionOrder right) => !left.Equals(right); - - public static implicit operator MessageCollectionOrder(string value) => new MessageCollectionOrder(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is MessageCollectionOrder other && Equals(other); - - public bool Equals(MessageCollectionOrder other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - - public override string ToString() => _value; - } -} diff --git a/.dotnet/src/Generated/Models/OpenAIPageOrder.cs b/.dotnet/src/Generated/Models/OpenAIPageOrder.cs new file mode 100644 index 000000000..d6e620155 --- /dev/null +++ b/.dotnet/src/Generated/Models/OpenAIPageOrder.cs @@ -0,0 +1,39 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace OpenAI +{ + public readonly partial struct OpenAIPageOrder : IEquatable + { + private readonly string _value; + private const string AscValue = "asc"; + private const string DescValue = "desc"; + + public OpenAIPageOrder(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + public static bool operator ==(OpenAIPageOrder left, OpenAIPageOrder right) => left.Equals(right); + + public static bool operator !=(OpenAIPageOrder left, OpenAIPageOrder right) => !left.Equals(right); + + public static implicit operator OpenAIPageOrder(string value) => new OpenAIPageOrder(value); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OpenAIPageOrder other && Equals(other); + + public bool Equals(OpenAIPageOrder other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + public override string ToString() => _value; + } +} diff --git a/.dotnet/src/Generated/Models/RunCollectionOrder.cs b/.dotnet/src/Generated/Models/RunCollectionOrder.cs deleted file mode 100644 index d16dcacf3..000000000 --- a/.dotnet/src/Generated/Models/RunCollectionOrder.cs +++ /dev/null @@ -1,40 +0,0 @@ -// - -#nullable disable - -using System; -using System.ComponentModel; -using OpenAI; - -namespace OpenAI.Assistants -{ - public readonly partial struct RunCollectionOrder : IEquatable - { - private readonly string _value; - private const string AscValue = "asc"; - private const string DescValue = "desc"; - - public RunCollectionOrder(string value) - { - Argument.AssertNotNull(value, nameof(value)); - - _value = value; - } - - public static bool operator ==(RunCollectionOrder left, RunCollectionOrder right) => left.Equals(right); - - public static bool operator !=(RunCollectionOrder left, RunCollectionOrder right) => !left.Equals(right); - - public static implicit operator RunCollectionOrder(string value) => new RunCollectionOrder(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is RunCollectionOrder other && Equals(other); - - public bool Equals(RunCollectionOrder other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - - public override string ToString() => _value; - } -} diff --git a/.dotnet/src/Generated/Models/RunStepCollectionOrder.cs b/.dotnet/src/Generated/Models/RunStepCollectionOrder.cs deleted file mode 100644 index ec2f727c4..000000000 --- a/.dotnet/src/Generated/Models/RunStepCollectionOrder.cs +++ /dev/null @@ -1,40 +0,0 @@ -// - -#nullable disable - -using System; -using System.ComponentModel; -using OpenAI; - -namespace OpenAI.Assistants -{ - public readonly partial struct RunStepCollectionOrder : IEquatable - { - private readonly string _value; - private const string AscValue = "asc"; - private const string DescValue = "desc"; - - public RunStepCollectionOrder(string value) - { - Argument.AssertNotNull(value, nameof(value)); - - _value = value; - } - - public static bool operator ==(RunStepCollectionOrder left, RunStepCollectionOrder right) => left.Equals(right); - - public static bool operator !=(RunStepCollectionOrder left, RunStepCollectionOrder right) => !left.Equals(right); - - public static implicit operator RunStepCollectionOrder(string value) => new RunStepCollectionOrder(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is RunStepCollectionOrder other && Equals(other); - - public bool Equals(RunStepCollectionOrder other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - - public override string ToString() => _value; - } -} diff --git a/.dotnet/src/Generated/Models/VectorStoreCollectionOrder.cs b/.dotnet/src/Generated/Models/VectorStoreCollectionOrder.cs deleted file mode 100644 index 02d58180c..000000000 --- a/.dotnet/src/Generated/Models/VectorStoreCollectionOrder.cs +++ /dev/null @@ -1,40 +0,0 @@ -// - -#nullable disable - -using System; -using System.ComponentModel; -using OpenAI; - -namespace OpenAI.VectorStores -{ - public readonly partial struct VectorStoreCollectionOrder : IEquatable - { - private readonly string _value; - private const string AscValue = "asc"; - private const string DescValue = "desc"; - - public VectorStoreCollectionOrder(string value) - { - Argument.AssertNotNull(value, nameof(value)); - - _value = value; - } - - public static bool operator ==(VectorStoreCollectionOrder left, VectorStoreCollectionOrder right) => left.Equals(right); - - public static bool operator !=(VectorStoreCollectionOrder left, VectorStoreCollectionOrder right) => !left.Equals(right); - - public static implicit operator VectorStoreCollectionOrder(string value) => new VectorStoreCollectionOrder(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is VectorStoreCollectionOrder other && Equals(other); - - public bool Equals(VectorStoreCollectionOrder other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - - public override string ToString() => _value; - } -} diff --git a/.dotnet/src/Generated/Models/VectorStoreFileAssociationCollectionOrder.cs b/.dotnet/src/Generated/Models/VectorStoreFileAssociationCollectionOrder.cs deleted file mode 100644 index 0f1f67686..000000000 --- a/.dotnet/src/Generated/Models/VectorStoreFileAssociationCollectionOrder.cs +++ /dev/null @@ -1,40 +0,0 @@ -// - -#nullable disable - -using System; -using System.ComponentModel; -using OpenAI; - -namespace OpenAI.VectorStores -{ - public readonly partial struct VectorStoreFileAssociationCollectionOrder : IEquatable - { - private readonly string _value; - private const string AscValue = "asc"; - private const string DescValue = "desc"; - - public VectorStoreFileAssociationCollectionOrder(string value) - { - Argument.AssertNotNull(value, nameof(value)); - - _value = value; - } - - public static bool operator ==(VectorStoreFileAssociationCollectionOrder left, VectorStoreFileAssociationCollectionOrder right) => left.Equals(right); - - public static bool operator !=(VectorStoreFileAssociationCollectionOrder left, VectorStoreFileAssociationCollectionOrder right) => !left.Equals(right); - - public static implicit operator VectorStoreFileAssociationCollectionOrder(string value) => new VectorStoreFileAssociationCollectionOrder(value); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is VectorStoreFileAssociationCollectionOrder other && Equals(other); - - public bool Equals(VectorStoreFileAssociationCollectionOrder other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - - public override string ToString() => _value; - } -} diff --git a/.dotnet/src/Generated/ModerationClient.RestClient.cs b/.dotnet/src/Generated/ModerationClient.RestClient.cs index 6830098b0..013ff75d5 100644 --- a/.dotnet/src/Generated/ModerationClient.RestClient.cs +++ b/.dotnet/src/Generated/ModerationClient.RestClient.cs @@ -14,7 +14,7 @@ public partial class ModerationClient private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - internal PipelineMessage CreateCreateModerationRequest(BinaryContent content, RequestOptions options) + internal virtual PipelineMessage CreateCreateModerationRequest(BinaryContent content, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; diff --git a/.dotnet/src/Generated/OpenAIFileClient.RestClient.cs b/.dotnet/src/Generated/OpenAIFileClient.RestClient.cs index 75e133f8b..d47b1cc5b 100644 --- a/.dotnet/src/Generated/OpenAIFileClient.RestClient.cs +++ b/.dotnet/src/Generated/OpenAIFileClient.RestClient.cs @@ -14,7 +14,7 @@ public partial class OpenAIFileClient private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - internal PipelineMessage CreateCreateFileRequest(BinaryContent content, string contentType, RequestOptions options) + internal virtual PipelineMessage CreateCreateFileRequest(BinaryContent content, string contentType, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -31,7 +31,7 @@ internal PipelineMessage CreateCreateFileRequest(BinaryContent content, string c return message; } - internal PipelineMessage CreateListFilesRequest(string purpose, RequestOptions options) + internal virtual PipelineMessage CreateListFilesRequest(string purpose, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -50,7 +50,7 @@ internal PipelineMessage CreateListFilesRequest(string purpose, RequestOptions o return message; } - internal PipelineMessage CreateRetrieveFileRequest(string fileId, RequestOptions options) + internal virtual PipelineMessage CreateRetrieveFileRequest(string fileId, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -66,7 +66,7 @@ internal PipelineMessage CreateRetrieveFileRequest(string fileId, RequestOptions return message; } - internal PipelineMessage CreateDeleteFileRequest(string fileId, RequestOptions options) + internal virtual PipelineMessage CreateDeleteFileRequest(string fileId, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -82,7 +82,7 @@ internal PipelineMessage CreateDeleteFileRequest(string fileId, RequestOptions o return message; } - internal PipelineMessage CreateDownloadFileRequest(string fileId, RequestOptions options) + internal virtual PipelineMessage CreateDownloadFileRequest(string fileId, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; diff --git a/.dotnet/src/Generated/OpenAIModelClient.RestClient.cs b/.dotnet/src/Generated/OpenAIModelClient.RestClient.cs index a94220acb..f1d547240 100644 --- a/.dotnet/src/Generated/OpenAIModelClient.RestClient.cs +++ b/.dotnet/src/Generated/OpenAIModelClient.RestClient.cs @@ -13,7 +13,7 @@ public partial class OpenAIModelClient private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - internal PipelineMessage CreateListModelsRequest(RequestOptions options) + internal virtual PipelineMessage CreateListModelsRequest(RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -28,7 +28,7 @@ internal PipelineMessage CreateListModelsRequest(RequestOptions options) return message; } - internal PipelineMessage CreateRetrieveModelRequest(string model, RequestOptions options) + internal virtual PipelineMessage CreateRetrieveModelRequest(string model, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -44,7 +44,7 @@ internal PipelineMessage CreateRetrieveModelRequest(string model, RequestOptions return message; } - internal PipelineMessage CreateDeleteModelRequest(string model, RequestOptions options) + internal virtual PipelineMessage CreateDeleteModelRequest(string model, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; diff --git a/.dotnet/src/Generated/VectorStoreClient.RestClient.cs b/.dotnet/src/Generated/VectorStoreClient.RestClient.cs index 322a97d5f..1ff1b42cf 100644 --- a/.dotnet/src/Generated/VectorStoreClient.RestClient.cs +++ b/.dotnet/src/Generated/VectorStoreClient.RestClient.cs @@ -2,6 +2,7 @@ #nullable disable +using System.ClientModel; using System.ClientModel.Primitives; using OpenAI; @@ -13,7 +14,7 @@ public partial class VectorStoreClient private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - internal PipelineMessage CreateListVectorStoresRequest(int? limit, string order, string after, string before, RequestOptions options) + internal virtual PipelineMessage CreateListVectorStoresRequest(int? limit, string order, string after, string before, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -40,11 +41,83 @@ internal PipelineMessage CreateListVectorStoresRequest(int? limit, string order, } request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); message.Apply(options); return message; } - internal PipelineMessage CreateListVectorStoreFilesRequest(string vectorStoreId, int? limit, string order, string after, string before, string filter, RequestOptions options) + internal virtual PipelineMessage CreateCreateVectorStoreRequest(BinaryContent content, RequestOptions options) + { + PipelineMessage message = Pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + PipelineRequest request = message.Request; + request.Method = "POST"; + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal virtual PipelineMessage CreateGetVectorStoreRequest(string vectorStoreId, RequestOptions options) + { + PipelineMessage message = Pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + PipelineRequest request = message.Request; + request.Method = "GET"; + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); + message.Apply(options); + return message; + } + + internal virtual PipelineMessage CreateModifyVectorStoreRequest(string vectorStoreId, BinaryContent content, RequestOptions options) + { + PipelineMessage message = Pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + PipelineRequest request = message.Request; + request.Method = "POST"; + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal virtual PipelineMessage CreateDeleteVectorStoreRequest(string vectorStoreId, RequestOptions options) + { + PipelineMessage message = Pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + PipelineRequest request = message.Request; + request.Method = "DELETE"; + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); + message.Apply(options); + return message; + } + + internal virtual PipelineMessage CreateListVectorStoreFilesRequest(string vectorStoreId, int? limit, string order, string after, string before, string filter, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -77,11 +150,129 @@ internal PipelineMessage CreateListVectorStoreFilesRequest(string vectorStoreId, } request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); + message.Apply(options); + return message; + } + + internal virtual PipelineMessage CreateCreateVectorStoreFileRequest(string vectorStoreId, BinaryContent content, RequestOptions options) + { + PipelineMessage message = Pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + PipelineRequest request = message.Request; + request.Method = "POST"; + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/files", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal virtual PipelineMessage CreateGetVectorStoreFileRequest(string vectorStoreId, string fileId, RequestOptions options) + { + PipelineMessage message = Pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + PipelineRequest request = message.Request; + request.Method = "GET"; + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/files/", false); + uri.AppendPath(fileId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); + message.Apply(options); + return message; + } + + internal virtual PipelineMessage CreateDeleteVectorStoreFileRequest(string vectorStoreId, string fileId, RequestOptions options) + { + PipelineMessage message = Pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + PipelineRequest request = message.Request; + request.Method = "DELETE"; + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/files/", false); + uri.AppendPath(fileId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); + message.Apply(options); + return message; + } + + internal virtual PipelineMessage CreateCreateVectorStoreFileBatchRequest(string vectorStoreId, BinaryContent content, RequestOptions options) + { + PipelineMessage message = Pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + PipelineRequest request = message.Request; + request.Method = "POST"; + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/file_batches", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); + request.Headers.Set("Content-Type", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal virtual PipelineMessage CreateGetVectorStoreFileBatchRequest(string vectorStoreId, string batchId, RequestOptions options) + { + PipelineMessage message = Pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + PipelineRequest request = message.Request; + request.Method = "GET"; + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/file_batches/", false); + uri.AppendPath(batchId, true); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); + message.Apply(options); + return message; + } + + internal virtual PipelineMessage CreateCancelVectorStoreFileBatchRequest(string vectorStoreId, string batchId, RequestOptions options) + { + PipelineMessage message = Pipeline.CreateMessage(); + message.ResponseClassifier = PipelineMessageClassifier200; + PipelineRequest request = message.Request; + request.Method = "POST"; + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/file_batches/", false); + uri.AppendPath(batchId, true); + uri.AppendPath("/cancel", false); + request.Uri = uri.ToUri(); + request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); message.Apply(options); return message; } - internal PipelineMessage CreateListFilesInVectorStoreBatchRequest(string vectorStoreId, string batchId, int? limit, string order, string after, string before, string filter, RequestOptions options) + internal virtual PipelineMessage CreateListFilesInVectorStoreBatchRequest(string vectorStoreId, string batchId, int? limit, string order, string after, string before, string filter, RequestOptions options) { PipelineMessage message = Pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; @@ -116,6 +307,7 @@ internal PipelineMessage CreateListFilesInVectorStoreBatchRequest(string vectorS } request.Uri = uri.ToUri(); request.Headers.Set("Accept", "application/json"); + request.Headers.Set("OpenAI-Beta", "assistants=v2"); message.Apply(options); return message; } diff --git a/.dotnet/src/Generated/VectorStoreClient.cs b/.dotnet/src/Generated/VectorStoreClient.cs index 975fb140c..8a0a7a7d4 100644 --- a/.dotnet/src/Generated/VectorStoreClient.cs +++ b/.dotnet/src/Generated/VectorStoreClient.cs @@ -27,7 +27,7 @@ public virtual ClientResult CreateVectorStore(BinaryContent content, RequestOpti { Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = this.CreateCreateVectorStoreRequest(content, options); + using PipelineMessage message = CreateCreateVectorStoreRequest(content, options); return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } @@ -35,7 +35,7 @@ public virtual async Task CreateVectorStoreAsync(BinaryContent con { Argument.AssertNotNull(content, nameof(content)); - using PipelineMessage message = this.CreateCreateVectorStoreRequest(content, options); + using PipelineMessage message = CreateCreateVectorStoreRequest(content, options); return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); } } diff --git a/.dotnet/tests/Assistants/Assistants.VectorStoresTests.cs b/.dotnet/tests/Assistants/Assistants.VectorStoresTests.cs index 49c63916b..4a29debc3 100644 --- a/.dotnet/tests/Assistants/Assistants.VectorStoresTests.cs +++ b/.dotnet/tests/Assistants/Assistants.VectorStoresTests.cs @@ -142,7 +142,7 @@ public void CanEnumerateVectorStores() int lastIdSeen = int.MaxValue; int count = 0; - foreach (VectorStore vectorStore in client.GetVectorStores(new VectorStoreCollectionOptions() { Order = VectorStoreCollectionOrder.Descending })) + foreach (VectorStore vectorStore in client.GetVectorStores(new OpenAIPageOptions() { Order = OpenAIPageOrder.Descending })) { Assert.That(vectorStore.Id, Is.Not.Null); if (vectorStore.Name?.StartsWith("Test Vector Store ") == true) @@ -184,7 +184,7 @@ public async Task CanEnumerateVectorStoresAsync() int lastIdSeen = int.MaxValue; int count = 0; - await foreach (VectorStore vectorStore in client.GetVectorStoresAsync(new VectorStoreCollectionOptions() { Order = VectorStoreCollectionOrder.Descending })) + await foreach (VectorStore vectorStore in client.GetVectorStoresAsync(new OpenAIPageOptions() { Order = OpenAIPageOrder.Descending })) { Assert.That(vectorStore.Id, Is.Not.Null); if (vectorStore.Name?.StartsWith("Test Vector Store ") == true) @@ -305,7 +305,7 @@ public async Task Pagination_CanRehydrateFileAssociationCollectionAsync() // Use enumerators instead of enumerables to faciliate advancing the collections // at the same time. - AsyncCollectionResult fileAssociations = client.GetFileAssociationsAsync(vectorStore.Id, new VectorStoreFileAssociationCollectionOptions() { PageSizeLimit = 2 }); + AsyncCollectionResult fileAssociations = client.GetFileAssociationsAsync(vectorStore.Id, new OpenAIPageOptions() { PageSizeLimit = 2 }); IAsyncEnumerable pages = fileAssociations.GetRawPagesAsync(); IAsyncEnumerator pageEnumerator = pages.GetAsyncEnumerator(); await pageEnumerator.MoveNextAsync(); @@ -383,7 +383,7 @@ public void Pagination_CanRehydrateFileAssociationCollection() // Errata: removals aren't immediately reflected when requesting the list Thread.Sleep(2000); - CollectionResult fileAssociations = client.GetFileAssociations(vectorStore.Id, new VectorStoreFileAssociationCollectionOptions() { PageSizeLimit = 2 }); + CollectionResult fileAssociations = client.GetFileAssociations(vectorStore.Id, new OpenAIPageOptions() { PageSizeLimit = 2 }); IEnumerable pages = fileAssociations.GetRawPages(); IEnumerator pageEnumerator = pages.GetEnumerator(); pageEnumerator.MoveNext(); diff --git a/.dotnet/tests/Assistants/AssistantsTests.cs b/.dotnet/tests/Assistants/AssistantsTests.cs index 3ac0ad949..7e916c355 100644 --- a/.dotnet/tests/Assistants/AssistantsTests.cs +++ b/.dotnet/tests/Assistants/AssistantsTests.cs @@ -286,10 +286,10 @@ public async Task ThreadWithInitialMessagesWorks() ? await client.CreateThreadAsync(options) : client.CreateThread(options); Validate(thread); - MessageCollectionOptions collectionOptions = new MessageCollectionOptions() { Order = MessageCollectionOrder.Ascending }; + OpenAIPageOptions pageOptions = new() { Order = OpenAIPageOrder.Ascending }; List messages = IsAsync - ? await client.GetMessagesAsync(thread.Id, collectionOptions).ToListAsync() - : client.GetMessages(thread.Id, collectionOptions).ToList(); + ? await client.GetMessagesAsync(thread.Id, pageOptions).ToListAsync() + : client.GetMessages(thread.Id, pageOptions).ToList(); Assert.That(messages.Count, Is.EqualTo(2)); Assert.That(messages[0].Role, Is.EqualTo(MessageRole.User)); Assert.That(messages[0].Content?.Count, Is.EqualTo(1)); @@ -553,7 +553,7 @@ public async Task FunctionToolsWork() } Assert.That(run.Status, Is.EqualTo(RunStatus.Completed)); - List messages = client.GetMessages(run.ThreadId, new MessageCollectionOptions() { Order = MessageCollectionOrder.Descending }).ToList(); + List messages = client.GetMessages(run.ThreadId, new OpenAIPageOptions() { Order = OpenAIPageOrder.Descending }).ToList(); Assert.That(messages.Count, Is.GreaterThan(1)); Assert.That(messages[0].Role, Is.EqualTo(MessageRole.Assistant)); Assert.That(messages[0].Content?[0], Is.Not.Null); @@ -910,7 +910,7 @@ This file describes the favorite foods of several people. } while (run?.Status.IsTerminal == false); Assert.That(run.Status, Is.EqualTo(RunStatus.Completed)); - CollectionResult messages = client.GetMessages(thread.Id, new() { Order = MessageCollectionOrder.Descending }); + CollectionResult messages = client.GetMessages(thread.Id, new() { Order = OpenAIPageOrder.Descending }); int messageCount = 0; bool hasCake = false; foreach (ThreadMessage message in messages) @@ -1198,7 +1198,7 @@ public async Task Pagination_CanEnumerateAssistantsAsync() // Page through collection int count = 0; - AsyncCollectionResult assistants = client.GetAssistantsAsync(new AssistantCollectionOptions() { Order = AssistantCollectionOrder.Descending }); + AsyncCollectionResult assistants = client.GetAssistantsAsync(new OpenAIPageOptions() { Order = OpenAIPageOrder.Descending }); int lastIdSeen = int.MaxValue; @@ -1243,7 +1243,7 @@ public void Pagination_CanEnumerateAssistants() // Page through collection int count = 0; - CollectionResult assistants = client.GetAssistants(new AssistantCollectionOptions() { Order = AssistantCollectionOrder.Descending }); + CollectionResult assistants = client.GetAssistants(new OpenAIPageOptions() { Order = OpenAIPageOrder.Descending }); int lastIdSeen = int.MaxValue; @@ -1291,9 +1291,9 @@ public async Task Pagination_CanPageThroughAssistantCollectionAsync() int count = 0; int pageCount = 0; AsyncCollectionResult assistants = client.GetAssistantsAsync( - new AssistantCollectionOptions() + new OpenAIPageOptions() { - Order = AssistantCollectionOrder.Descending, + Order = OpenAIPageOrder.Descending, PageSizeLimit = TestPageSizeLimit }); @@ -1349,9 +1349,9 @@ public void Pagination_CanPageThroughAssistantCollection() int count = 0; int pageCount = 0; CollectionResult assistants = client.GetAssistants( - new AssistantCollectionOptions() + new OpenAIPageOptions() { - Order = AssistantCollectionOrder.Descending, + Order = OpenAIPageOrder.Descending, PageSizeLimit = TestPageSizeLimit }); @@ -1414,9 +1414,9 @@ public async Task Pagination_CanRehydrateAssistantPageCollectionFromBytesAsync() } AsyncCollectionResult assistants = client.GetAssistantsAsync( - new AssistantCollectionOptions() + new OpenAIPageOptions() { - Order = AssistantCollectionOrder.Descending, + Order = OpenAIPageOrder.Descending, PageSizeLimit = TestPageSizeLimit }); @@ -1482,9 +1482,9 @@ public void Pagination_CanRehydrateAssistantPageCollectionFromBytes() } CollectionResult assistants = client.GetAssistants( - new AssistantCollectionOptions() + new OpenAIPageOptions() { - Order = AssistantCollectionOrder.Descending, + Order = OpenAIPageOrder.Descending, PageSizeLimit = TestPageSizeLimit }); @@ -1554,9 +1554,9 @@ public async Task Pagination_CanRehydrateAssistantPageCollectionFromPageTokenAsy } AsyncCollectionResult assistants = client.GetAssistantsAsync( - new AssistantCollectionOptions() + new OpenAIPageOptions() { - Order = AssistantCollectionOrder.Descending, + Order = OpenAIPageOrder.Descending, PageSizeLimit = TestPageSizeLimit }); @@ -1633,9 +1633,9 @@ public void Pagination_CanRehydrateAssistantPageCollectionFromPageToken() } CollectionResult assistants = client.GetAssistants( - new AssistantCollectionOptions() + new OpenAIPageOptions() { - Order = AssistantCollectionOrder.Descending, + Order = OpenAIPageOrder.Descending, PageSizeLimit = TestPageSizeLimit }); diff --git a/.openapi3/openapi3-openai.yaml b/.openapi3/openapi3-openai.yaml index 78f510744..5cf516db3 100644 --- a/.openapi3/openapi3-openai.yaml +++ b/.openapi3/openapi3-openai.yaml @@ -31,6 +31,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 responses: '200': description: The request has succeeded. @@ -63,6 +70,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: limit in: query required: false @@ -81,10 +95,7 @@ paths: Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` for descending order. schema: - type: string - enum: - - asc - - desc + $ref: '#/components/schemas/PageOrder' default: desc explode: false - name: after @@ -134,6 +145,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: assistant_id in: path required: true @@ -166,6 +184,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: assistant_id in: path required: true @@ -204,6 +229,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: assistant_id in: path required: true @@ -1271,7 +1303,14 @@ paths: post: operationId: Realtime_startRealtimeSession summary: Starts a real-time conversation session. - parameters: [] + parameters: + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - realtime=v1 responses: '200': description: The request has succeeded. @@ -1303,6 +1342,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 responses: '200': description: The request has succeeded. @@ -1336,6 +1382,14 @@ paths: type: string enum: - application/json + - text/event-stream + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 responses: '200': description: The request has succeeded. @@ -1369,6 +1423,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: thread_id in: path required: true @@ -1401,6 +1462,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: thread_id in: path required: true @@ -1439,6 +1507,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: thread_id in: path required: true @@ -1472,6 +1547,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: thread_id in: path required: true @@ -1510,6 +1592,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: thread_id in: path required: true @@ -1534,10 +1623,7 @@ paths: Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` for descending order. schema: - type: string - enum: - - asc - - desc + $ref: '#/components/schemas/PageOrder' default: desc explode: false - name: after @@ -1587,6 +1673,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: thread_id in: path required: true @@ -1625,6 +1718,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: thread_id in: path required: true @@ -1669,6 +1769,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: thread_id in: path required: true @@ -1708,6 +1815,14 @@ paths: type: string enum: - application/json + - text/event-stream + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: thread_id in: path required: true @@ -1762,6 +1877,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: thread_id in: path required: true @@ -1786,10 +1908,7 @@ paths: Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` for descending order. schema: - type: string - enum: - - asc - - desc + $ref: '#/components/schemas/PageOrder' default: desc explode: false - name: after @@ -1839,6 +1958,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: thread_id in: path required: true @@ -1877,6 +2003,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: thread_id in: path required: true @@ -1922,6 +2055,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: thread_id in: path required: true @@ -1961,6 +2101,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: thread_id in: path required: true @@ -1991,10 +2138,7 @@ paths: Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` for descending order. schema: - type: string - enum: - - asc - - desc + $ref: '#/components/schemas/PageOrder' default: desc explode: false - name: after @@ -2060,6 +2204,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: thread_id in: path required: true @@ -2124,6 +2275,14 @@ paths: type: string enum: - application/json + - text/event-stream + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: thread_id in: path required: true @@ -2330,6 +2489,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: limit in: query required: false @@ -2348,10 +2514,7 @@ paths: Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` for descending order. schema: - type: string - enum: - - asc - - desc + $ref: '#/components/schemas/PageOrder' default: desc explode: false - name: after @@ -2400,6 +2563,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 responses: '200': description: The request has succeeded. @@ -2433,6 +2603,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: vector_store_id in: path required: true @@ -2465,6 +2642,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: vector_store_id in: path required: true @@ -2503,6 +2687,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: vector_store_id in: path required: true @@ -2536,6 +2727,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: vector_store_id in: path required: true @@ -2575,6 +2773,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: vector_store_id in: path required: true @@ -2614,6 +2819,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: vector_store_id in: path required: true @@ -2653,6 +2865,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: vector_store_id in: path required: true @@ -2683,10 +2902,7 @@ paths: Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` for descending order. schema: - type: string - enum: - - asc - - desc + $ref: '#/components/schemas/PageOrder' default: desc explode: false - name: after @@ -2743,6 +2959,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: vector_store_id in: path required: true @@ -2767,10 +2990,7 @@ paths: Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` for descending order. schema: - type: string - enum: - - asc - - desc + $ref: '#/components/schemas/PageOrder' default: desc explode: false - name: after @@ -2826,6 +3046,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: vector_store_id in: path required: true @@ -2865,6 +3092,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: vector_store_id in: path required: true @@ -2903,6 +3137,13 @@ paths: type: string enum: - application/json + - name: OpenAI-Beta + in: header + required: true + schema: + type: string + enum: + - assistants=v2 - name: vector_store_id in: path required: true @@ -4673,6 +4914,35 @@ components: - $ref: '#/components/schemas/StaticChunkingStrategyRequestParam' description: The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. x-oaiExpandable: true + CommonPageQueryParameters: + type: object + properties: + limit: + type: integer + format: int32 + description: |- + A limit on the number of objects to be returned. Limit can range between 1 and 100, and the + default is 20. + default: 20 + order: + allOf: + - $ref: '#/components/schemas/PageOrder' + description: |- + Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` + for descending order. + default: desc + after: + type: string + description: |- + A cursor for use in pagination. `after` is an object ID that defines your place in the list. + For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + subsequent call can include after=obj_foo in order to fetch the next page of the list. + before: + type: string + description: |- + A cursor for use in pagination. `before` is an object ID that defines your place in the list. + For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + subsequent call can include before=obj_foo in order to fetch the previous page of the list. CompleteUploadRequest: type: object required: @@ -9357,6 +9627,11 @@ components: allOf: - $ref: '#/components/schemas/FileChunkingStrategyResponseParam' description: This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the `chunking_strategy` concept was introduced in the API. + PageOrder: + type: string + enum: + - asc + - desc ParallelToolCalls: type: boolean description: Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use. diff --git a/.plugin/generator/src/OpenAILibraryPlugin.cs b/.plugin/generator/src/OpenAILibraryPlugin.cs index 37ea066fb..9f026e22b 100644 --- a/.plugin/generator/src/OpenAILibraryPlugin.cs +++ b/.plugin/generator/src/OpenAILibraryPlugin.cs @@ -22,6 +22,7 @@ public override void Configure() AddVisitor(new OmittedTypesVisitor()); AddVisitor(new InvariantFormatAdditionalPropertiesVisitor()); AddVisitor(new OpenAILibraryVisitor()); + AddVisitor(new VirtualMessageCreationVisitor()); } } } \ No newline at end of file diff --git a/.plugin/generator/src/Visitors/VirtualMessageCreationVisitor.cs b/.plugin/generator/src/Visitors/VirtualMessageCreationVisitor.cs new file mode 100644 index 000000000..a871a7b0b --- /dev/null +++ b/.plugin/generator/src/Visitors/VirtualMessageCreationVisitor.cs @@ -0,0 +1,41 @@ +using Microsoft.Generator.CSharp.ClientModel; +using Microsoft.Generator.CSharp.Primitives; +using Microsoft.Generator.CSharp.Providers; + +namespace OpenAILibraryPlugin.Visitors; + +/// +/// This visitor updates generated PipelineMessage creation methods to be virtual (and thus overrideable via derived clients). +/// +public class VirtualMessageCreationVisitor : ScmLibraryVisitor +{ + protected override MethodProvider Visit(MethodProvider method) + { + if (method.Signature?.ReturnType?.Name != "PipelineMessage" + || method.Signature?.Name?.StartsWith("Create") != true + || method.Signature?.Name?.EndsWith("Request") != true + || method.Signature?.Modifiers.HasFlag(MethodSignatureModifiers.Internal) != true) + { + return method; + } + + if (!method.Signature.Modifiers.HasFlag(MethodSignatureModifiers.Virtual)) + { + MethodSignature newSignature = new( + method.Signature.Name, + method.Signature.Description, + method.Signature.Modifiers | MethodSignatureModifiers.Virtual, + method.Signature.ReturnType, + method.Signature.ReturnDescription, + method.Signature.Parameters, + method.Signature.Attributes, + method.Signature.GenericArguments, + method.Signature.GenericParameterConstraints, + method.Signature.ExplicitInterface, + NonDocumentComment: "Plugin customization: make PipelineMessage creation methods virtual"); + method.Update(signature: newSignature); + } + + return method; + } +} \ No newline at end of file diff --git a/.typespec/assistants/operations.tsp b/.typespec/assistants/operations.tsp index 524fc3e8f..bad2ea458 100644 --- a/.typespec/assistants/operations.tsp +++ b/.typespec/assistants/operations.tsp @@ -16,7 +16,8 @@ interface Assistants { @tag("Assistants") @summary("Create an assistant with a model and instructions.") createAssistant( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, @body requestBody: CreateAssistantRequest, ): AssistantObject | ErrorResponse; @@ -25,33 +26,9 @@ interface Assistants { @tag("Assistants") @summary("Returns a list of assistants.") listAssistants( - @header accept: "application/json", - - /** - * A limit on the number of objects to be returned. Limit can range between 1 and 100, and the - * default is 20. - */ - @query limit?: int32 = 20, - - /** - * Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` - * for descending order. - */ - @query order?: "asc" | "desc" = "desc", - - /** - * A cursor for use in pagination. `after` is an object ID that defines your place in the list. - * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - * subsequent call can include after=obj_foo in order to fetch the next page of the list. - */ - @query after?: string, - - /** - * A cursor for use in pagination. `before` is an object ID that defines your place in the list. - * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - * subsequent call can include before=obj_foo in order to fetch the previous page of the list. - */ - @query before?: string, + ...AcceptJsonHeader, + ...AssistantsBetaHeader, + ...CommonPageQueryParameters, ): ListAssistantsResponse | ErrorResponse; @route("{assistant_id}") @@ -60,7 +37,8 @@ interface Assistants { @tag("Assistants") @summary("Retrieves an assistant.") getAssistant( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the assistant to retrieve. */ @path assistant_id: string, @@ -72,7 +50,8 @@ interface Assistants { @tag("Assistants") @summary("Modifies an assistant.") modifyAssistant( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the assistant to modify. */ @path assistant_id: string, @@ -86,7 +65,8 @@ interface Assistants { @tag("Assistants") @summary("Delete an assistant.") deleteAssistant( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the assistant to delete. */ @path assistant_id: string, diff --git a/.typespec/common/custom.tsp b/.typespec/common/custom.tsp index 3efb2cfc2..2eac3fe37 100644 --- a/.typespec/common/custom.tsp +++ b/.typespec/common/custom.tsp @@ -1,3 +1,7 @@ +import "@typespec/http"; +import "@typespec/openapi"; + +using TypeSpec.Http; using TypeSpec.OpenAPI; namespace OpenAI; @@ -6,3 +10,61 @@ namespace OpenAI; model OmniTypedResponseFormat { type: string; } + +alias AcceptJsonHeader = { + @header accept: "application/json"; +}; + +alias AcceptJsonOrEventStreamHeader = { + @header accept: "application/json" | "text/event-stream"; +}; + +alias AssistantsBetaHeader = { + @header("OpenAI-Beta") openAIBeta: "assistants=v2"; +}; + +alias PageLimitQueryParameter = { + /** + * A limit on the number of objects to be returned. Limit can range between 1 and 100, and the + * default is 20. + */ + @query limit?: int32 = 20; +}; + +union PageOrder { + asc: "asc", + desc: "desc", +} + +alias PageOrderQueryParameter = { + /** + * Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` + * for descending order. + */ + @query order?: PageOrder = PageOrder.desc; +}; + +alias PageAfterQueryParameter = { + /** + * A cursor for use in pagination. `after` is an object ID that defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include after=obj_foo in order to fetch the next page of the list. + */ + @query after?: string; +}; + +alias PageBeforeQueryParameter = { + /** + * A cursor for use in pagination. `before` is an object ID that defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include before=obj_foo in order to fetch the previous page of the list. + */ + @query before?: string; +}; + +model CommonPageQueryParameters { + ...PageLimitQueryParameter; + ...PageOrderQueryParameter; + ...PageAfterQueryParameter; + ...PageBeforeQueryParameter; +} diff --git a/.typespec/messages/operations.tsp b/.typespec/messages/operations.tsp index 159ee17c0..df4ebf365 100644 --- a/.typespec/messages/operations.tsp +++ b/.typespec/messages/operations.tsp @@ -16,7 +16,8 @@ interface Messages { @tag("Assistants") @summary("Create a message.") createMessage( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the [thread](/docs/api-reference/threads) to create a message for. */ @path thread_id: string, @@ -29,36 +30,13 @@ interface Messages { @tag("Assistants") @summary("Returns a list of messages for a given thread.") listMessages( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the [thread](/docs/api-reference/threads) the messages belong to. */ @path thread_id: string, - /** - * A limit on the number of objects to be returned. Limit can range between 1 and 100, and the - * default is 20. - */ - @query limit?: int32 = 20, - - /** - * Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` - * for descending order. - */ - @query order?: "asc" | "desc" = "desc", - - /** - * A cursor for use in pagination. `after` is an object ID that defines your place in the list. - * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - * subsequent call can include after=obj_foo in order to fetch the next page of the list. - */ - @query after?: string, - - /** - * A cursor for use in pagination. `before` is an object ID that defines your place in the list. - * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - * subsequent call can include before=obj_foo in order to fetch the previous page of the list. - */ - @query before?: string, + ...CommonPageQueryParameters, ): ListMessagesResponse | ErrorResponse; @route("{message_id}") @@ -67,7 +45,8 @@ interface Messages { @tag("Assistants") @summary("Retrieve a message.") getMessage( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the [thread](/docs/api-reference/threads) to which this message belongs. */ @path thread_id: string, @@ -82,7 +61,8 @@ interface Messages { @tag("Assistants") @summary("Modifies a message.") modifyMessage( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the thread to which this message belongs. */ @path thread_id: string, @@ -99,7 +79,8 @@ interface Messages { @tag("Assistants") @summary("Deletes a message.") deleteMessage( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the thread to which this message belongs. */ @path thread_id: string, diff --git a/.typespec/realtime/operations.tsp b/.typespec/realtime/operations.tsp index e714568b3..bd4eaa60b 100644 --- a/.typespec/realtime/operations.tsp +++ b/.typespec/realtime/operations.tsp @@ -1,3 +1,4 @@ +import "../common"; import "./models.tsp"; using TypeSpec.Http; @@ -10,6 +11,11 @@ interface Realtime { @tag("Realtime") @summary("Starts a real-time conversation session.") startRealtimeSession( + ...RealtimeBetaHeader, @body requestMessages: RealtimeClientEvent[], ): RealtimeServerEvent[]; } + +alias RealtimeBetaHeader = { + @header("OpenAI-Beta") openAIBeta: "realtime=v1"; +}; diff --git a/.typespec/runs/operations.tsp b/.typespec/runs/operations.tsp index d9f38e0b8..b29381379 100644 --- a/.typespec/runs/operations.tsp +++ b/.typespec/runs/operations.tsp @@ -17,7 +17,8 @@ interface Runs { @tag("Assistants") @summary("Create a thread and run it in one request.") createThreadAndRun( - @header accept: "application/json", + ...AcceptJsonOrEventStreamHeader, + ...AssistantsBetaHeader, @body requestBody: CreateThreadAndRunRequest, ): RunObject | ErrorResponse; @@ -27,22 +28,13 @@ interface Runs { @tag("Assistants") @summary("Create a run.") createRun( - @header accept: "application/json", + ...AcceptJsonOrEventStreamHeader, + ...AssistantsBetaHeader, /** The ID of the thread to run. */ @path thread_id: string, - /** - * A list of additional fields to include in the response. Currently the only supported value is - * `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result - * content. - * - * See the - * [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) - * for more information. - */ - @query `include[]`?: IncludedRunStepProperty[], - + ...IncludedRunStepPropertyParameter, @body requestBody: CreateRunRequest, ): RunObject | ErrorResponse; @@ -52,36 +44,13 @@ interface Runs { @tag("Assistants") @summary("Returns a list of runs belonging to a thread.") listRuns( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the thread the run belongs to. */ @path thread_id: string, - /** - * A limit on the number of objects to be returned. Limit can range between 1 and 100, and the - * default is 20. - */ - @query limit?: int32 = 20, - - /** - * Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` - * for descending order. - */ - @query order?: "asc" | "desc" = "desc", - - /** - * A cursor for use in pagination. `after` is an object ID that defines your place in the list. - * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - * subsequent call can include after=obj_foo in order to fetch the next page of the list. - */ - @query after?: string, - - /** - * A cursor for use in pagination. `before` is an object ID that defines your place in the list. - * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - * subsequent call can include before=obj_foo in order to fetch the previous page of the list. - */ - @query before?: string, + ...CommonPageQueryParameters, ): ListRunsResponse | ErrorResponse; @route("{thread_id}/runs/{run_id}") @@ -90,7 +59,8 @@ interface Runs { @tag("Assistants") @summary("Retrieves a run.") getRun( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the [thread](/docs/api-reference/threads) that was run. */ @path thread_id: string, @@ -105,7 +75,8 @@ interface Runs { @tag("Assistants") @summary("Modifies a run.") modifyRun( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the [thread](/docs/api-reference/threads) that was run. */ @path thread_id: string, @@ -122,7 +93,8 @@ interface Runs { @tag("Assistants") @summary("Cancels a run that is `in_progress`.") cancelRun( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the thread to which this run belongs. */ @path thread_id: string, @@ -141,7 +113,8 @@ interface Runs { they're all completed. All outputs must be submitted in a single request. """) submitToolOutputsToRun( - @header accept: "application/json", + ...AcceptJsonOrEventStreamHeader, + ...AssistantsBetaHeader, /** The ID of the [thread](/docs/api-reference/threads) to which this run belongs. */ @path thread_id: string, @@ -158,7 +131,8 @@ interface Runs { @tag("Assistants") @summary("Returns a list of run steps belonging to a run.") listRunSteps( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the thread the run and run steps belong to. */ @path thread_id: string, @@ -166,42 +140,8 @@ interface Runs { /** The ID of the run the run steps belong to. */ @path run_id: string, - /** - * A limit on the number of objects to be returned. Limit can range between 1 and 100, and the - * default is 20. - */ - @query limit?: int32 = 20, - - /** - * Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` - * for descending order. - */ - @query order?: "asc" | "desc" = "desc", - - /** - * A cursor for use in pagination. `after` is an object ID that defines your place in the list. - * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - * subsequent call can include after=obj_foo in order to fetch the next page of the list. - */ - @query after?: string, - - /** - * A cursor for use in pagination. `before` is an object ID that defines your place in the list. - * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - * subsequent call can include before=obj_foo in order to fetch the previous page of the list. - */ - @query before?: string, - - /** - * A list of additional fields to include in the response. Currently the only supported value is - * `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result - * content. - * - * See the - * [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) - * for more information. - */ - @query `include[]`?: IncludedRunStepProperty[], + ...CommonPageQueryParameters, + ...IncludedRunStepPropertyParameter, ): ListRunStepsResponse | ErrorResponse; @route("{thread_id}/runs/{run_id}/steps/{step_id}") @@ -210,7 +150,8 @@ interface Runs { @tag("Assistants") @summary("Retrieves a run step.") getRunStep( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the thread to which the run and run step belongs. */ @path thread_id: string, @@ -221,15 +162,19 @@ interface Runs { /** The ID of the run step to retrieve. */ @path step_id: string, - /** - * A list of additional fields to include in the response. Currently the only supported value is - * `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result - * content. - * - * See the - * [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) - * for more information. - */ - @query `include[]`?: IncludedRunStepProperty[], + ...IncludedRunStepPropertyParameter, ): RunStepObject | ErrorResponse; } + +alias IncludedRunStepPropertyParameter = { + /** + * A list of additional fields to include in the response. Currently the only supported value is + * `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result + * content. + * + * See the + * [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) + * for more information. + */ + @query `include[]`?: IncludedRunStepProperty[]; +}; diff --git a/.typespec/threads/operations.tsp b/.typespec/threads/operations.tsp index 36e8bca52..1fc8e2254 100644 --- a/.typespec/threads/operations.tsp +++ b/.typespec/threads/operations.tsp @@ -16,7 +16,8 @@ interface Threads { @tag("Assistants") @summary("Create a thread.") createThread( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, @body requestBody: CreateThreadRequest, ): ThreadObject | ErrorResponse; @@ -26,7 +27,8 @@ interface Threads { @tag("Assistants") @summary("Retrieves a thread.") getThread( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the thread to retrieve. */ @path thread_id: string, @@ -38,7 +40,8 @@ interface Threads { @tag("Assistants") @summary("Modifies a thread.") modifyThread( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the thread to modify. Only the `metadata` can be modified. */ @path thread_id: string, @@ -52,7 +55,8 @@ interface Threads { @tag("Assistants") @summary("Delete a thread.") deleteThread( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the thread to delete. */ @path thread_id: string, diff --git a/.typespec/vector-stores/operations.tsp b/.typespec/vector-stores/operations.tsp index f286e3dd2..e48a60ddd 100644 --- a/.typespec/vector-stores/operations.tsp +++ b/.typespec/vector-stores/operations.tsp @@ -17,33 +17,9 @@ interface VectorStores { @tag("Vector Stores") @summary("Returns a list of vector-stores.") listVectorStores( - @header accept: "application/json", - - /** - * A limit on the number of objects to be returned. Limit can range between 1 and 100, and the - * default is 20. - */ - @query limit?: int32 = 20, - - /** - * Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` - * for descending order. - */ - @query order?: "asc" | "desc" = "desc", - - /** - * A cursor for use in pagination. `after` is an object ID that defines your place in the list. - * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - * subsequent call can include after=obj_foo in order to fetch the next page of the list. - */ - @query after?: string, - - /** - * A cursor for use in pagination. `before` is an object ID that defines your place in the list. - * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - * subsequent call can include before=obj_foo in order to fetch the previous page of the list. - */ - @query before?: string, + ...AcceptJsonHeader, + ...AssistantsBetaHeader, + ...CommonPageQueryParameters, ): ListVectorStoresResponse | ErrorResponse; @post @@ -51,7 +27,8 @@ interface VectorStores { @tag("Vector Stores") @summary("Creates a vector store.") createVectorStore( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, @body requestBody: CreateVectorStoreRequest, ): VectorStoreObject | ErrorResponse; @@ -61,7 +38,8 @@ interface VectorStores { @tag("Vector Stores") @summary("Retrieves a vector store.") getVectorStore( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the vector store to retrieve. */ @path vector_store_id: string, @@ -73,7 +51,8 @@ interface VectorStores { @tag("Vector Stores") @summary("Modifies a vector store.") modifyVectorStore( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the vector store to modify. */ @path vector_store_id: string, @@ -87,7 +66,8 @@ interface VectorStores { @tag("Vector Stores") @summary("Delete a vector store.") deleteVectorStore( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the vector store to delete. */ @path vector_store_id: string, @@ -99,41 +79,13 @@ interface VectorStores { @tag("Vector Stores") @summary("Returns a list of vector store files.") listVectorStoreFiles( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the vector store that the files belong to. */ @path vector_store_id: string, - /** - * A limit on the number of objects to be returned. Limit can range between 1 and 100, and the - * default is 20. - */ - @query limit?: int32 = 20, - - /** - * Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` - * for descending order. - */ - @query order?: "asc" | "desc" = "desc", - - /** - * A cursor for use in pagination. `after` is an object ID that defines your place in the list. - * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - * subsequent call can include after=obj_foo in order to fetch the next page of the list. - */ - @query after?: string, - - /** - * A cursor for use in pagination. `before` is an object ID that defines your place in the list. - * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - * subsequent call can include before=obj_foo in order to fetch the previous page of the list. - */ - @query before?: string, - - /** - * Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`. - */ - @query filter?: ListVectorStoreFilesFilter, + ...VectorStoreFilesPageQueryParameters, ): ListVectorStoreFilesResponse | ErrorResponse; @route("{vector_store_id}/files") @@ -142,7 +94,8 @@ interface VectorStores { @tag("Vector Stores") @summary("Create a vector store file by attaching a [File](/docs/api-reference/files) to a [vector store](/docs/api-reference/vector-stores/object).") createVectorStoreFile( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the vector store for which to create a File. */ @path vector_store_id: string, @@ -156,7 +109,8 @@ interface VectorStores { @tag("Vector Stores") @summary("Retrieves a vector store file.") getVectorStoreFile( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the vector store that the file belongs to. */ @path vector_store_id: string, @@ -171,7 +125,8 @@ interface VectorStores { @tag("Vector Stores") @summary("Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted. To delete the file, use the [delete file](/docs/api-reference/files/delete) endpoint.") deleteVectorStoreFile( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the vector store that the file belongs to. */ @path vector_store_id: string, @@ -186,7 +141,8 @@ interface VectorStores { @tag("Vector Stores") @summary("Create a vector store file batch.") createVectorStoreFileBatch( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the vector store for which to create a file batch. */ @path vector_store_id: string, @@ -200,7 +156,8 @@ interface VectorStores { @tag("Vector Stores") @summary("Retrieves a vector store file batch.") getVectorStoreFileBatch( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the vector store that the file batch belongs to. */ @path vector_store_id: string, @@ -215,7 +172,8 @@ interface VectorStores { @tag("Vector Stores") @summary("Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible.") cancelVectorStoreFileBatch( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the vector store that the file batch belongs to. */ @path vector_store_id: string, @@ -230,7 +188,8 @@ interface VectorStores { @tag("Vector Stores") @summary("Returns a list of vector store files in a batch.") listFilesInVectorStoreBatch( - @header accept: "application/json", + ...AcceptJsonHeader, + ...AssistantsBetaHeader, /** The ID of the vector store that the file batch belongs to. */ @path vector_store_id: string, @@ -238,35 +197,18 @@ interface VectorStores { /** The ID of the file batch that the files belong to. */ @path batch_id: string, - /** - * A limit on the number of objects to be returned. Limit can range between 1 and 100, and the - * default is 20. - */ - @query limit?: int32 = 20, - - /** - * Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` - * for descending order. - */ - @query order?: "asc" | "desc" = "desc", - - /** - * A cursor for use in pagination. `after` is an object ID that defines your place in the list. - * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - * subsequent call can include after=obj_foo in order to fetch the next page of the list. - */ - @query after?: string, - - /** - * A cursor for use in pagination. `before` is an object ID that defines your place in the list. - * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - * subsequent call can include before=obj_foo in order to fetch the previous page of the list. - */ - @query before?: string, - - /** - * Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`. - */ - @query filter?: ListVectorStoreFilesFilter, + ...VectorStoreFilesPageQueryParameters, ): ListVectorStoreFilesResponse | ErrorResponse; } + +alias VectorStoreFilesPageQueryParameters = { + ...PageLimitQueryParameter; + ...PageOrderQueryParameter; + ...PageAfterQueryParameter; + ...PageBeforeQueryParameter; + + /** + * Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`. + */ + @query filter?: ListVectorStoreFilesFilter; +};