diff --git a/.dotnet.azure/.tests.staging/AoaiTestBase.cs b/.dotnet.azure/.tests.staging/AoaiTestBase.cs index 8a27b86af..c73cf63dd 100644 --- a/.dotnet.azure/.tests.staging/AoaiTestBase.cs +++ b/.dotnet.azure/.tests.staging/AoaiTestBase.cs @@ -57,7 +57,7 @@ public AoaiTestBase(bool isAsync) { } public TClient GetTestClient() { AzureOpenAIClient topLevelClient = GetTestTopLevelClient(null); - string getDeployment() => "gpt-4o"; + string getDeployment() => "gpt-4"; object clientObject = null; diff --git a/.dotnet.azure/.tests.staging/AssistantTests.cs b/.dotnet.azure/.tests.staging/AssistantTests.cs index ee441c854..115428724 100644 --- a/.dotnet.azure/.tests.staging/AssistantTests.cs +++ b/.dotnet.azure/.tests.staging/AssistantTests.cs @@ -44,7 +44,7 @@ public AssistantTests(bool isAsync) : base(isAsync) { } public async Task BasicAssistantOperationsWork() { AssistantClient client = GetTestClient(); - string modelName = "gpt-4o"; // client.DeploymentOrThrow(); + string modelName = "gpt-4"; // client.DeploymentOrThrow(); Assistant assistant = await client.CreateAssistantAsync(modelName); Validate(assistant); Assert.That(assistant.Name, Is.Null.Or.Empty); @@ -74,7 +74,7 @@ public async Task BasicAssistantOperationsWork() }, }); Assert.That(modifiedAssistant.Id, Is.EqualTo(assistant.Id)); - AsyncPageableCollection recentAssistants = client.GetAssistantsAsync(); + IAsyncEnumerable recentAssistants = client.GetAssistantsAsync().GetAllValuesAsync(); //SyncOrAsync( // client, c => c.GetAssistants(), c => c.GetAssistantsAsync()); Assistant recentAssistant = null; @@ -670,68 +670,5 @@ public async Task BasicAssistantOperationsWork() // Assert.That(content, Has.Length.GreaterThan(0)); // } - [Test] - public async Task BrowserToolWorks() - { - Uri endpoint = new("https://openai-sdk-testing-tip.openai.azure.com"); - TokenCredential credential = new DefaultAzureCredential(); - AzureOpenAIClientOptions options = new(); - options.AddPolicy(new GenericActionPipelinePolicy( - requestAction: request => - { - request.Headers.Set("X-Ms-Enable-Preview", "true"); - }), - PipelinePosition.PerCall); - AzureOpenAIClient azureClient = new(endpoint, credential, options); - AssistantClient client = azureClient.GetAssistantClient(); - - Assistant assistant = await client.CreateAssistantAsync( - "gpt-4-0125-preview", - new AssistantCreationOptions() - { - Instructions = "When asked to retrieve up-to-date information, use the browser tool.", - Tools = - { - new BingSearchToolDefinition() - { - BingResourceId = "/subscriptions/6a6fff00-4464-4eab-a6b1-0b533c7202e0/resourceGroups/rg-agent-test-westus2/providers/Microsoft.Bing/accounts/chattest-westus2-bing", - }, - }, - }); - Validate(assistant); - - ThreadCreationOptions threadOptions = new() - { - InitialMessages = - { - "What's the date and what's headline news today?" - }, - }; - - List annotationUpdates = []; - await foreach (StreamingUpdate update in client.CreateThreadAndRunStreamingAsync(assistant.Id, threadOptions)) - { - if (update is MessageContentUpdate contentUpdate) - { - Console.Write(contentUpdate.Text); - if (contentUpdate.TextAnnotation is not null) - { - annotationUpdates.Add(contentUpdate.TextAnnotation); - } - } - } - Console.WriteLine(); - - if (annotationUpdates.Count > 0) - { - Console.WriteLine("Citations:"); - for (int i = 0; i < annotationUpdates.Count; i++) - { - Console.WriteLine($"{(i + 1)}: {annotationUpdates[i].GetBingSearchTitle()}"); - Console.WriteLine($" {annotationUpdates[i].GetBingSearchUrl().AbsoluteUri}"); - } - } - } - private static readonly DateTimeOffset s_2024 = new(2024, 1, 1, 0, 0, 0, TimeSpan.Zero); } diff --git a/.dotnet.azure/src/Custom/Assistants/AzureAssistantClient.Protocol.cs b/.dotnet.azure/src/Custom/Assistants/AzureAssistantClient.Protocol.cs index 2246b4371..c21e36c6f 100644 --- a/.dotnet.azure/src/Custom/Assistants/AzureAssistantClient.Protocol.cs +++ b/.dotnet.azure/src/Custom/Assistants/AzureAssistantClient.Protocol.cs @@ -27,16 +27,16 @@ public override ClientResult CreateAssistant(BinaryContent content, RequestOptio return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } - public override async Task GetAssistantsAsync(int? limit, string order, string after, string before, RequestOptions options) + public override IAsyncEnumerable GetAssistantsAsync(int? limit, string order, string after, string before, RequestOptions options) { - using PipelineMessage message = CreateGetAssistantsRequest(limit, order, after, before, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + AzureAssistantsPageEnumerator enumerator = new(Pipeline, _endpoint, limit, order, after, before, _apiVersion, options); + return PageCollectionHelpers.CreateAsync(enumerator); } - public override ClientResult GetAssistants(int? limit, string order, string after, string before, RequestOptions options) + public override IEnumerable GetAssistants(int? limit, string order, string after, string before, RequestOptions options) { - using PipelineMessage message = CreateGetAssistantsRequest(limit, order, after, before, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + AzureAssistantsPageEnumerator enumerator = new(Pipeline, _endpoint, limit, order, after, before, _apiVersion, options); + return PageCollectionHelpers.Create(enumerator); } public override async Task GetAssistantAsync(string assistantId, RequestOptions options) @@ -108,21 +108,21 @@ public override ClientResult CreateMessage(string threadId, BinaryContent conten } /// - public override async Task GetMessagesAsync(string threadId, int? limit, string order, string after, string before, RequestOptions options) + public override IAsyncEnumerable GetMessagesAsync(string threadId, int? limit, string order, string after, string before, RequestOptions options) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - using PipelineMessage message = CreateGetMessagesRequest(threadId, limit, order, after, before, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + AzureMessagesPageEnumerator enumerator = new(Pipeline, _endpoint, threadId, limit, order, after, before, _apiVersion, options); + return PageCollectionHelpers.CreateAsync(enumerator); } /// - public override ClientResult GetMessages(string threadId, int? limit, string order, string after, string before, RequestOptions options) + public override IEnumerable GetMessages(string threadId, int? limit, string order, string after, string before, RequestOptions options) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - using PipelineMessage message = CreateGetMessagesRequest(threadId, limit, order, after, before, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + AzureMessagesPageEnumerator enumerator = new(Pipeline, _endpoint, threadId, limit, order, after, before, _apiVersion, options); + return PageCollectionHelpers.Create(enumerator); } /// @@ -260,21 +260,21 @@ public override ClientResult CreateRun(string threadId, BinaryContent content, R } /// - public override async Task GetRunsAsync(string threadId, int? limit, string order, string after, string before, RequestOptions options) + public override IAsyncEnumerable GetRunsAsync(string threadId, int? limit, string order, string after, string before, RequestOptions options) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - using PipelineMessage message = CreateGetRunsRequest(threadId, limit, order, after, before, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + AzureRunsPageEnumerator enumerator = new(Pipeline, _endpoint, threadId, limit, order, after, before, _apiVersion, options); + return PageCollectionHelpers.CreateAsync(enumerator); } /// - public override ClientResult GetRuns(string threadId, int? limit, string order, string after, string before, RequestOptions options) + public override IEnumerable GetRuns(string threadId, int? limit, string order, string after, string before, RequestOptions options) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - using PipelineMessage message = CreateGetRunsRequest(threadId, limit, order, after, before, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + AzureRunsPageEnumerator enumerator = new(Pipeline, _endpoint, threadId, limit, order, after, before, _apiVersion, options); + return PageCollectionHelpers.Create(enumerator); } /// @@ -380,23 +380,23 @@ public override ClientResult SubmitToolOutputsToRun(string threadId, string runI } /// - public override async Task GetRunStepsAsync(string threadId, string runId, int? limit, string order, string after, string before, RequestOptions options) + public override IAsyncEnumerable GetRunStepsAsync(string threadId, string runId, int? limit, string order, string after, string before, RequestOptions options) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - using PipelineMessage message = CreateGetRunStepsRequest(threadId, runId, limit, order, after, before, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + AzureRunStepsPageEnumerator enumerator = new(Pipeline, _endpoint, threadId, runId, limit, order, after, before, _apiVersion, options); + return PageCollectionHelpers.CreateAsync(enumerator); } /// - public override ClientResult GetRunSteps(string threadId, string runId, int? limit, string order, string after, string before, RequestOptions options) + public override IEnumerable GetRunSteps(string threadId, string runId, int? limit, string order, string after, string before, RequestOptions options) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - using PipelineMessage message = CreateGetRunStepsRequest(threadId, runId, limit, order, after, before, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + AzureRunStepsPageEnumerator enumerator = new(Pipeline, _endpoint, threadId, runId, limit, order, after, before, _apiVersion, options); + return PageCollectionHelpers.Create(enumerator); } /// @@ -492,9 +492,6 @@ public override ClientResult DeleteThread(string threadId, RequestOptions option private new PipelineMessage CreateCreateAssistantRequest(BinaryContent content, RequestOptions options = null) => NewJsonPostBuilder(content, options).WithPath("assistants").Build(); - private new PipelineMessage CreateGetAssistantsRequest(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) => NewJsonGetBuilder(options).WithPath("assistants", assistantId).Build(); @@ -522,9 +519,6 @@ private PipelineMessage CreateDeleteThreadRequest(string threadId, RequestOption private PipelineMessage CreateCreateMessageRequest(string threadId, BinaryContent content, RequestOptions options) => NewJsonPostBuilder(content, options).WithPath("threads", threadId, "messages").Build(); - private PipelineMessage CreateGetMessagesRequest(string threadId, int? limit, string order, string after, string before, RequestOptions options) - => NewGetListBuilder(limit, order, after, before, options).WithPath("threads", threadId, "messages").Build(); - private PipelineMessage CreateGetMessageRequest(string threadId, string messageId, RequestOptions options) => NewJsonGetBuilder(options).WithPath("threads", threadId, "messages", messageId).Build(); @@ -540,9 +534,6 @@ private PipelineMessage CreateCreateThreadAndRunRequest(BinaryContent content, R private PipelineMessage CreateCreateRunRequest(string threadId, BinaryContent content, RequestOptions options) => NewJsonPostBuilder(content, options).WithPath("threads", threadId, "runs").Build(); - private PipelineMessage CreateGetRunsRequest(string threadId, int? limit, string order, string after, string before, RequestOptions options) - => NewGetListBuilder(limit, order, after, before, options).WithPath("threads", threadId, "runs").Build(); - private PipelineMessage CreateGetRunRequest(string threadId, string runId, RequestOptions options) => NewJsonGetBuilder(options).WithPath("threads", threadId, "runs", runId).Build(); @@ -555,16 +546,14 @@ private PipelineMessage CreateCancelRunRequest(string threadId, string runId, Re private PipelineMessage CreateSubmitToolOutputsToRunRequest(string threadId, string runId, BinaryContent content, RequestOptions options) => NewJsonPostBuilder(content, options).WithPath("threads", threadId, "runs", runId, "submit_tool_outputs").Build(); - private PipelineMessage CreateGetRunStepsRequest(string threadId, string runId, int? limit, string order, string after, string before, RequestOptions options) - => NewGetListBuilder(limit, order, after, before, options).WithPath("threads", threadId, "runs", runId, "steps").Build(); - private PipelineMessage CreateGetRunStepRequest(string threadId, string runId, string stepId, RequestOptions options) => NewJsonGetBuilder(options).WithPath("threads", threadId, "runs", runId, "steps", stepId).Build(); private AzureOpenAIPipelineMessageBuilder NewBuilder(RequestOptions options) => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) - .WithHeader(s_OpenAIBetaFeatureHeader, s_OpenAIBetaAssistantsV2HeaderValue) + .WithAssistantsHeader() .WithOptions(options); + private AzureOpenAIPipelineMessageBuilder NewJsonPostBuilder(BinaryContent content, RequestOptions options) => NewBuilder(options) .WithMethod("POST") @@ -583,11 +572,5 @@ private AzureOpenAIPipelineMessageBuilder NewJsonDeleteBuilder(RequestOptions op private AzureOpenAIPipelineMessageBuilder NewGetListBuilder(int? limit, string order, string after, string before, RequestOptions options) => NewJsonGetBuilder(options) - .WithOptionalQueryParameter("limit", limit) - .WithOptionalQueryParameter("order", order) - .WithOptionalQueryParameter("after", after) - .WithOptionalQueryParameter("before", before); - - private static readonly string s_OpenAIBetaFeatureHeader = "OpenAI-Beta"; - private static readonly string s_OpenAIBetaAssistantsV2HeaderValue = "assistants=v2"; + .WithCommonListParameters(limit, order, after, before); } diff --git a/.dotnet.azure/src/Custom/Assistants/AzureRunStepToolCall.cs b/.dotnet.azure/src/Custom/Assistants/AzureRunStepToolCall.cs deleted file mode 100644 index fd4e57eab..000000000 --- a/.dotnet.azure/src/Custom/Assistants/AzureRunStepToolCall.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; - -namespace Azure.AI.OpenAI; - -public static partial class RunStepToolCallExtensions -{ - /// - /// Gets a value indicating whether this instance represents a call to a browser tool. - /// - /// The tool call to check the type of. - /// True if the tool call represents a browser tool call, false otherwise. - [Experimental("AOAI001")] - public static bool IsBingSearchKind(this RunStepToolCall runStepToolCall) - { - return runStepToolCall.Type == "browser"; - } -} diff --git a/.dotnet.azure/src/Custom/Assistants/AzureTextAnnotation.cs b/.dotnet.azure/src/Custom/Assistants/AzureTextAnnotation.cs deleted file mode 100644 index a55ce1d81..000000000 --- a/.dotnet.azure/src/Custom/Assistants/AzureTextAnnotation.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System.ClientModel.Primitives; -using System.Diagnostics.CodeAnalysis; -using Azure.AI.OpenAI.Assistants; -using Azure.AI.OpenAI.Internal; - -#pragma warning disable AZC0112 - -namespace Azure.AI.OpenAI.Assistants; - -public static class TextAnnotationExtensions -{ - /// - /// Gets a value indicating whether the text annotation represents one provided by an Azure OpenAI Bing Search - /// browser tool. - /// - /// The annotation being evaluated. - /// True if the annotation has a browser tool url_citation, false otherwise. - [Experimental("AOAI001")] - public static bool IsBingSearchAnnotation(this TextAnnotation baseAnnotation) - { - return GetInternalUrlCitationFrom(baseAnnotation) != null; - } - - /// - /// If applicable, gets the page title from an Azure OpenAI Bing Search browser tool's text content - /// annotation. - /// - /// The annotation being evaluated. - /// If present, the title from a browser tool annotation; null otherwise. - [Experimental("AOAI001")] - public static string GetBingSearchTitle(this TextAnnotation baseAnnotation) - { - return GetInternalUrlCitationFrom(baseAnnotation)?.Title; - } - - /// - /// If applicable, gets the page URL from an Azure OpenAI Bing Search browser tool's text content - /// annotation. - /// - /// The annotation being evaluated. - /// If present, the url from a browser tool annotation; null otherwise. - [Experimental("AOAI001")] - public static Uri GetBingSearchUrl(this TextAnnotation baseAnnotation) - { - return GetInternalUrlCitationFrom(baseAnnotation)?.Url; - } - - private static InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation - GetInternalUrlCitationFrom(TextAnnotation baseAnnotation) - { - return baseAnnotation?._internalAnnotation? - .SerializedAdditionalRawData?.TryGetValue("url_citation", out BinaryData citationData) == true - ? ModelReaderWriter.Read(citationData) - : null; - } -} diff --git a/.dotnet.azure/src/Custom/Assistants/AzureTextAnnotationUpdate.cs b/.dotnet.azure/src/Custom/Assistants/AzureTextAnnotationUpdate.cs deleted file mode 100644 index 25a95f0ca..000000000 --- a/.dotnet.azure/src/Custom/Assistants/AzureTextAnnotationUpdate.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System.ClientModel.Primitives; -using System.Diagnostics.CodeAnalysis; -using Azure.AI.OpenAI.Assistants; -using Azure.AI.OpenAI.Internal; - -#pragma warning disable AZC0112 - -namespace Azure.AI.OpenAI.Assistants; - -public static partial class TextAnnotationUpdateExtensions -{ - /// - /// Gets a value indicating whether the text annotation represents one provided by an Azure OpenAI Bing Search - /// browser tool. - /// - /// The annotation being evaluated. - /// True if the annotation has a browser tool url_citation, false otherwise. - [Experimental("AOAI001")] - public static bool IsBingSearchAnnotation(this TextAnnotationUpdate baseAnnotation) - { - return GetInternalUrlCitationFrom(baseAnnotation) != null; - } - - /// - /// If applicable, gets the page title from an Azure OpenAI Bing Search browser tool's text content - /// annotation. - /// - /// The annotation being evaluated. - /// If present, the title from a browser tool annotation; null otherwise. - [Experimental("AOAI001")] - public static string GetBingSearchTitle(this TextAnnotationUpdate baseAnnotation) - { - return GetInternalUrlCitationFrom(baseAnnotation)?.Title; - } - - /// - /// If applicable, gets the page URL from an Azure OpenAI Bing Search browser tool's text content - /// annotation. - /// - /// The annotation being evaluated. - /// If present, the url from a browser tool annotation; null otherwise. - [Experimental("AOAI001")] - public static Uri GetBingSearchUrl(this TextAnnotationUpdate baseAnnotation) - { - return GetInternalUrlCitationFrom(baseAnnotation)?.Url; - } - - private static InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation - GetInternalUrlCitationFrom(TextAnnotationUpdate baseAnnotation) - { - return baseAnnotation?._internalAnnotation? - .SerializedAdditionalRawData?.TryGetValue("url_citation", out BinaryData citationData) == true - ? ModelReaderWriter.Read(citationData) - : null; - } -} diff --git a/.dotnet.azure/src/Custom/Assistants/BingSearchToolDefinition.Serialization.cs b/.dotnet.azure/src/Custom/Assistants/BingSearchToolDefinition.Serialization.cs deleted file mode 100644 index a9c67dae5..000000000 --- a/.dotnet.azure/src/Custom/Assistants/BingSearchToolDefinition.Serialization.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using OpenAI.Assistants; - -namespace Azure.AI.OpenAI.Assistants; - -[CodeGenSuppress("global::System.ClientModel.Primitives.IJsonModel.Write", typeof(Utf8JsonWriter), typeof(ModelReaderWriterOptions))] -public partial class BingSearchToolDefinition : IJsonModel -{ - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - => CustomSerializationHelpers.SerializeInstance(this, SerializeBingSearchToolDefinition, writer, options); - - internal static void SerializeBingSearchToolDefinition(BingSearchToolDefinition instance, Utf8JsonWriter writer, ModelReaderWriterOptions options) - => instance.WriteCore(writer, options); - - protected override void WriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - writer.WritePropertyName("browser"u8); - writer.WriteObjectValue(_internalBrowser, options); - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - writer.WriteSerializedAdditionalRawData(SerializedAdditionalRawData, options); - writer.WriteEndObject(); - } -} \ No newline at end of file diff --git a/.dotnet.azure/src/Custom/Assistants/BingSearchToolDefinition.cs b/.dotnet.azure/src/Custom/Assistants/BingSearchToolDefinition.cs deleted file mode 100644 index 3880ec0c6..000000000 --- a/.dotnet.azure/src/Custom/Assistants/BingSearchToolDefinition.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using Azure.AI.OpenAI.Assistants; -using OpenAI.Assistants; - -namespace Azure.AI.OpenAI.Assistants; - -/// The BingSearchToolDefinition. -[CodeGenModel("BingSearchToolDefinition")] -[Experimental("AOAI001")] -public partial class BingSearchToolDefinition : ToolDefinition -{ - public required string BingResourceId - { - get => _internalBrowser.BingResourceId; - set => _internalBrowser.BingResourceId = value; - } - - /// Initializes a new instance of . - public BingSearchToolDefinition() - : base("browser") - { - _internalBrowser = new(); - } - - [SetsRequiredMembers] - public BingSearchToolDefinition(string bingResourceId) - : this() - { - _internalBrowser.BingResourceId = bingResourceId; - } - - /// Initializes a new instance of . - /// Discriminator. - /// Keeps track of any properties unknown to the library. - /// Overrides for the file search tool. - [SetsRequiredMembers] - internal BingSearchToolDefinition(string type, IDictionary serializedAdditionalRawData, InternalBingSearchToolDefinitionBrowser browser) : base(type, serializedAdditionalRawData) - { - _internalBrowser = browser; - } - - /// Overrides for the file search tool. - [CodeGenMember("Browser")] - internal InternalBingSearchToolDefinitionBrowser _internalBrowser { get; set; } -} diff --git a/.dotnet.azure/src/Custom/Assistants/Internal/Pagination/AzureAssistantsPageEnumerator.cs b/.dotnet.azure/src/Custom/Assistants/Internal/Pagination/AzureAssistantsPageEnumerator.cs new file mode 100644 index 000000000..d406c67da --- /dev/null +++ b/.dotnet.azure/src/Custom/Assistants/Internal/Pagination/AzureAssistantsPageEnumerator.cs @@ -0,0 +1,46 @@ +using System.ClientModel; +using System.ClientModel.Primitives; + +#nullable enable + +namespace Azure.AI.OpenAI.Assistants; + +internal partial class AzureAssistantsPageEnumerator : AssistantsPageEnumerator +{ + private readonly Uri _endpoint; + private readonly string _apiVersion; + + public AzureAssistantsPageEnumerator( + ClientPipeline pipeline, + Uri endpoint, + int? limit, string order, string after, string before, + string apiVersion, + RequestOptions options) + : base(pipeline, endpoint, limit, order, after, before, options) + { + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + internal override async Task GetAssistantsAsync(int? limit, string order, string after, string before, RequestOptions options) + { + using PipelineMessage message = CreateGetAssistantsRequest(limit, order, after, before, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + internal override ClientResult GetAssistants(int? limit, string order, string after, string before, RequestOptions options) + { + using PipelineMessage message = CreateGetAssistantsRequest(limit, order, after, before, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + private new PipelineMessage CreateGetAssistantsRequest(int? limit, string order, string after, string before, RequestOptions options) + => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) + .WithAssistantsHeader() + .WithOptions(options) + .WithMethod("GET") + .WithAccept("application/json") + .WithCommonListParameters(limit, order, after, before) + .WithPath("assistants") + .Build(); +} diff --git a/.dotnet.azure/src/Custom/Assistants/Internal/Pagination/AzureMessagesPageEnumerator.cs b/.dotnet.azure/src/Custom/Assistants/Internal/Pagination/AzureMessagesPageEnumerator.cs new file mode 100644 index 000000000..6f2150dbb --- /dev/null +++ b/.dotnet.azure/src/Custom/Assistants/Internal/Pagination/AzureMessagesPageEnumerator.cs @@ -0,0 +1,51 @@ +using System.ClientModel; +using System.ClientModel.Primitives; + +#nullable enable + +namespace Azure.AI.OpenAI.Assistants; + +internal partial class AzureMessagesPageEnumerator : MessagesPageEnumerator +{ + private readonly Uri _endpoint; + private readonly string _apiVersion; + + public AzureMessagesPageEnumerator( + ClientPipeline pipeline, + Uri endpoint, + string threadId, + int? limit, string order, string after, string before, + string apiVersion, + RequestOptions options) + : base(pipeline, endpoint, threadId, limit, order, after, before, options) + { + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + internal override async Task GetMessagesAsync(string threadId, int? limit, string order, string after, string before, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + using PipelineMessage message = CreateGetMessagesRequest(threadId, limit, order, after, before, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + internal override ClientResult GetMessages(string threadId, int? limit, string order, string after, string before, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + using PipelineMessage message = CreateGetMessagesRequest(threadId, limit, order, after, before, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + private PipelineMessage CreateGetMessagesRequest(string threadId, int? limit, string order, string after, string before, RequestOptions options) + => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) + .WithAssistantsHeader() + .WithOptions(options) + .WithMethod("GET") + .WithAccept("application/json") + .WithCommonListParameters(limit, order, after, before) + .WithPath("threads", threadId, "messages") + .Build(); +} diff --git a/.dotnet.azure/src/Custom/Assistants/Internal/Pagination/AzureRunStepsPageEnumerator.cs b/.dotnet.azure/src/Custom/Assistants/Internal/Pagination/AzureRunStepsPageEnumerator.cs new file mode 100644 index 000000000..633aa3d6e --- /dev/null +++ b/.dotnet.azure/src/Custom/Assistants/Internal/Pagination/AzureRunStepsPageEnumerator.cs @@ -0,0 +1,53 @@ +using System.ClientModel; +using System.ClientModel.Primitives; + +#nullable enable + +namespace Azure.AI.OpenAI.Assistants; + +internal partial class AzureRunStepsPageEnumerator : RunStepsPageEnumerator +{ + private readonly Uri _endpoint; + private readonly string _apiVersion; + + public AzureRunStepsPageEnumerator( + ClientPipeline pipeline, + Uri endpoint, + string threadId, string runId, + int? limit, string? order, string? after, string? before, + string apiVersion, + RequestOptions options) + : base(pipeline, endpoint, threadId, runId, limit, order, after, before, options) + { + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + internal override async Task GetRunStepsAsync(string threadId, string runId, int? limit, string? order, string? after, string? before, RequestOptions? options) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using PipelineMessage message = CreateGetRunStepsRequest(threadId, runId, limit, order, after, before, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + internal override ClientResult GetRunSteps(string threadId, string runId, int? limit, string? order, string? after, string? before, RequestOptions? options) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using PipelineMessage message = CreateGetRunStepsRequest(threadId, runId, limit, order, after, before, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + private PipelineMessage CreateGetRunStepsRequest(string threadId, string runId, int? limit, string order, string after, string before, RequestOptions options) + => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) + .WithAssistantsHeader() + .WithOptions(options) + .WithMethod("GET") + .WithAccept("application/json") + .WithCommonListParameters(limit, order, after, before) + .WithPath("threads", threadId, "runs", runId, "steps") + .Build(); +} diff --git a/.dotnet.azure/src/Custom/Assistants/Internal/Pagination/AzureRunsPageEnumerator.cs b/.dotnet.azure/src/Custom/Assistants/Internal/Pagination/AzureRunsPageEnumerator.cs new file mode 100644 index 000000000..2a180d2f9 --- /dev/null +++ b/.dotnet.azure/src/Custom/Assistants/Internal/Pagination/AzureRunsPageEnumerator.cs @@ -0,0 +1,51 @@ +using System.ClientModel; +using System.ClientModel.Primitives; + +#nullable enable + +namespace Azure.AI.OpenAI.Assistants; + +internal partial class AzureRunsPageEnumerator : RunsPageEnumerator +{ + private readonly Uri _endpoint; + private readonly string _apiVersion; + + public AzureRunsPageEnumerator( + ClientPipeline pipeline, + Uri endpoint, + string threadId, int? limit, string order, string after, string before, + string apiVersion, + RequestOptions options) + : base(pipeline, endpoint, threadId, limit, order, after, before, options) + { + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + + internal override async Task GetRunsAsync(string threadId, int? limit, string order, string after, string before, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + using PipelineMessage message = CreateGetRunsRequest(threadId, limit, order, after, before, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + internal override ClientResult GetRuns(string threadId, int? limit, string order, string after, string before, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + + using PipelineMessage message = CreateGetRunsRequest(threadId, limit, order, after, before, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + private PipelineMessage CreateGetRunsRequest(string threadId, int? limit, string order, string after, string before, RequestOptions options) + => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) + .WithAssistantsHeader() + .WithOptions(options) + .WithMethod("GET") + .WithAccept("application/json") + .WithCommonListParameters(limit, order, after, before) + .WithPath("threads", threadId, "runs") + .Build(); +} diff --git a/.dotnet.azure/src/Custom/Chat/AzureChatClient.cs b/.dotnet.azure/src/Custom/Chat/AzureChatClient.cs index 784e9bf0e..89949a52d 100644 --- a/.dotnet.azure/src/Custom/Chat/AzureChatClient.cs +++ b/.dotnet.azure/src/Custom/Chat/AzureChatClient.cs @@ -38,7 +38,7 @@ protected AzureChatClient() { } /// - public override AsyncResultCollection CompleteChatStreamingAsync(IEnumerable messages, ChatCompletionOptions options = null, CancellationToken cancellationToken = default) + public override AsyncCollectionResult CompleteChatStreamingAsync(IEnumerable messages, ChatCompletionOptions options = null, CancellationToken cancellationToken = default) { options ??= new(); options.StreamOptions = null; @@ -46,7 +46,7 @@ public override AsyncResultCollection CompleteCha } /// - public override ResultCollection CompleteChatStreaming(IEnumerable messages, ChatCompletionOptions options = null, CancellationToken cancellationToken = default) + public override CollectionResult CompleteChatStreaming(IEnumerable messages, ChatCompletionOptions options = null, CancellationToken cancellationToken = default) { options ??= new(); options.StreamOptions = null; diff --git a/.dotnet.azure/src/Custom/Common/PageableResultHelpers.cs b/.dotnet.azure/src/Custom/Common/PageableResultHelpers.cs deleted file mode 100644 index c3112acda..000000000 --- a/.dotnet.azure/src/Custom/Common/PageableResultHelpers.cs +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System.ClientModel; - -#nullable enable - -namespace Azure.AI.OpenAI; - -internal class PageableResultHelpers -{ - public static PageableCollection Create(Func> firstPageFunc, Func>? nextPageFunc, int? pageSize = default) where T : notnull - { - ResultPage first(string? _, int? pageSizeHint) => firstPageFunc(pageSizeHint); - return new FuncPageable(first, nextPageFunc, pageSize); - } - - public static AsyncPageableCollection Create(Func>> firstPageFunc, Func>>? nextPageFunc, int? pageSize = default) where T : notnull - { - Task> first(string? _, int? pageSizeHint) => firstPageFunc(pageSizeHint); - return new FuncAsyncPageable(first, nextPageFunc, pageSize); - } - - private class FuncAsyncPageable : AsyncPageableCollection where T : notnull - { - private readonly Func>> _firstPageFunc; - private readonly Func>>? _nextPageFunc; - private readonly int? _defaultPageSize; - - public FuncAsyncPageable(Func>> firstPageFunc, Func>>? nextPageFunc, int? defaultPageSize = default) - { - _firstPageFunc = firstPageFunc; - _nextPageFunc = nextPageFunc; - _defaultPageSize = defaultPageSize; - } - - public override async IAsyncEnumerable> AsPages(string? continuationToken = default, int? pageSizeHint = default) - { - Func>>? pageFunc = string.IsNullOrEmpty(continuationToken) ? _firstPageFunc : _nextPageFunc; - - if (pageFunc == null) - { - yield break; - } - - int? pageSize = pageSizeHint ?? _defaultPageSize; - do - { - ResultPage page = await pageFunc(continuationToken, pageSize).ConfigureAwait(false); - SetRawResponse(page.GetRawResponse()); - yield return page; - continuationToken = page.ContinuationToken; - pageFunc = _nextPageFunc; - } - while (!string.IsNullOrEmpty(continuationToken) && pageFunc != null); - } - } - - private class FuncPageable : PageableCollection where T : notnull - { - private readonly Func> _firstPageFunc; - private readonly Func>? _nextPageFunc; - private readonly int? _defaultPageSize; - - public FuncPageable(Func> firstPageFunc, Func>? nextPageFunc, int? defaultPageSize = default) - { - _firstPageFunc = firstPageFunc; - _nextPageFunc = nextPageFunc; - _defaultPageSize = defaultPageSize; - } - - public override IEnumerable> AsPages(string? continuationToken = default, int? pageSizeHint = default) - { - Func>? pageFunc = string.IsNullOrEmpty(continuationToken) ? _firstPageFunc : _nextPageFunc; - - if (pageFunc == null) - { - yield break; - } - - int? pageSize = pageSizeHint ?? _defaultPageSize; - do - { - ResultPage page = pageFunc(continuationToken, pageSize); - SetRawResponse(page.GetRawResponse()); - yield return page; - continuationToken = page.ContinuationToken; - pageFunc = _nextPageFunc; - } - while (!string.IsNullOrEmpty(continuationToken) && pageFunc != null); - } - } -} diff --git a/.dotnet.azure/src/Custom/VectorStores/AzureVectorStoreClient.Protocol.cs b/.dotnet.azure/src/Custom/VectorStores/AzureVectorStoreClient.Protocol.cs index f76eba089..b14c3b56e 100644 --- a/.dotnet.azure/src/Custom/VectorStores/AzureVectorStoreClient.Protocol.cs +++ b/.dotnet.azure/src/Custom/VectorStores/AzureVectorStoreClient.Protocol.cs @@ -9,16 +9,16 @@ namespace Azure.AI.OpenAI.VectorStores; internal partial class AzureVectorStoreClient : VectorStoreClient { - public override async Task GetVectorStoresAsync(int? limit, string order, string after, string before, RequestOptions options) + public override IAsyncEnumerable GetVectorStoresAsync(int? limit, string order, string after, string before, RequestOptions options) { - using PipelineMessage message = CreateGetVectorStoresRequest(limit, order, after, before, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + AzureVectorStoresPageEnumerator enumerator = new(Pipeline, _endpoint, limit, order, after, before, _apiVersion, options); + return PageCollectionHelpers.CreateAsync(enumerator); } - public override ClientResult GetVectorStores(int? limit, string order, string after, string before, RequestOptions options) + public override IEnumerable GetVectorStores(int? limit, string order, string after, string before, RequestOptions options) { - using PipelineMessage message = CreateGetVectorStoresRequest(limit, order, after, before, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + AzureVectorStoresPageEnumerator enumerator = new(Pipeline, _endpoint, limit, order, after, before, _apiVersion,options); + return PageCollectionHelpers.Create(enumerator); } public override async Task CreateVectorStoreAsync(BinaryContent content, RequestOptions options = null) @@ -83,18 +83,20 @@ public override ClientResult DeleteVectorStore(string vectorStoreId, RequestOpti return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } - public override async Task GetFileAssociationsAsync(string vectorStoreId, int? limit, string order, string after, string before, string filter, RequestOptions options) + public override IAsyncEnumerable GetFileAssociationsAsync(string vectorStoreId, int? limit, string order, string after, string before, string filter, RequestOptions options) { - using PipelineMessage message = CreateGetVectorStoreFilesRequest(vectorStoreId, limit, order, after, before, filter, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + + AzureVectorStoreFilesPageEnumerator enumerator = new(Pipeline, _endpoint, vectorStoreId, limit, order, after, before, filter, _apiVersion, options); + return PageCollectionHelpers.CreateAsync(enumerator); } - public override ClientResult GetFileAssociations(string vectorStoreId, int? limit, string order, string after, string before, string filter, RequestOptions options) + public override IEnumerable GetFileAssociations(string vectorStoreId, int? limit, string order, string after, string before, string filter, RequestOptions options) { Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - using PipelineMessage message = CreateGetVectorStoreFilesRequest(vectorStoreId, limit, order, after, before, filter, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + AzureVectorStoreFilesPageEnumerator enumerator = new(Pipeline, _endpoint, vectorStoreId, limit, order, after, before, filter, _apiVersion, options); + return PageCollectionHelpers.Create(enumerator); } public override async Task AddFileToVectorStoreAsync(string vectorStoreId, BinaryContent content, RequestOptions options = null) @@ -205,36 +207,24 @@ public override ClientResult CancelBatchFileJob(string vectorStoreId, string bat return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); } - public override async Task GetFileAssociationsAsync(string vectorStoreId, string batchId, int? limit, string order, string after, string before, string filter, RequestOptions options) + public override IAsyncEnumerable GetFileAssociationsAsync(string vectorStoreId, string batchId, int? limit, string order, string after, string before, string filter, RequestOptions options) { Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); - using PipelineMessage message = CreateGetFilesInVectorStoreBatchesRequest(vectorStoreId, batchId, limit, order, after, before, filter, options); - return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + AzureVectorStoreFileBatchesPageEnumerator enumerator = new(Pipeline, _endpoint, vectorStoreId, batchId, limit, order, after, before, filter, _apiVersion, options); + return PageCollectionHelpers.CreateAsync(enumerator); } - public override ClientResult GetFileAssociations(string vectorStoreId, string batchId, int? limit, string order, string after, string before, string filter, RequestOptions options) + public override IEnumerable GetFileAssociations(string vectorStoreId, string batchId, int? limit, string order, string after, string before, string filter, RequestOptions options) { Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); - using PipelineMessage message = CreateGetFilesInVectorStoreBatchesRequest(vectorStoreId, batchId, limit, order, after, before, filter, options); - return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + AzureVectorStoreFileBatchesPageEnumerator enumerator = new(Pipeline, _endpoint, vectorStoreId, batchId, limit, order, after, before, filter, _apiVersion, options); + return PageCollectionHelpers.Create(enumerator); } - private new PipelineMessage CreateGetVectorStoresRequest(int? limit, string order, string after, string before, RequestOptions options) - => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) - .WithMethod("GET") - .WithPath("vector_stores") - .WithOptionalQueryParameter("limit", limit) - .WithOptionalQueryParameter("order", order) - .WithOptionalQueryParameter("after", after) - .WithOptionalQueryParameter("before", before) - .WithAccept("application/json") - .WithOptions(options) - .Build(); - private new PipelineMessage CreateCreateVectorStoreRequest(BinaryContent content, RequestOptions options) => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) .WithMethod("POST") @@ -269,19 +259,6 @@ public override ClientResult GetFileAssociations(string vectorStoreId, string ba .WithOptions(options) .Build(); - private new PipelineMessage CreateGetVectorStoreFilesRequest(string vectorStoreId, int? limit, string order, string after, string before, string filter, RequestOptions options) - => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) - .WithMethod("GET") - .WithPath("vector_stores", vectorStoreId, "files") - .WithOptionalQueryParameter("limit", limit) - .WithOptionalQueryParameter("order", order) - .WithOptionalQueryParameter("after", after) - .WithOptionalQueryParameter("before", before) - .WithOptionalQueryParameter("filter", filter) - .WithAccept("application/json") - .WithOptions(options) - .Build(); - private new PipelineMessage CreateCreateVectorStoreFileRequest(string vectorStoreId, BinaryContent content, RequestOptions options) => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) .WithMethod("POST") @@ -331,17 +308,4 @@ public override ClientResult GetFileAssociations(string vectorStoreId, string ba .WithAccept("application/json") .WithOptions(options) .Build(); - - private new PipelineMessage CreateGetFilesInVectorStoreBatchesRequest(string vectorStoreId, string batchId, int? limit, string order, string after, string before, string filter, RequestOptions options) - => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) - .WithMethod("GET") - .WithPath("vector_stores", vectorStoreId, "file_batches", batchId, "files") - .WithOptionalQueryParameter("limit", limit) - .WithOptionalQueryParameter("order", order) - .WithOptionalQueryParameter("after", after) - .WithOptionalQueryParameter("before", before) - .WithOptionalQueryParameter("filter", filter) - .WithAccept("application/json") - .WithOptions(options) - .Build(); } diff --git a/.dotnet.azure/src/Custom/VectorStores/Internal/Pagination/AzureVectorStoreFileBatchesPageEnumerator.cs b/.dotnet.azure/src/Custom/VectorStores/Internal/Pagination/AzureVectorStoreFileBatchesPageEnumerator.cs new file mode 100644 index 000000000..d2505c8ab --- /dev/null +++ b/.dotnet.azure/src/Custom/VectorStores/Internal/Pagination/AzureVectorStoreFileBatchesPageEnumerator.cs @@ -0,0 +1,53 @@ +using System.ClientModel; +using System.ClientModel.Primitives; + +#nullable enable + +namespace Azure.AI.OpenAI.VectorStores; + +internal partial class AzureVectorStoreFileBatchesPageEnumerator : VectorStoreFileBatchesPageEnumerator +{ + private readonly Uri _endpoint; + private readonly string _apiVersion; + + public AzureVectorStoreFileBatchesPageEnumerator( + ClientPipeline pipeline, + Uri endpoint, + string vectorStoreId, string batchId, int? limit, string? order, string? after, string? before, string? filter, + string apiVersion, + RequestOptions options) + : base(pipeline, endpoint, vectorStoreId, batchId, limit, order, after, before, filter, options) + { + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + internal override async Task GetFileAssociationsAsync(string vectorStoreId, string batchId, int? limit, string? order, string? after, string? before, string? filter, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); + + using PipelineMessage message = CreateGetFilesInVectorStoreBatchesRequest(vectorStoreId, batchId, limit, order, after, before, filter, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + internal override ClientResult GetFileAssociations(string vectorStoreId, string batchId, int? limit, string? order, string? after, string? before, string? filter, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); + + using PipelineMessage message = CreateGetFilesInVectorStoreBatchesRequest(vectorStoreId, batchId, limit, order, after, before, filter, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + private new PipelineMessage CreateGetFilesInVectorStoreBatchesRequest(string vectorStoreId, string batchId, int? limit, string order, string after, string before, string filter, RequestOptions options) + => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) + .WithAssistantsHeader() + .WithOptions(options) + .WithMethod("GET") + .WithAccept("application/json") + .WithCommonListParameters(limit, order, after, before) + .WithOptionalQueryParameter("filter", filter) + .WithPath("vector_stores", vectorStoreId, "file_batches", batchId, "files") + .Build(); +} diff --git a/.dotnet.azure/src/Custom/VectorStores/Internal/Pagination/AzureVectorStoreFilesPageEnumerator.cs b/.dotnet.azure/src/Custom/VectorStores/Internal/Pagination/AzureVectorStoreFilesPageEnumerator.cs new file mode 100644 index 000000000..208ae233d --- /dev/null +++ b/.dotnet.azure/src/Custom/VectorStores/Internal/Pagination/AzureVectorStoreFilesPageEnumerator.cs @@ -0,0 +1,52 @@ +using System.ClientModel; +using System.ClientModel.Primitives; + +#nullable enable + +namespace Azure.AI.OpenAI.VectorStores; + +internal partial class AzureVectorStoreFilesPageEnumerator : VectorStoreFilesPageEnumerator +{ + private readonly Uri _endpoint; + private readonly string _apiVersion; + + public AzureVectorStoreFilesPageEnumerator( + ClientPipeline pipeline, + Uri endpoint, + string vectorStoreId, + int? limit, string? order, string? after, string? before, string? filter, + string apiVersion, + RequestOptions options) + : base(pipeline, endpoint, vectorStoreId, limit, order, after, before, filter, options) + { + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + internal override async Task GetFileAssociationsAsync(string vectorStoreId, int? limit, string? order, string? after, string? before, string? filter, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + + using PipelineMessage message = CreateGetVectorStoreFilesRequest(vectorStoreId, limit, order, after, before, filter, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + internal override ClientResult GetFileAssociations(string vectorStoreId, int? limit, string? order, string? after, string? before, string? filter, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + + using PipelineMessage message = CreateGetVectorStoreFilesRequest(vectorStoreId, limit, order, after, before, filter, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + private new PipelineMessage CreateGetVectorStoreFilesRequest(string vectorStoreId, int? limit, string order, string after, string before, string filter, RequestOptions options) + => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) + .WithAssistantsHeader() + .WithOptions(options) + .WithMethod("GET") + .WithAccept("application/json") + .WithCommonListParameters(limit, order, after, before) + .WithOptionalQueryParameter("filter", filter) + .WithPath("vector_stores", vectorStoreId, "files") + .Build(); +} diff --git a/.dotnet.azure/src/Custom/VectorStores/Internal/Pagination/AzureVectorStoresPageEnumerator.cs b/.dotnet.azure/src/Custom/VectorStores/Internal/Pagination/AzureVectorStoresPageEnumerator.cs new file mode 100644 index 000000000..23390e837 --- /dev/null +++ b/.dotnet.azure/src/Custom/VectorStores/Internal/Pagination/AzureVectorStoresPageEnumerator.cs @@ -0,0 +1,46 @@ +using System.ClientModel; +using System.ClientModel.Primitives; + +#nullable enable + +namespace Azure.AI.OpenAI.VectorStores; + +internal partial class AzureVectorStoresPageEnumerator : VectorStoresPageEnumerator +{ + private readonly Uri _endpoint; + private readonly string _apiVersion; + + public AzureVectorStoresPageEnumerator( + ClientPipeline pipeline, + Uri endpoint, + int? limit, string order, string after, string before, + string apiVersion, + RequestOptions options) + : base(pipeline, endpoint, limit, order, after, before, options) + { + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + internal override async Task GetVectorStoresAsync(int? limit, string order, string after, string before, RequestOptions options) + { + using PipelineMessage message = CreateGetVectorStoresRequest(limit, order, after, before, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + internal override ClientResult GetVectorStores(int? limit, string order, string after, string before, RequestOptions options) + { + using PipelineMessage message = CreateGetVectorStoresRequest(limit, order, after, before, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + private new PipelineMessage CreateGetVectorStoresRequest(int? limit, string order, string after, string before, RequestOptions options) + => new AzureOpenAIPipelineMessageBuilder(Pipeline, _endpoint, _apiVersion) + .WithAssistantsHeader() + .WithOptions(options) + .WithMethod("GET") + .WithAccept("application/json") + .WithCommonListParameters(limit, order, after, before) + .WithPath("vector_stores") + .Build(); +} diff --git a/.dotnet.azure/src/Generated/BingSearchToolDefinition.Serialization.cs b/.dotnet.azure/src/Generated/BingSearchToolDefinition.Serialization.cs deleted file mode 100644 index 6129a9b9f..000000000 --- a/.dotnet.azure/src/Generated/BingSearchToolDefinition.Serialization.cs +++ /dev/null @@ -1,110 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; - -namespace Azure.AI.OpenAI.Assistants -{ - public partial class BingSearchToolDefinition : IJsonModel - { - BingSearchToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(BingSearchToolDefinition)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeBingSearchToolDefinition(document.RootElement, options); - } - - internal static BingSearchToolDefinition DeserializeBingSearchToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalBingSearchToolDefinitionBrowser browser = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("browser"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - browser = InternalBingSearchToolDefinitionBrowser.DeserializeInternalBingSearchToolDefinitionBrowser(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new BingSearchToolDefinition(type, serializedAdditionalRawData, browser); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(BingSearchToolDefinition)} does not support writing '{options.Format}' format."); - } - } - - BingSearchToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeBingSearchToolDefinition(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(BingSearchToolDefinition)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static new BingSearchToolDefinition FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializeBingSearchToolDefinition(document.RootElement); - } - - /// Convert into a . - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/.dotnet.azure/src/Generated/InternalBingSearchToolDefinitionBrowser.Serialization.cs b/.dotnet.azure/src/Generated/InternalBingSearchToolDefinitionBrowser.Serialization.cs deleted file mode 100644 index e144a6e01..000000000 --- a/.dotnet.azure/src/Generated/InternalBingSearchToolDefinitionBrowser.Serialization.cs +++ /dev/null @@ -1,137 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; - -namespace Azure.AI.OpenAI.Assistants -{ - internal partial class InternalBingSearchToolDefinitionBrowser : IJsonModel - { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalBingSearchToolDefinitionBrowser)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("bing_resource_id") != true) - { - writer.WritePropertyName("bing_resource_id"u8); - writer.WriteStringValue(BingResourceId); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - InternalBingSearchToolDefinitionBrowser IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalBingSearchToolDefinitionBrowser)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalBingSearchToolDefinitionBrowser(document.RootElement, options); - } - - internal static InternalBingSearchToolDefinitionBrowser DeserializeInternalBingSearchToolDefinitionBrowser(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string bingResourceId = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("bing_resource_id"u8)) - { - bingResourceId = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalBingSearchToolDefinitionBrowser(bingResourceId, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalBingSearchToolDefinitionBrowser)} does not support writing '{options.Format}' format."); - } - } - - InternalBingSearchToolDefinitionBrowser IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalBingSearchToolDefinitionBrowser(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalBingSearchToolDefinitionBrowser)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static InternalBingSearchToolDefinitionBrowser FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalBingSearchToolDefinitionBrowser(document.RootElement); - } - - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } - } -} - diff --git a/.dotnet.azure/src/Generated/InternalBingSearchToolDefinitionBrowser.cs b/.dotnet.azure/src/Generated/InternalBingSearchToolDefinitionBrowser.cs deleted file mode 100644 index a188551c5..000000000 --- a/.dotnet.azure/src/Generated/InternalBingSearchToolDefinitionBrowser.cs +++ /dev/null @@ -1,72 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Assistants -{ - /// The BingSearchToolDefinitionBrowser. - internal partial class InternalBingSearchToolDefinitionBrowser - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - /// The resource ID of the Bing Search resource to use. - /// is null. - internal InternalBingSearchToolDefinitionBrowser(string bingResourceId) - { - Argument.AssertNotNull(bingResourceId, nameof(bingResourceId)); - - BingResourceId = bingResourceId; - } - - /// Initializes a new instance of . - /// The resource ID of the Bing Search resource to use. - /// Keeps track of any properties unknown to the library. - internal InternalBingSearchToolDefinitionBrowser(string bingResourceId, IDictionary serializedAdditionalRawData) - { - BingResourceId = bingResourceId; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalBingSearchToolDefinitionBrowser() - { - } - - /// The resource ID of the Bing Search resource to use. - internal string BingResourceId { get; set; } - } -} - diff --git a/.dotnet.azure/src/Generated/InternalMessageContentTextAnnotationsBingSearchUrlCitation.Serialization.cs b/.dotnet.azure/src/Generated/InternalMessageContentTextAnnotationsBingSearchUrlCitation.Serialization.cs deleted file mode 100644 index c89a7d916..000000000 --- a/.dotnet.azure/src/Generated/InternalMessageContentTextAnnotationsBingSearchUrlCitation.Serialization.cs +++ /dev/null @@ -1,187 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; - -namespace Azure.AI.OpenAI.Assistants -{ - internal partial class InternalMessageContentTextAnnotationsBingSearchUrlCitation : IJsonModel - { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsBingSearchUrlCitation)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("text") != true) - { - writer.WritePropertyName("text"u8); - writer.WriteStringValue(Text); - } - if (SerializedAdditionalRawData?.ContainsKey("url_citation") != true) - { - writer.WritePropertyName("url_citation"u8); - writer.WriteObjectValue(UrlCitation, options); - } - if (SerializedAdditionalRawData?.ContainsKey("start_index") != true) - { - writer.WritePropertyName("start_index"u8); - writer.WriteNumberValue(StartIndex); - } - if (SerializedAdditionalRawData?.ContainsKey("end_index") != true) - { - writer.WritePropertyName("end_index"u8); - writer.WriteNumberValue(EndIndex); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - InternalMessageContentTextAnnotationsBingSearchUrlCitation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsBingSearchUrlCitation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageContentTextAnnotationsBingSearchUrlCitation(document.RootElement, options); - } - - internal static InternalMessageContentTextAnnotationsBingSearchUrlCitation DeserializeInternalMessageContentTextAnnotationsBingSearchUrlCitation(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string text = default; - InternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation urlCitation = default; - int startIndex = default; - int endIndex = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("text"u8)) - { - text = property.Value.GetString(); - continue; - } - if (property.NameEquals("url_citation"u8)) - { - urlCitation = InternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation.DeserializeInternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation(property.Value, options); - continue; - } - if (property.NameEquals("start_index"u8)) - { - startIndex = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("end_index"u8)) - { - endIndex = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageContentTextAnnotationsBingSearchUrlCitation( - type, - serializedAdditionalRawData, - text, - urlCitation, - startIndex, - endIndex); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsBingSearchUrlCitation)} does not support writing '{options.Format}' format."); - } - } - - InternalMessageContentTextAnnotationsBingSearchUrlCitation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageContentTextAnnotationsBingSearchUrlCitation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsBingSearchUrlCitation)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static new InternalMessageContentTextAnnotationsBingSearchUrlCitation FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageContentTextAnnotationsBingSearchUrlCitation(document.RootElement); - } - - /// Convert into a . - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } - } -} - diff --git a/.dotnet.azure/src/Generated/InternalMessageContentTextAnnotationsBingSearchUrlCitation.cs b/.dotnet.azure/src/Generated/InternalMessageContentTextAnnotationsBingSearchUrlCitation.cs deleted file mode 100644 index b4d73e02e..000000000 --- a/.dotnet.azure/src/Generated/InternalMessageContentTextAnnotationsBingSearchUrlCitation.cs +++ /dev/null @@ -1,61 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Assistants -{ - /// The MessageContentTextAnnotationsBingSearchUrlCitation. - internal partial class InternalMessageContentTextAnnotationsBingSearchUrlCitation : MessageContentTextObjectAnnotation - { - /// Initializes a new instance of . - /// The text in the message content that needs to be replaced. - /// - /// - /// - /// or is null. - internal InternalMessageContentTextAnnotationsBingSearchUrlCitation(string text, InternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation urlCitation, int startIndex, int endIndex) - { - Argument.AssertNotNull(text, nameof(text)); - Argument.AssertNotNull(urlCitation, nameof(urlCitation)); - - Type = "url_citation"; - Text = text; - UrlCitation = urlCitation; - StartIndex = startIndex; - EndIndex = endIndex; - } - - /// Initializes a new instance of . - /// The discriminated type identifier for the content item. - /// Keeps track of any properties unknown to the library. - /// The text in the message content that needs to be replaced. - /// - /// - /// - internal InternalMessageContentTextAnnotationsBingSearchUrlCitation(string type, IDictionary serializedAdditionalRawData, string text, InternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation urlCitation, int startIndex, int endIndex) : base(type, serializedAdditionalRawData) - { - Text = text; - UrlCitation = urlCitation; - StartIndex = startIndex; - EndIndex = endIndex; - } - - /// Initializes a new instance of for deserialization. - internal InternalMessageContentTextAnnotationsBingSearchUrlCitation() - { - } - - /// The text in the message content that needs to be replaced. - internal string Text { get; set; } - /// Gets the url citation. - internal InternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation UrlCitation { get; set; } - /// Gets the start index. - internal int StartIndex { get; set; } - /// Gets the end index. - internal int EndIndex { get; set; } - } -} - diff --git a/.dotnet.azure/src/Generated/InternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation.Serialization.cs b/.dotnet.azure/src/Generated/InternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation.Serialization.cs deleted file mode 100644 index 2ad756485..000000000 --- a/.dotnet.azure/src/Generated/InternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation.Serialization.cs +++ /dev/null @@ -1,148 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; - -namespace Azure.AI.OpenAI.Assistants -{ - internal partial class InternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation : IJsonModel - { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("url") != true) - { - writer.WritePropertyName("url"u8); - writer.WriteStringValue(Url.AbsoluteUri); - } - if (SerializedAdditionalRawData?.ContainsKey("title") != true) - { - writer.WritePropertyName("title"u8); - writer.WriteStringValue(Title); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - InternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation(document.RootElement, options); - } - - internal static InternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation DeserializeInternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - Uri url = default; - string title = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("url"u8)) - { - url = new Uri(property.Value.GetString()); - continue; - } - if (property.NameEquals("title"u8)) - { - title = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation(url, title, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation)} does not support writing '{options.Format}' format."); - } - } - - InternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static InternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation(document.RootElement); - } - - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } - } -} - diff --git a/.dotnet.azure/src/Generated/InternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation.cs b/.dotnet.azure/src/Generated/InternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation.cs deleted file mode 100644 index 6fdef7453..000000000 --- a/.dotnet.azure/src/Generated/InternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation.cs +++ /dev/null @@ -1,79 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Assistants -{ - /// The MessageContentTextAnnotationsBingSearchUrlCitationUrlCitation. - internal partial class InternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - /// - /// - /// or is null. - internal InternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation(Uri url, string title) - { - Argument.AssertNotNull(url, nameof(url)); - Argument.AssertNotNull(title, nameof(title)); - - Url = url; - Title = title; - } - - /// Initializes a new instance of . - /// - /// - /// Keeps track of any properties unknown to the library. - internal InternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation(Uri url, string title, IDictionary serializedAdditionalRawData) - { - Url = url; - Title = title; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalMessageContentTextAnnotationsBingSearchUrlCitationUrlCitation() - { - } - - /// Gets the url. - internal Uri Url { get; set; } - /// Gets the title. - internal string Title { get; set; } - } -} - diff --git a/.dotnet.azure/src/Generated/InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitation.Serialization.cs b/.dotnet.azure/src/Generated/InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitation.Serialization.cs deleted file mode 100644 index acc46a267..000000000 --- a/.dotnet.azure/src/Generated/InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitation.Serialization.cs +++ /dev/null @@ -1,211 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; - -namespace Azure.AI.OpenAI.Assistants -{ - internal partial class InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitation : IJsonModel - { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitation)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("index") != true) - { - writer.WritePropertyName("index"u8); - writer.WriteNumberValue(Index); - } - if (SerializedAdditionalRawData?.ContainsKey("text") != true && Optional.IsDefined(Text)) - { - writer.WritePropertyName("text"u8); - writer.WriteStringValue(Text); - } - if (SerializedAdditionalRawData?.ContainsKey("url_citation") != true && Optional.IsDefined(UrlCitation)) - { - writer.WritePropertyName("url_citation"u8); - writer.WriteObjectValue(UrlCitation, options); - } - if (SerializedAdditionalRawData?.ContainsKey("start_index") != true && Optional.IsDefined(StartIndex)) - { - writer.WritePropertyName("start_index"u8); - writer.WriteNumberValue(StartIndex.Value); - } - if (SerializedAdditionalRawData?.ContainsKey("end_index") != true && Optional.IsDefined(EndIndex)) - { - writer.WritePropertyName("end_index"u8); - writer.WriteNumberValue(EndIndex.Value); - } - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageDeltaContentTextAnnotationsBingSearchUrlCitation(document.RootElement, options); - } - - internal static InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitation DeserializeInternalMessageDeltaContentTextAnnotationsBingSearchUrlCitation(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - int index = default; - string text = default; - InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation urlCitation = default; - int? startIndex = default; - int? endIndex = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("index"u8)) - { - index = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("text"u8)) - { - text = property.Value.GetString(); - continue; - } - if (property.NameEquals("url_citation"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - urlCitation = InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation.DeserializeInternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation(property.Value, options); - continue; - } - if (property.NameEquals("start_index"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - startIndex = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("end_index"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - endIndex = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitation( - type, - serializedAdditionalRawData, - index, - text, - urlCitation, - startIndex, - endIndex); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitation)} does not support writing '{options.Format}' format."); - } - } - - InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageDeltaContentTextAnnotationsBingSearchUrlCitation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitation)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static new InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitation FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageDeltaContentTextAnnotationsBingSearchUrlCitation(document.RootElement); - } - - /// Convert into a . - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } - } -} - diff --git a/.dotnet.azure/src/Generated/InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitation.cs b/.dotnet.azure/src/Generated/InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitation.cs deleted file mode 100644 index 3e64d7074..000000000 --- a/.dotnet.azure/src/Generated/InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitation.cs +++ /dev/null @@ -1,55 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Assistants -{ - /// The MessageDeltaContentTextAnnotationsBingSearchUrlCitation. - internal partial class InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitation : MessageDeltaTextContentAnnotation - { - /// Initializes a new instance of . - /// The index of the annotation in the text content part. - internal InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitation(int index) - { - Type = "url_citation"; - Index = index; - } - - /// Initializes a new instance of . - /// The discriminated type identifier for the content item. - /// Keeps track of any properties unknown to the library. - /// The index of the annotation in the text content part. - /// The text in the message content that needs to be replaced. - /// - /// - /// - internal InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitation(string type, IDictionary serializedAdditionalRawData, int index, string text, InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation urlCitation, int? startIndex, int? endIndex) : base(type, serializedAdditionalRawData) - { - Index = index; - Text = text; - UrlCitation = urlCitation; - StartIndex = startIndex; - EndIndex = endIndex; - } - - /// Initializes a new instance of for deserialization. - internal InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitation() - { - } - - /// The index of the annotation in the text content part. - internal int Index { get; set; } - /// The text in the message content that needs to be replaced. - internal string Text { get; set; } - /// Gets the url citation. - internal InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation UrlCitation { get; set; } - /// Gets the start index. - internal int? StartIndex { get; set; } - /// Gets the end index. - internal int? EndIndex { get; set; } - } -} - diff --git a/.dotnet.azure/src/Generated/InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation.Serialization.cs b/.dotnet.azure/src/Generated/InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation.Serialization.cs deleted file mode 100644 index 6a57103e5..000000000 --- a/.dotnet.azure/src/Generated/InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation.Serialization.cs +++ /dev/null @@ -1,152 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; - -namespace Azure.AI.OpenAI.Assistants -{ - internal partial class InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation : IJsonModel - { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (SerializedAdditionalRawData?.ContainsKey("url") != true && Optional.IsDefined(Url)) - { - writer.WritePropertyName("url"u8); - writer.WriteStringValue(Url.AbsoluteUri); - } - if (SerializedAdditionalRawData?.ContainsKey("title") != true && Optional.IsDefined(Title)) - { - writer.WritePropertyName("title"u8); - writer.WriteStringValue(Title); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation(document.RootElement, options); - } - - internal static InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation DeserializeInternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - Uri url = default; - string title = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("url"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - url = new Uri(property.Value.GetString()); - continue; - } - if (property.NameEquals("title"u8)) - { - title = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation(url, title, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation)} does not support writing '{options.Format}' format."); - } - } - - InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation(document.RootElement); - } - - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } - } -} - diff --git a/.dotnet.azure/src/Generated/InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation.cs b/.dotnet.azure/src/Generated/InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation.cs deleted file mode 100644 index 2866427d9..000000000 --- a/.dotnet.azure/src/Generated/InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation.cs +++ /dev/null @@ -1,66 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Assistants -{ - /// The MessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation. - internal partial class InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - internal InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation() - { - } - - /// Initializes a new instance of . - /// - /// - /// Keeps track of any properties unknown to the library. - internal InternalMessageDeltaContentTextAnnotationsBingSearchUrlCitationUrlCitation(Uri url, string title, IDictionary serializedAdditionalRawData) - { - Url = url; - Title = title; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Gets the url. - internal Uri Url { get; set; } - /// Gets the title. - internal string Title { get; set; } - } -} - diff --git a/.dotnet.azure/src/Utility/AzureOpenAIPipelineMessageBuilder.cs b/.dotnet.azure/src/Utility/AzureOpenAIPipelineMessageBuilder.cs index 58d160566..07d5d3711 100644 --- a/.dotnet.azure/src/Utility/AzureOpenAIPipelineMessageBuilder.cs +++ b/.dotnet.azure/src/Utility/AzureOpenAIPipelineMessageBuilder.cs @@ -57,6 +57,12 @@ public AzureOpenAIPipelineMessageBuilder WithOptionalQueryParameter(string na where T : struct, IConvertible => WithOptionalQueryParameter(name, value.HasValue ? Convert.ChangeType(value.Value, typeof(string)).ToString() : null); + public AzureOpenAIPipelineMessageBuilder WithCommonListParameters(int? limit, string order, string after, string before) + => WithOptionalQueryParameter("limit", limit) + .WithOptionalQueryParameter("order", order) + .WithOptionalQueryParameter("after", after) + .WithOptionalQueryParameter("before", before); + public AzureOpenAIPipelineMessageBuilder WithMethod(string requestMethod) { _method = requestMethod; @@ -76,6 +82,12 @@ public AzureOpenAIPipelineMessageBuilder WithHeader(string name, string value) return this; } + public AzureOpenAIPipelineMessageBuilder WithAssistantsHeader() + { + _headers[s_OpenAIBetaFeatureHeader] = s_OpenAIBetaAssistantsV2HeaderValue; + return this; + } + public AzureOpenAIPipelineMessageBuilder WithAccept(string acceptHeaderValue) => WithHeader("Accept", acceptHeaderValue); @@ -149,4 +161,7 @@ private void SetUri(PipelineRequest request) request.Uri = uriBuilder.ToUri(); } + + private static readonly string s_OpenAIBetaFeatureHeader = "OpenAI-Beta"; + private static readonly string s_OpenAIBetaAssistantsV2HeaderValue = "assistants=v2"; } diff --git a/.dotnet/src/Custom/Assistants/AssistantClient.Protocol.cs b/.dotnet/src/Custom/Assistants/AssistantClient.Protocol.cs index d96ee9617..dace80d8f 100644 --- a/.dotnet/src/Custom/Assistants/AssistantClient.Protocol.cs +++ b/.dotnet/src/Custom/Assistants/AssistantClient.Protocol.cs @@ -70,7 +70,7 @@ public virtual ClientResult CreateAssistant(BinaryContent content, RequestOption [EditorBrowsable(EditorBrowsableState.Never)] public virtual IAsyncEnumerable GetAssistantsAsync(int? limit, string order, string after, string before, RequestOptions options) { - AssistantsPageEnumerator enumerator = new AssistantsPageEnumerator(_pipeline, _endpoint, limit, order, after, before, options); + AssistantsPageEnumerator enumerator = new(_pipeline, _endpoint, limit, order, after, before, options); return PageCollectionHelpers.CreateAsync(enumerator); } @@ -101,7 +101,7 @@ public virtual IAsyncEnumerable GetAssistantsAsync(int? limit, str [EditorBrowsable(EditorBrowsableState.Never)] public virtual IEnumerable GetAssistants(int? limit, string order, string after, string before, RequestOptions options) { - AssistantsPageEnumerator enumerator = new AssistantsPageEnumerator(_pipeline, _endpoint, limit, order, after, before, options); + AssistantsPageEnumerator enumerator = new(_pipeline, _endpoint, limit, order, after, before, options); return PageCollectionHelpers.Create(enumerator); } @@ -259,7 +259,7 @@ public virtual IAsyncEnumerable GetMessagesAsync(string threadId, { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - MessagesPageEnumerator enumerator = new MessagesPageEnumerator(_pipeline, _endpoint, threadId, limit, order, after, before, options); + MessagesPageEnumerator enumerator = new(_pipeline, _endpoint, threadId, limit, order, after, before, options); return PageCollectionHelpers.CreateAsync(enumerator); } @@ -295,7 +295,7 @@ public virtual IEnumerable GetMessages(string threadId, int? limit { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - MessagesPageEnumerator enumerator = new MessagesPageEnumerator(_pipeline, _endpoint, threadId, limit, order, after, before, options); + MessagesPageEnumerator enumerator = new(_pipeline, _endpoint, threadId, limit, order, after, before, options); return PageCollectionHelpers.Create(enumerator); } @@ -381,7 +381,7 @@ public virtual IAsyncEnumerable GetRunsAsync(string threadId, int? { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - RunsPageEnumerator enumerator = new RunsPageEnumerator(_pipeline, _endpoint, threadId, limit, order, after, before, options); + RunsPageEnumerator enumerator = new(_pipeline, _endpoint, threadId, limit, order, after, before, options); return PageCollectionHelpers.CreateAsync(enumerator); } @@ -417,7 +417,7 @@ public virtual IEnumerable GetRuns(string threadId, int? limit, st { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - RunsPageEnumerator enumerator = new RunsPageEnumerator(_pipeline, _endpoint, threadId, limit, order, after, before, options); + RunsPageEnumerator enumerator = new(_pipeline, _endpoint, threadId, limit, order, after, before, options); return PageCollectionHelpers.Create(enumerator); } @@ -495,7 +495,7 @@ public virtual IAsyncEnumerable GetRunStepsAsync(string threadId, Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - RunStepsPageEnumerator enumerator = new RunStepsPageEnumerator(_pipeline, _endpoint, threadId, runId, limit, order, after, before, options); + RunStepsPageEnumerator enumerator = new(_pipeline, _endpoint, threadId, runId, limit, order, after, before, options); return PageCollectionHelpers.CreateAsync(enumerator); } @@ -533,7 +533,7 @@ public virtual IEnumerable GetRunSteps(string threadId, string run Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - RunStepsPageEnumerator enumerator = new RunStepsPageEnumerator(_pipeline, _endpoint, threadId, runId, limit, order, after, before, options); + RunStepsPageEnumerator enumerator = new(_pipeline, _endpoint, threadId, runId, limit, order, after, before, options); return PageCollectionHelpers.Create(enumerator); } diff --git a/.dotnet/src/Custom/Assistants/AssistantClient.cs b/.dotnet/src/Custom/Assistants/AssistantClient.cs index 611ef7edd..3ca8be2f8 100644 --- a/.dotnet/src/Custom/Assistants/AssistantClient.cs +++ b/.dotnet/src/Custom/Assistants/AssistantClient.cs @@ -118,14 +118,8 @@ public virtual AsyncPageCollection GetAssistantsAsync( AssistantCollectionOptions options = default, CancellationToken cancellationToken = default) { - AssistantsPageEnumerator enumerator = new(_pipeline, _endpoint, - options?.PageSize, - options?.Order?.ToString(), - options?.AfterId, - options?.BeforeId, - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.CreateAsync(enumerator); + return GetAssistantsAsync(options?.PageSize, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, cancellationToken.ToRequestOptions()) + as AsyncPageCollection; } /// @@ -144,14 +138,8 @@ public virtual AsyncPageCollection GetAssistantsAsync( Argument.AssertNotNull(firstPageToken, nameof(firstPageToken)); AssistantsPageToken pageToken = AssistantsPageToken.FromToken(firstPageToken); - AssistantsPageEnumerator enumerator = new(_pipeline, _endpoint, - pageToken.Limit, - pageToken.Order, - pageToken.After, - pageToken.Before, - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.CreateAsync(enumerator); + return GetAssistantsAsync(pageToken?.Limit, pageToken?.Order, pageToken?.After, pageToken.Before, cancellationToken.ToRequestOptions()) + as AsyncPageCollection; } /// @@ -167,14 +155,8 @@ public virtual PageCollection GetAssistants( AssistantCollectionOptions options = default, CancellationToken cancellationToken = default) { - AssistantsPageEnumerator enumerator = new(_pipeline, _endpoint, - options?.PageSize, - options?.Order?.ToString(), - options?.AfterId, - options?.BeforeId, - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.Create(enumerator); + return GetAssistants(options?.PageSize, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, cancellationToken.ToRequestOptions()) + as PageCollection; } /// @@ -193,14 +175,8 @@ public virtual PageCollection GetAssistants( Argument.AssertNotNull(firstPageToken, nameof(firstPageToken)); AssistantsPageToken pageToken = AssistantsPageToken.FromToken(firstPageToken); - AssistantsPageEnumerator enumerator = new(_pipeline, _endpoint, - pageToken.Limit, - pageToken.Order, - pageToken.After, - pageToken.Before, - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.Create(enumerator); + return GetAssistants(pageToken?.Limit, pageToken?.Order, pageToken?.After, pageToken.Before, cancellationToken.ToRequestOptions()) + as PageCollection; } /// @@ -486,15 +462,8 @@ public virtual AsyncPageCollection GetMessagesAsync( { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - MessagesPageEnumerator enumerator = new(_pipeline, _endpoint, - threadId, - options?.PageSize, - options?.Order?.ToString(), - options?.AfterId, - options?.BeforeId, - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.CreateAsync(enumerator); + return GetMessagesAsync(threadId, options?.PageSize, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, cancellationToken.ToRequestOptions()) + as AsyncPageCollection; } /// @@ -513,15 +482,8 @@ public virtual AsyncPageCollection GetMessagesAsync( Argument.AssertNotNull(firstPageToken, nameof(firstPageToken)); MessagesPageToken pageToken = MessagesPageToken.FromToken(firstPageToken); - MessagesPageEnumerator enumerator = new(_pipeline, _endpoint, - pageToken.ThreadId, - pageToken.Limit, - pageToken.Order, - pageToken.After, - pageToken.Before, - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.CreateAsync(enumerator); + return GetMessagesAsync(pageToken?.ThreadId, pageToken?.Limit, pageToken?.Order, pageToken?.After, pageToken?.Before, cancellationToken.ToRequestOptions()) + as AsyncPageCollection; } /// @@ -541,15 +503,8 @@ public virtual PageCollection GetMessages( { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - MessagesPageEnumerator enumerator = new(_pipeline, _endpoint, - threadId, - options?.PageSize, - options?.Order?.ToString(), - options?.AfterId, - options?.BeforeId, - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.Create(enumerator); + return GetMessages(threadId, options?.PageSize, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, cancellationToken.ToRequestOptions()) + as PageCollection; } /// @@ -568,15 +523,9 @@ public virtual PageCollection GetMessages( Argument.AssertNotNull(firstPageToken, nameof(firstPageToken)); MessagesPageToken pageToken = MessagesPageToken.FromToken(firstPageToken); - MessagesPageEnumerator enumerator = new(_pipeline, _endpoint, - pageToken.ThreadId, - pageToken.Limit, - pageToken.Order, - pageToken.After, - pageToken.Before, - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.Create(enumerator); + return GetMessages(pageToken?.ThreadId, pageToken?.Limit, pageToken?.Order, pageToken?.After, pageToken?.Before, cancellationToken.ToRequestOptions()) + as PageCollection; + } /// @@ -888,15 +837,8 @@ public virtual AsyncPageCollection GetRunsAsync( { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - RunsPageEnumerator enumerator = new(_pipeline, _endpoint, - threadId, - options?.PageSize, - options?.Order?.ToString(), - options?.AfterId, - options?.BeforeId, - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.CreateAsync(enumerator); + return GetRunsAsync(threadId, options?.PageSize, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, cancellationToken.ToRequestOptions()) + as AsyncPageCollection; } /// @@ -915,15 +857,8 @@ public virtual AsyncPageCollection GetRunsAsync( Argument.AssertNotNull(firstPageToken, nameof(firstPageToken)); RunsPageToken pageToken = RunsPageToken.FromToken(firstPageToken); - RunsPageEnumerator enumerator = new(_pipeline, _endpoint, - pageToken.ThreadId, - pageToken.Limit, - pageToken.Order, - pageToken.After, - pageToken.Before, - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.CreateAsync(enumerator); + return GetRunsAsync(pageToken?.ThreadId, pageToken?.Limit, pageToken?.Order, pageToken?.After, pageToken?.Before, cancellationToken.ToRequestOptions()) + as AsyncPageCollection; } /// @@ -943,15 +878,8 @@ public virtual PageCollection GetRuns( { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - RunsPageEnumerator enumerator = new(_pipeline, _endpoint, - threadId, - options?.PageSize, - options?.Order?.ToString(), - options?.AfterId, - options?.BeforeId, - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.Create(enumerator); + return GetRuns(threadId, options?.PageSize, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, cancellationToken.ToRequestOptions()) + as PageCollection; } /// @@ -970,15 +898,8 @@ public virtual PageCollection GetRuns( Argument.AssertNotNull(firstPageToken, nameof(firstPageToken)); RunsPageToken pageToken = RunsPageToken.FromToken(firstPageToken); - RunsPageEnumerator enumerator = new(_pipeline, _endpoint, - pageToken.ThreadId, - pageToken.Limit, - pageToken.Order, - pageToken.After, - pageToken.Before, - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.Create(enumerator); + return GetRuns(pageToken?.ThreadId, pageToken?.Limit, pageToken?.Order, pageToken?.After, pageToken?.Before, cancellationToken.ToRequestOptions()) + as PageCollection; } /// @@ -1168,16 +1089,8 @@ public virtual AsyncPageCollection GetRunStepsAsync( Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - RunStepsPageEnumerator enumerator = new(_pipeline, _endpoint, - threadId, - runId, - options?.PageSize, - options?.Order?.ToString(), - options?.AfterId, - options?.BeforeId, - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.CreateAsync(enumerator); + return GetRunStepsAsync(threadId, runId, options?.PageSize, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, cancellationToken.ToRequestOptions()) + as AsyncPageCollection; } /// @@ -1196,16 +1109,8 @@ public virtual AsyncPageCollection GetRunStepsAsync( Argument.AssertNotNull(firstPageToken, nameof(firstPageToken)); RunStepsPageToken pageToken = RunStepsPageToken.FromToken(firstPageToken); - RunStepsPageEnumerator enumerator = new(_pipeline, _endpoint, - pageToken.ThreadId, - pageToken.RunId, - pageToken.Limit, - pageToken.Order, - pageToken.After, - pageToken.Before, - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.CreateAsync(enumerator); + return GetRunStepsAsync(pageToken?.ThreadId, pageToken?.RunId, pageToken?.Limit, pageToken?.Order, pageToken?.After, pageToken?.Before, cancellationToken.ToRequestOptions()) + as AsyncPageCollection; } /// @@ -1228,16 +1133,8 @@ public virtual PageCollection GetRunSteps( Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - RunStepsPageEnumerator enumerator = new(_pipeline, _endpoint, - threadId, - runId, - options?.PageSize, - options?.Order?.ToString(), - options?.AfterId, - options?.BeforeId, - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.Create(enumerator); + return GetRunSteps(threadId, runId, options?.PageSize, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, cancellationToken.ToRequestOptions()) + as PageCollection; } /// @@ -1256,16 +1153,8 @@ public virtual PageCollection GetRunSteps( Argument.AssertNotNull(firstPageToken, nameof(firstPageToken)); RunStepsPageToken pageToken = RunStepsPageToken.FromToken(firstPageToken); - RunStepsPageEnumerator enumerator = new(_pipeline, _endpoint, - pageToken.ThreadId, - pageToken.RunId, - pageToken.Limit, - pageToken.Order, - pageToken.After, - pageToken.Before, - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.Create(enumerator); + return GetRunSteps(pageToken?.ThreadId, pageToken?.RunId, pageToken?.Limit, pageToken?.Order, pageToken?.After, pageToken?.Before, cancellationToken.ToRequestOptions()) + as PageCollection; } /// diff --git a/.dotnet/src/Custom/Assistants/Internal/Pagination/AssistantsPageEnumerator.cs b/.dotnet/src/Custom/Assistants/Internal/Pagination/AssistantsPageEnumerator.cs index 634dd6b15..66019bbb5 100644 --- a/.dotnet/src/Custom/Assistants/Internal/Pagination/AssistantsPageEnumerator.cs +++ b/.dotnet/src/Custom/Assistants/Internal/Pagination/AssistantsPageEnumerator.cs @@ -21,6 +21,8 @@ internal partial class AssistantsPageEnumerator : PageEnumerator private readonly string _before; private readonly RequestOptions _options; + public virtual ClientPipeline Pipeline => _pipeline; + public AssistantsPageEnumerator( ClientPipeline pipeline, Uri endpoint, diff --git a/.dotnet/src/Custom/Assistants/Internal/Pagination/MessagesPageEnumerator.cs b/.dotnet/src/Custom/Assistants/Internal/Pagination/MessagesPageEnumerator.cs index c8ee06035..53e09fec5 100644 --- a/.dotnet/src/Custom/Assistants/Internal/Pagination/MessagesPageEnumerator.cs +++ b/.dotnet/src/Custom/Assistants/Internal/Pagination/MessagesPageEnumerator.cs @@ -22,6 +22,8 @@ internal partial class MessagesPageEnumerator : PageEnumerator private readonly string _before; private readonly RequestOptions _options; + public virtual ClientPipeline Pipeline => _pipeline; + public MessagesPageEnumerator( ClientPipeline pipeline, Uri endpoint, diff --git a/.dotnet/src/Custom/Assistants/Internal/Pagination/RunStepsPageEnumerator.cs b/.dotnet/src/Custom/Assistants/Internal/Pagination/RunStepsPageEnumerator.cs index d6d74d7d2..b5992ce78 100644 --- a/.dotnet/src/Custom/Assistants/Internal/Pagination/RunStepsPageEnumerator.cs +++ b/.dotnet/src/Custom/Assistants/Internal/Pagination/RunStepsPageEnumerator.cs @@ -23,6 +23,8 @@ internal partial class RunStepsPageEnumerator : PageEnumerator private string? _after; + public virtual ClientPipeline Pipeline => _pipeline; + public RunStepsPageEnumerator( ClientPipeline pipeline, Uri endpoint, diff --git a/.dotnet/src/Custom/Assistants/Internal/Pagination/RunsPageEnumerator.cs b/.dotnet/src/Custom/Assistants/Internal/Pagination/RunsPageEnumerator.cs index 3a0b827d0..f48ceb3c1 100644 --- a/.dotnet/src/Custom/Assistants/Internal/Pagination/RunsPageEnumerator.cs +++ b/.dotnet/src/Custom/Assistants/Internal/Pagination/RunsPageEnumerator.cs @@ -22,6 +22,8 @@ internal partial class RunsPageEnumerator : PageEnumerator private readonly string _before; private readonly RequestOptions _options; + public virtual ClientPipeline Pipeline => _pipeline; + public RunsPageEnumerator( ClientPipeline pipeline, Uri endpoint, diff --git a/.dotnet/src/Custom/VectorStores/Internal/Pagination/VectorStoreFileBatchesPageEnumerator.cs b/.dotnet/src/Custom/VectorStores/Internal/Pagination/VectorStoreFileBatchesPageEnumerator.cs index cd4f938e9..1445485dc 100644 --- a/.dotnet/src/Custom/VectorStores/Internal/Pagination/VectorStoreFileBatchesPageEnumerator.cs +++ b/.dotnet/src/Custom/VectorStores/Internal/Pagination/VectorStoreFileBatchesPageEnumerator.cs @@ -24,6 +24,8 @@ internal partial class VectorStoreFileBatchesPageEnumerator : PageEnumerator _pipeline; + public VectorStoreFileBatchesPageEnumerator( ClientPipeline pipeline, Uri endpoint, diff --git a/.dotnet/src/Custom/VectorStores/Internal/Pagination/VectorStoreFilesPageEnumerator.cs b/.dotnet/src/Custom/VectorStores/Internal/Pagination/VectorStoreFilesPageEnumerator.cs index 3063fb397..9a5e9bec3 100644 --- a/.dotnet/src/Custom/VectorStores/Internal/Pagination/VectorStoreFilesPageEnumerator.cs +++ b/.dotnet/src/Custom/VectorStores/Internal/Pagination/VectorStoreFilesPageEnumerator.cs @@ -23,6 +23,8 @@ internal partial class VectorStoreFilesPageEnumerator : PageEnumerator _pipeline; + public VectorStoreFilesPageEnumerator( ClientPipeline pipeline, Uri endpoint, diff --git a/.dotnet/src/Custom/VectorStores/Internal/Pagination/VectorStoresPageEnumerator.cs b/.dotnet/src/Custom/VectorStores/Internal/Pagination/VectorStoresPageEnumerator.cs index 3e454f384..311a88372 100644 --- a/.dotnet/src/Custom/VectorStores/Internal/Pagination/VectorStoresPageEnumerator.cs +++ b/.dotnet/src/Custom/VectorStores/Internal/Pagination/VectorStoresPageEnumerator.cs @@ -20,6 +20,8 @@ internal partial class VectorStoresPageEnumerator : PageEnumerator private string _after; + public virtual ClientPipeline Pipeline => _pipeline; + public VectorStoresPageEnumerator( ClientPipeline pipeline, Uri endpoint, @@ -96,7 +98,7 @@ internal virtual ClientResult GetVectorStores(int? limit, string order, string a return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); } - private PipelineMessage CreateGetVectorStoresRequest(int? limit, string order, string after, string before, RequestOptions options) + internal PipelineMessage CreateGetVectorStoresRequest(int? limit, string order, string after, string before, RequestOptions options) { var message = _pipeline.CreateMessage(); message.ResponseClassifier = PipelineMessageClassifier200; diff --git a/.dotnet/src/Custom/VectorStores/VectorStoreClient.cs b/.dotnet/src/Custom/VectorStores/VectorStoreClient.cs index 161f4f6ab..1d5947894 100644 --- a/.dotnet/src/Custom/VectorStores/VectorStoreClient.cs +++ b/.dotnet/src/Custom/VectorStores/VectorStoreClient.cs @@ -214,14 +214,8 @@ public virtual AsyncPageCollection GetVectorStoresAsync( VectorStoreCollectionOptions options = default, CancellationToken cancellationToken = default) { - VectorStoresPageEnumerator enumerator = new(_pipeline, _endpoint, - options?.PageSize, - options?.Order?.ToString(), - options?.AfterId, - options?.BeforeId, - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.CreateAsync(enumerator); + return GetVectorStoresAsync(options?.PageSize, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, cancellationToken.ToRequestOptions()) + as AsyncPageCollection; } /// @@ -240,14 +234,8 @@ public virtual AsyncPageCollection GetVectorStoresAsync( Argument.AssertNotNull(firstPageToken, nameof(firstPageToken)); VectorStoresPageToken pageToken = VectorStoresPageToken.FromToken(firstPageToken); - VectorStoresPageEnumerator enumerator = new(_pipeline, _endpoint, - pageToken.Limit, - pageToken.Order, - pageToken.After, - pageToken.Before, - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.CreateAsync(enumerator); + return GetVectorStoresAsync(pageToken?.Limit, pageToken?.Order, pageToken?.After, pageToken?.Before, cancellationToken.ToRequestOptions()) + as AsyncPageCollection; } /// @@ -263,14 +251,8 @@ public virtual PageCollection GetVectorStores( VectorStoreCollectionOptions options = default, CancellationToken cancellationToken = default) { - VectorStoresPageEnumerator enumerator = new(_pipeline, _endpoint, - options?.PageSize, - options?.Order?.ToString(), - options?.AfterId, - options?.BeforeId, - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.Create(enumerator); + return GetVectorStores(options?.PageSize, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, cancellationToken.ToRequestOptions()) + as PageCollection; } /// @@ -289,14 +271,8 @@ public virtual PageCollection GetVectorStores( Argument.AssertNotNull(firstPageToken, nameof(firstPageToken)); VectorStoresPageToken pageToken = VectorStoresPageToken.FromToken(firstPageToken); - VectorStoresPageEnumerator enumerator = new(_pipeline, _endpoint, - pageToken.Limit, - pageToken.Order, - pageToken.After, - pageToken.Before, - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.Create(enumerator); + return GetVectorStores(pageToken?.Limit, pageToken?.Order, pageToken?.After, pageToken?.Before, cancellationToken.ToRequestOptions()) + as PageCollection; } /// @@ -355,16 +331,8 @@ public virtual AsyncPageCollection GetFileAssociatio { Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - VectorStoreFilesPageEnumerator enumerator = new(_pipeline, _endpoint, - vectorStoreId, - options?.PageSize, - options?.Order?.ToString(), - options?.AfterId, - options?.BeforeId, - options?.Filter?.ToString(), - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.CreateAsync(enumerator); + return GetFileAssociationsAsync(vectorStoreId, options?.PageSize, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, options?.Filter?.ToString(), cancellationToken.ToRequestOptions()) + as AsyncPageCollection; } /// @@ -383,16 +351,8 @@ public virtual AsyncPageCollection GetFileAssociatio Argument.AssertNotNull(firstPageToken, nameof(firstPageToken)); VectorStoreFilesPageToken pageToken = VectorStoreFilesPageToken.FromToken(firstPageToken); - VectorStoreFilesPageEnumerator enumerator = new(_pipeline, _endpoint, - pageToken.VectorStoreId, - pageToken.Limit, - pageToken.Order, - pageToken.After, - pageToken.Before, - pageToken.Filter, - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.CreateAsync(enumerator); + return GetFileAssociationsAsync(pageToken?.VectorStoreId, pageToken?.Limit, pageToken?.Order, pageToken?.After, pageToken?.Before, pageToken?.Filter, cancellationToken.ToRequestOptions()) + as AsyncPageCollection; } /// @@ -415,16 +375,8 @@ public virtual PageCollection GetFileAssociations( { Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - VectorStoreFilesPageEnumerator enumerator = new(_pipeline, _endpoint, - vectorStoreId, - options?.PageSize, - options?.Order?.ToString(), - options?.AfterId, - options?.BeforeId, - options?.Filter?.ToString(), - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.Create(enumerator); + return GetFileAssociations(vectorStoreId, options?.PageSize, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, options?.Filter?.ToString(), cancellationToken.ToRequestOptions()) + as PageCollection; } /// @@ -443,16 +395,8 @@ public virtual PageCollection GetFileAssociations( Argument.AssertNotNull(firstPageToken, nameof(firstPageToken)); VectorStoreFilesPageToken pageToken = VectorStoreFilesPageToken.FromToken(firstPageToken); - VectorStoreFilesPageEnumerator enumerator = new(_pipeline, _endpoint, - pageToken.VectorStoreId, - pageToken.Limit, - pageToken.Order, - pageToken.After, - pageToken.Before, - pageToken.Filter, - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.Create(enumerator); + return GetFileAssociations(pageToken?.VectorStoreId, pageToken?.Limit, pageToken?.Order, pageToken?.After, pageToken?.Before, pageToken?.Filter, cancellationToken.ToRequestOptions()) + as PageCollection; } /// @@ -680,17 +624,8 @@ public virtual AsyncPageCollection GetFileAssociatio Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); Argument.AssertNotNullOrEmpty(batchJobId, nameof(batchJobId)); - VectorStoreFileBatchesPageEnumerator enumerator = new(_pipeline, _endpoint, - vectorStoreId, - batchJobId, - options?.PageSize, - options?.Order?.ToString(), - options?.AfterId, - options?.BeforeId, - options?.Filter?.ToString(), - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.CreateAsync(enumerator); + return GetFileAssociationsAsync(vectorStoreId, batchJobId, options?.PageSize, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, options?.Filter?.ToString(), cancellationToken.ToRequestOptions()) + as AsyncPageCollection; } /// @@ -732,17 +667,8 @@ public virtual AsyncPageCollection GetFileAssociatio nameof(vectorStoreId)); } - VectorStoreFileBatchesPageEnumerator enumerator = new(_pipeline, _endpoint, - pageToken.VectorStoreId, - pageToken.BatchId, - pageToken.Limit, - pageToken.Order, - pageToken.After, - pageToken.Before, - pageToken.Filter, - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.CreateAsync(enumerator); + return GetFileAssociationsAsync(vectorStoreId, batchJobId, pageToken?.Limit, pageToken?.Order, pageToken?.After, pageToken?.Before, pageToken?.Filter, cancellationToken.ToRequestOptions()) + as AsyncPageCollection; } /// @@ -770,17 +696,8 @@ public virtual PageCollection GetFileAssociations( Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); Argument.AssertNotNullOrEmpty(batchJobId, nameof(batchJobId)); - VectorStoreFileBatchesPageEnumerator enumerator = new(_pipeline, _endpoint, - vectorStoreId, - batchJobId, - options?.PageSize, - options?.Order?.ToString(), - options?.AfterId, - options?.BeforeId, - options?.Filter?.ToString(), - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.Create(enumerator); + return GetFileAssociations(vectorStoreId, batchJobId, options?.PageSize, options?.Order?.ToString(), options?.AfterId, options?.BeforeId, options?.Filter?.ToString(), cancellationToken.ToRequestOptions()) + as PageCollection; } /// @@ -823,16 +740,7 @@ public virtual PageCollection GetFileAssociations( nameof(vectorStoreId)); } - VectorStoreFileBatchesPageEnumerator enumerator = new(_pipeline, _endpoint, - pageToken.VectorStoreId, - pageToken.BatchId, - pageToken.Limit, - pageToken.Order, - pageToken.After, - pageToken.Before, - pageToken.Filter, - cancellationToken.ToRequestOptions()); - - return PageCollectionHelpers.Create(enumerator); + return GetFileAssociations(vectorStoreId, batchJobId, pageToken?.Limit, pageToken?.Order, pageToken?.After, pageToken?.Before, pageToken?.Filter, cancellationToken.ToRequestOptions()) + as PageCollection; } } diff --git a/.openapi3.azure/openapi3-azure-openai.yaml b/.openapi3.azure/openapi3-azure-openai.yaml index 76b8c059b..94c0b0d77 100644 --- a/.openapi3.azure/openapi3-azure-openai.yaml +++ b/.openapi3.azure/openapi3-azure-openai.yaml @@ -3,32 +3,10 @@ info: title: Azure OpenAI Service version: 0.0.0 tags: - - name: Assistants - name: Chat - name: Images + - name: Assistants paths: - /assistants: - post: - tags: - - Assistants - operationId: createAssistant - summary: Create an assistant with a model and instructions. - parameters: [] - responses: - '200': - description: The request has succeeded. - content: - application/json: - schema: - anyOf: - - $ref: '#/components/schemas/OpenAI.AssistantObject' - - $ref: '#/components/schemas/OpenAI.ErrorResponse' - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/OpenAI.CreateAssistantRequest' /chat/completions: post: tags: @@ -76,31 +54,6 @@ paths: application/json: schema: $ref: '#/components/schemas/OpenAI.CreateImageRequest' - /threads/runs: - post: - tags: - - Assistants - operationId: createThreadAndRun - summary: Create a thread and run it in one request. - parameters: [] - responses: - '200': - description: The request has succeeded. - content: - application/json: - schema: - anyOf: - - $ref: '#/components/schemas/OpenAI.RunObject' - - type: array - items: - $ref: '#/components/schemas/AssistantStreamEvent' - - $ref: '#/components/schemas/OpenAI.ErrorResponse' - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/OpenAI.CreateThreadAndRunRequest' /threads/{thread_id}/messages: post: tags: @@ -129,392 +82,21 @@ paths: application/json: schema: $ref: '#/components/schemas/OpenAI.CreateMessageRequest' - /threads/{thread_id}/runs: - post: - tags: - - Assistants - operationId: createRun - summary: Create a run. - parameters: - - name: thread_id - in: path - required: true - description: The ID of the thread to run. - schema: - type: string - responses: - '200': - description: The request has succeeded. - content: - application/json: - schema: - anyOf: - - $ref: '#/components/schemas/OpenAI.RunObject' - - type: array - items: - $ref: '#/components/schemas/AssistantStreamEvent' - - $ref: '#/components/schemas/OpenAI.ErrorResponse' - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/OpenAI.CreateRunRequest' - get: - tags: - - Assistants - operationId: listRuns - summary: Returns a list of runs belonging to a thread. - parameters: - - name: thread_id - in: path - required: true - description: The ID of the thread the run belongs to. - schema: - type: string - - name: limit - in: query - required: false - description: |- - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the - default is 20. - schema: - type: integer - format: int32 - default: 20 - - name: order - in: query - required: false - description: |- - Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` - for descending order. - schema: - $ref: '#/components/schemas/ListOrder' - default: desc - - name: after - in: query - required: false - 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. - schema: - type: string - - name: before - in: query - required: false - 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. - schema: - type: string - responses: - '200': - description: The request has succeeded. - content: - application/json: - schema: - anyOf: - - $ref: '#/components/schemas/OpenAI.ListRunsResponse' - - $ref: '#/components/schemas/OpenAI.ErrorResponse' - /threads/{thread_id}/runs/{run_id}: - get: - tags: - - Assistants - operationId: getRun - summary: Retrieves a run. - parameters: - - name: thread_id - in: path - required: true - description: The ID of the [thread](/docs/api-reference/threads) that was run. - schema: - type: string - - name: run_id - in: path - required: true - description: The ID of the run to retrieve. - schema: - type: string - responses: - '200': - description: The request has succeeded. - content: - application/json: - schema: - anyOf: - - $ref: '#/components/schemas/OpenAI.RunObject' - - $ref: '#/components/schemas/OpenAI.ErrorResponse' - post: - tags: - - Assistants - operationId: modifyRun - summary: Modifies a run. - parameters: - - name: thread_id - in: path - required: true - description: The ID of the [thread](/docs/api-reference/threads) that was run. - schema: - type: string - - name: run_id - in: path - required: true - description: The ID of the run to modify. - schema: - type: string - responses: - '200': - description: The request has succeeded. - content: - application/json: - schema: - anyOf: - - $ref: '#/components/schemas/OpenAI.RunObject' - - $ref: '#/components/schemas/OpenAI.ErrorResponse' - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/OpenAI.ModifyRunRequest' - /threads/{thread_id}/runs/{run_id}/cancel: - post: - tags: - - Assistants - operationId: cancelRun - summary: Cancels a run that is `in_progress`. - parameters: - - name: thread_id - in: path - required: true - description: The ID of the thread to which this run belongs. - schema: - type: string - - name: run_id - in: path - required: true - description: The ID of the run to cancel. - schema: - type: string - responses: - '200': - description: The request has succeeded. - content: - application/json: - schema: - anyOf: - - $ref: '#/components/schemas/OpenAI.RunObject' - - $ref: '#/components/schemas/OpenAI.ErrorResponse' - /threads/{thread_id}/runs/{run_id}/steps: - get: - tags: - - Assistants - operationId: listRunSteps - summary: Returns a list of run steps belonging to a run. - parameters: - - name: thread_id - in: path - required: true - description: The ID of the thread the run and run steps belong to. - schema: - type: string - - name: run_id - in: path - required: true - description: The ID of the run the run steps belong to. - schema: - type: string - - name: limit - in: query - required: false - description: |- - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the - default is 20. - schema: - type: integer - format: int32 - default: 20 - - name: order - in: query - required: false - description: |- - Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` - for descending order. - schema: - $ref: '#/components/schemas/ListOrder' - default: desc - - name: after - in: query - required: false - 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. - schema: - type: string - - name: before - in: query - required: false - 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. - schema: - type: string - responses: - '200': - description: The request has succeeded. - content: - application/json: - schema: - anyOf: - - $ref: '#/components/schemas/OpenAI.ListRunStepsResponse' - - $ref: '#/components/schemas/OpenAI.ErrorResponse' - /threads/{thread_id}/runs/{run_id}/steps/{step_id}: - get: - tags: - - Assistants - operationId: getRunStep - summary: Retrieves a run step. - parameters: - - name: thread_id - in: path - required: true - description: The ID of the thread to which the run and run step belongs. - schema: - type: string - - name: run_id - in: path - required: true - description: The ID of the run to which the run step belongs. - schema: - type: string - - name: step_id - in: path - required: true - description: The ID of the run step to retrieve. - schema: - type: string - responses: - '200': - description: The request has succeeded. - content: - application/json: - schema: - anyOf: - - $ref: '#/components/schemas/AzureRunStepObject' - - $ref: '#/components/schemas/OpenAI.ErrorResponse' - /threads/{thread_id}/runs/{run_id}/submit_tool_outputs: - post: - tags: - - Assistants - operationId: submitToolOutputsToRun - summary: |- - When a run has the `status: "requires_action"` and `required_action.type` is - `submit_tool_outputs`, this endpoint can be used to submit the outputs from the tool calls once - they're all completed. All outputs must be submitted in a single request. - parameters: - - name: thread_id - in: path - required: true - description: The ID of the [thread](/docs/api-reference/threads) to which this run belongs. - schema: - type: string - - name: run_id - in: path - required: true - description: The ID of the run that requires the tool output submission. - schema: - type: string - responses: - '200': - description: The request has succeeded. - content: - application/json: - schema: - anyOf: - - $ref: '#/components/schemas/OpenAI.RunObject' - - $ref: '#/components/schemas/OpenAI.ErrorResponse' - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/OpenAI.SubmitToolOutputsRunRequest' security: - ApiKeyAuth: [] - OAuth2Auth: - https://cognitiveservices.azure.com/.default components: schemas: - AssistantStreamEvent: - anyOf: - - $ref: '#/components/schemas/ThreadStreamEvent' - - $ref: '#/components/schemas/RunStreamEvent' - - $ref: '#/components/schemas/RunStepStreamEvent' - - $ref: '#/components/schemas/MessageStreamEvent' - - $ref: '#/components/schemas/OpenAI.ErrorEvent' - - $ref: '#/components/schemas/OpenAI.DoneEvent' - description: |- - Represents an event emitted when streaming a Run. - - Each event in a server-sent events stream has an `event` and `data` property: - - ``` - event: thread.created - data: {"id": "thread_123", "object": "thread", ...} - ``` - - We emit events whenever a new object is created, transitions to a new state, or is being - streamed in parts (deltas). For example, we emit `thread.run.created` when a new run - is created, `thread.run.completed` when a run completes, and so on. When an Assistant chooses - to create a message during a run, we emit a `thread.message.created event`, a - `thread.message.in_progress` event, many `thread.message.delta` events, and finally a - `thread.message.completed` event. - - We may add additional events over time, so we recommend handling unknown events gracefully - in your code. See the [Assistants API quickstart](/docs/assistants/overview) to learn how to - integrate the Assistants API with streaming. - AssistantsApiResponseFormatOption: - anyOf: - - type: string - enum: - - none - - auto - - $ref: '#/components/schemas/OpenAI.AssistantsApiResponseFormat' - description: |- - Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4 Turbo](/docs/models/gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`. - - Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is valid JSON. - - **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - x-oaiExpandable: true - AssistantsApiToolChoiceOption: - anyOf: - - type: string - enum: - - none - - auto - - required - - $ref: '#/components/schemas/OpenAI.AssistantsNamedToolChoice' - description: |- - Controls which (if any) tool is called by the model. - `none` means the model will not call any tools and instead generates a message. - `auto` is the default value and means the model can pick between generating a message or calling one or more tools. - `required` means the model must call one or more tools before responding to the user. - Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. - x-oaiExpandable: true - AzureChatCompletionResponseMessage: - type: object - properties: - context: - allOf: - - $ref: '#/components/schemas/AzureChatMessageContext' - description: The Azure-specific context information associated with the chat completion response message. - allOf: - - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' + AzureChatCompletionResponseMessage: + type: object + properties: + context: + allOf: + - $ref: '#/components/schemas/AzureChatMessageContext' + description: The Azure-specific context information associated with the chat completion response message. + allOf: + - $ref: '#/components/schemas/OpenAI.ChatCompletionResponseMessage' description: |- The extended response model component for chat completion response messages on the Azure OpenAI service. This model adds support for chat message context, used by the On Your Data feature for intent, citations, and other @@ -1457,115 +1039,6 @@ components: error: $ref: '#/components/schemas/AzureOpenAIDalleError' description: A structured representation of an error an Azure OpenAI request. - AzureRunStepDetailsToolCallsObjectToolCallsObject: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.RunStepDetailsToolCallsObjectToolCallsObject' - AzureRunStepObject: - type: object - required: - - id - - object - - created_at - - assistant_id - - thread_id - - run_id - - type - - status - - last_error - - expired_at - - cancelled_at - - failed_at - - completed_at - - metadata - - usage - properties: - id: - type: string - description: The identifier of the run step, which can be referenced in API endpoints. - object: - type: string - enum: - - thread.run.step - description: The object type, which is always `thread.run.step`. - created_at: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) for when the run step was created. - assistant_id: - type: string - description: The ID of the [assistant](/docs/api-reference/assistants) associated with the run step. - thread_id: - type: string - description: The ID of the [thread](/docs/api-reference/threads) that was run. - run_id: - type: string - description: The ID of the [run](/docs/api-reference/runs) that this run step is a part of. - type: - type: string - enum: - - message_creation - - tool_calls - description: The type of run step, which can be either `message_creation` or `tool_calls`. - status: - type: string - enum: - - in_progress - - cancelled - - failed - - completed - - expired - description: The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`. - last_error: - type: object - properties: - code: - type: string - enum: - - server_error - - rate_limit_exceeded - description: One of `server_error` or `rate_limit_exceeded`. - message: - type: string - description: A human-readable description of the error. - required: - - code - - message - nullable: true - description: The last error associated with this run step. Will be `null` if there are no errors. - expired_at: - type: integer - format: unixtime - nullable: true - description: The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired. - cancelled_at: - type: integer - format: unixtime - nullable: true - description: The Unix timestamp (in seconds) for when the run step was cancelled. - failed_at: - type: integer - format: unixtime - nullable: true - description: The Unix timestamp (in seconds) for when the run step failed. - completed_at: - type: integer - format: unixtime - nullable: true - description: The Unix timestamp (in seconds) for when the run step completed. - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. - x-oaiTypeLabel: map - usage: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.RunStepCompletionUsage' - nullable: true - description: Represents a step in execution of a run. AzureSearchChatDataSource: type: object required: @@ -1703,26 +1176,6 @@ components: allOf: - $ref: '#/components/schemas/AzureChatDataSource' description: Represents a data source configuration that will use an Azure Search resource. - BingSearchToolDefinition: - type: object - required: - - type - properties: - type: - type: string - enum: - - browser - description: 'The type of tool being defined: `browser`' - browser: - type: object - properties: - bing_resource_id: - type: string - description: The resource ID of the Bing Search resource to use. - required: - - bing_resource_id - allOf: - - $ref: '#/components/schemas/OpenAI.AssistantToolDefinition' ChatCompletionMessageToolCallsItem: type: array items: @@ -1755,7 +1208,7 @@ components: `none` is the default when no tools are present. `auto` is the default if tools are present. x-oaiExpandable: true - CreateMessageRequestAttachmentsItem: + CreateMessageRequestAttachments: type: array items: type: object @@ -1774,21 +1227,6 @@ components: required: - file_id - tools - CreateRunRequestAdditional_messages: - type: array - items: - $ref: '#/components/schemas/OpenAI.CreateMessageRequest' - CreateRunRequestTools: - type: array - items: - $ref: '#/components/schemas/OpenAI.AssistantToolDefinition' - maxItems: 20 - x-oaiExpandable: true - CreateThreadAndRunRequestTools: - type: array - items: - $ref: '#/components/schemas/OpenAI.AssistantToolDefinition' - maxItems: 20 ElasticsearchChatDataSource: type: object required: @@ -1893,88 +1331,7 @@ components: description: The parameter information to control the use of the Elasticsearch data source. allOf: - $ref: '#/components/schemas/AzureChatDataSource' - ListOrder: - anyOf: - - type: string - - type: string - enum: - - asc - - desc - MessageContentTextAnnotationsBingSearchUrlCitation: - type: object - required: - - type - - text - - url_citation - - start_index - - end_index - properties: - type: - type: string - enum: - - url_citation - description: Always `url_citation`. - text: - type: string - description: The text in the message content that needs to be replaced. - url_citation: - type: object - properties: - url: - type: string - format: uri - title: - type: string - required: - - url - - title - start_index: - type: integer - format: int32 - minimum: 0 - end_index: - type: integer - format: int32 - minimum: 0 - allOf: - - $ref: '#/components/schemas/OpenAI.MessageContentTextObjectAnnotation' - MessageDeltaContentTextAnnotationsBingSearchUrlCitation: - type: object - required: - - index - - type - properties: - index: - type: integer - format: int32 - description: The index of the annotation in the text content part. - type: - type: string - enum: - - url_citation - description: Always `url_citation`. - text: - type: string - description: The text in the message content that needs to be replaced. - url_citation: - type: object - properties: - url: - type: string - format: uri - title: - type: string - start_index: - type: integer - format: int32 - minimum: 0 - end_index: - type: integer - format: int32 - minimum: 0 - allOf: - - $ref: '#/components/schemas/OpenAI.MessageDeltaTextContentAnnotation' - MessageObjectAttachmentsItem: + MessageObjectAttachments: type: array items: type: object @@ -1990,201 +1347,36 @@ components: - $ref: '#/components/schemas/OpenAI.AssistantToolsFileSearchTypeOnly' description: The tools to add this file to. x-oaiExpandable: true - MessageStreamEvent: - anyOf: - - type: object - properties: - event: - type: string - enum: - - thread.message.created - data: - $ref: '#/components/schemas/OpenAI.MessageObject' - required: - - event - - data - - type: object - properties: - event: - type: string - enum: - - thread.message.in_progress - data: - $ref: '#/components/schemas/OpenAI.MessageObject' - required: - - event - - data - - type: object - properties: - event: - type: string - enum: - - thread.message.delta - data: - $ref: '#/components/schemas/OpenAI.MessageDeltaObject' - required: - - event - - data - - type: object - properties: - event: - type: string - enum: - - thread.message.completed - data: - $ref: '#/components/schemas/OpenAI.MessageObject' - required: - - event - - data - - type: object - properties: - event: - type: string - enum: - - thread.message.incomplete - data: - $ref: '#/components/schemas/OpenAI.MessageObject' - required: - - event - - data - OpenAI.AssistantObject: + OpenAI.AssistantToolDefinition: type: object required: - - id - - object - - created_at - - name - - description - - model - - instructions - - tools - - metadata + - type properties: - id: + type: type: string - description: The identifier, which can be referenced in API endpoints. - object: + discriminator: + propertyName: type + mapping: + file_search: '#/components/schemas/OpenAI.AssistantToolsFileSearch' + function: '#/components/schemas/OpenAI.AssistantToolsFunction' + OpenAI.AssistantToolsCode: + type: object + required: + - type + properties: + type: type: string enum: - - assistant - description: The object type, which is always `assistant`. - created_at: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) for when the assistant was created. - name: - type: string - nullable: true - maxLength: 256 - description: The name of the assistant. The maximum length is 256 characters. - description: - type: string - nullable: true - maxLength: 512 - description: The description of the assistant. The maximum length is 512 characters. - model: - type: string - description: ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. - instructions: - type: string - nullable: true - maxLength: 256000 - description: The system instructions that the assistant uses. The maximum length is 256,000 characters. - tools: - type: array - items: - $ref: '#/components/schemas/OpenAI.AssistantToolDefinition' - maxItems: 128 - description: A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. - x-oaiExpandable: true - default: [] - tool_resources: - type: object - properties: - code_interpreter: - type: object - properties: - file_ids: - type: array - items: - type: string - maxItems: 20 - description: A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter`` tool. There can be a maximum of 20 files associated with the tool. - default: [] - file_search: - type: object - properties: - vector_store_ids: - type: array - items: - type: string - maxItems: 1 - description: The ID of the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant. - nullable: true - description: A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. - x-oaiTypeLabel: map - temperature: - type: number - format: float - nullable: true - minimum: 0 - maximum: 2 - description: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - default: 1 - top_p: - type: number - format: float - nullable: true - minimum: 0 - maximum: 1 - description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or temperature but not both. - default: 1 - response_format: - oneOf: - - $ref: '#/components/schemas/AssistantsApiResponseFormatOption' - nullable: true - description: Represents an `assistant` that can call the model and use tools. - OpenAI.AssistantToolDefinition: - type: object - required: - - type - properties: - type: - type: string - discriminator: - propertyName: type - mapping: - browser: '#/components/schemas/BingSearchToolDefinition' - code_interpreter: '#/components/schemas/OpenAI.AssistantToolsCode' - file_search: '#/components/schemas/OpenAI.AssistantToolsFileSearch' - function: '#/components/schemas/OpenAI.AssistantToolsFunction' - OpenAI.AssistantToolsCode: - type: object - required: - - type - properties: - type: - type: string - enum: - - code_interpreter - description: 'The type of tool being defined: `code_interpreter`' - allOf: - - $ref: '#/components/schemas/OpenAI.AssistantToolDefinition' - OpenAI.AssistantToolsFileSearch: - type: object - required: - - type - properties: - type: + - code_interpreter + description: 'The type of tool being defined: `code_interpreter`' + allOf: + - $ref: '#/components/schemas/OpenAI.AssistantToolDefinition' + OpenAI.AssistantToolsFileSearch: + type: object + required: + - type + properties: + type: type: string enum: - file_search @@ -2229,38 +1421,6 @@ components: $ref: '#/components/schemas/OpenAI.FunctionObject' allOf: - $ref: '#/components/schemas/OpenAI.AssistantToolDefinition' - OpenAI.AssistantsApiResponseFormat: - type: object - properties: - type: - type: string - enum: - - text - - json_object - description: Must be one of `text` or `json_object`. - default: text - description: An object describing the expected output of the model. If `json_object` only `function` type `tools` are allowed to be passed to the Run. If `text` the model can return text or any value needed. - OpenAI.AssistantsNamedToolChoice: - type: object - required: - - type - properties: - type: - type: string - enum: - - function - - code_interpreter - - file_search - description: The type of the tool. If type is `function`, the function name must be set - function: - type: object - properties: - name: - type: string - description: The name of the function to call. - required: - - name - description: Specifies a tool the model should use. Use to force the model to call a specific tool. OpenAI.ChatCompletionFunctionCallOption: type: object required: @@ -2685,151 +1845,6 @@ components: format: int32 description: Total number of tokens used in the request (prompt + completion). description: Usage statistics for the completion request. - OpenAI.CreateAssistantRequest: - type: object - required: - - model - properties: - model: - anyOf: - - type: string - - type: string - enum: - - gpt-4o - - gpt-4o-2024-05-13 - - gpt-4-turbo - - gpt-4-turbo-2024-04-09 - - gpt-4-0125-preview - - gpt-4-turbo-preview - - gpt-4-1106-preview - - gpt-4-vision-preview - - gpt-4 - - gpt-4-0314 - - gpt-4-0613 - - gpt-4-32k - - gpt-4-32k-0314 - - gpt-4-32k-0613 - - gpt-3.5-turbo - - gpt-3.5-turbo-16k - - gpt-3.5-turbo-0613 - - gpt-3.5-turbo-1106 - - gpt-3.5-turbo-0125 - - gpt-3.5-turbo-16k-0613 - description: ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. - x-oaiTypeLabel: string - name: - type: string - nullable: true - maxLength: 256 - description: The name of the assistant. The maximum length is 256 characters. - description: - type: string - nullable: true - maxLength: 512 - description: The description of the assistant. The maximum length is 512 characters. - instructions: - type: string - nullable: true - maxLength: 256000 - description: The system instructions that the assistant uses. The maximum length is 256,000 characters. - tools: - type: array - items: - $ref: '#/components/schemas/OpenAI.AssistantToolDefinition' - maxItems: 128 - description: A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. - x-oaiExpandable: true - default: [] - tool_resources: - type: object - properties: - code_interpreter: - type: object - properties: - file_ids: - type: array - items: - type: string - maxItems: 20 - description: A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. - default: [] - file_search: - anyOf: - - $ref: '#/components/schemas/OpenAI.CreateAssistantRequestToolResourcesFileSearchVectorStoreIdReferences' - - $ref: '#/components/schemas/OpenAI.CreateAssistantRequestToolResourcesFileSearchVectorStoreCreationHelpers' - nullable: true - description: A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. - x-oaiTypeLabel: map - temperature: - type: number - format: float - nullable: true - minimum: 0 - maximum: 2 - description: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - default: 1 - top_p: - type: number - format: float - nullable: true - minimum: 0 - maximum: 1 - description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or temperature but not both. - default: 1 - response_format: - oneOf: - - $ref: '#/components/schemas/AssistantsApiResponseFormatOption' - nullable: true - OpenAI.CreateAssistantRequestToolResourcesFileSearchVectorStoreCreationHelpers: - type: object - properties: - vector_stores: - type: array - items: - type: object - properties: - file_ids: - type: array - items: - type: string - maxItems: 10000 - description: |- - A list of [file](/docs/api-reference/files) IDs to add to the vector store. There can be - a maximum of 10000 files in a vector store. - metadata: - type: object - additionalProperties: - type: string - description: |- - Set of 16 key-value pairs that can be attached to a vector store. This can be useful for - storing additional information about the vector store in a structured format. Keys can - be a maximum of 64 characters long and values can be a maxium of 512 characters long. - x-oaiTypeLabel: map - maxItems: 1 - description: |- - A helper to create a [vector store](/docs/api-reference/vector-stores/object) with - file_ids and attach it to this assistant. There can be a maximum of 1 vector store - attached to the assistant. - OpenAI.CreateAssistantRequestToolResourcesFileSearchVectorStoreIdReferences: - type: object - properties: - vector_store_ids: - type: array - items: - type: string - maxItems: 1 - description: |- - The [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. - There can be a maximum of 1 vector store attached to the assistant. OpenAI.CreateChatCompletionRequest: type: object required: @@ -3203,7 +2218,7 @@ components: attachments: type: object allOf: - - $ref: '#/components/schemas/CreateMessageRequestAttachmentsItem' + - $ref: '#/components/schemas/CreateMessageRequestAttachments' nullable: true description: A list of files attached to the message, and the tools they should be added to. metadata: @@ -3213,373 +2228,24 @@ components: nullable: true description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. x-oaiTypeLabel: map - OpenAI.CreateRunRequest: + OpenAI.Error: type: object required: - - assistant_id + - code + - message + - param + - type properties: - assistant_id: + code: type: string - description: The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run. - model: - anyOf: - - type: string - - type: string - enum: - - gpt-4o - - gpt-4o-2024-05-13 - - gpt-4-turbo - - gpt-4-turbo-2024-04-09 - - gpt-4-0125-preview - - gpt-4-turbo-preview - - gpt-4-1106-preview - - gpt-4-vision-preview - - gpt-4 - - gpt-4-0314 - - gpt-4-0613 - - gpt-4-32k - - gpt-4-32k-0314 - - gpt-4-32k-0613 - - gpt-3.5-turbo - - gpt-3.5-turbo-16k - - gpt-3.5-turbo-0613 - - gpt-3.5-turbo-1106 - - gpt-3.5-turbo-0125 - - gpt-3.5-turbo-16k-0613 nullable: true - description: The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used. - x-oaiTypeLabel: string - instructions: + message: type: string - nullable: true - description: Overrides the [instructions](/docs/api-reference/assistants/createAssistant) of the assistant. This is useful for modifying the behavior on a per-run basis. - additional_instructions: - type: string - nullable: true - description: Appends additional instructions at the end of the instructions for the run. This is useful for modifying the behavior on a per-run basis without overriding other instructions. - additional_messages: - type: object - allOf: - - $ref: '#/components/schemas/CreateRunRequestAdditional_messages' - nullable: true - description: Adds additional messages to the thread before creating the run. - tools: - type: object - allOf: - - $ref: '#/components/schemas/CreateRunRequestTools' - nullable: true - description: Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. - x-oaiTypeLabel: map - temperature: - type: number - format: float - nullable: true - minimum: 0 - maximum: 2 - description: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - default: 1 - top_p: - type: number - format: float - nullable: true - minimum: 0 - maximum: 1 - description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or temperature but not both. - default: 1 - stream: - type: boolean - nullable: true - description: 'If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message.' - max_prompt_tokens: - type: integer - format: int32 - nullable: true - minimum: 256 - description: The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. - max_completion_tokens: - type: integer - format: int32 - nullable: true - minimum: 256 - description: The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. - truncation_strategy: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.TruncationObject' - nullable: true - tool_choice: - oneOf: - - $ref: '#/components/schemas/AssistantsApiToolChoiceOption' - nullable: true - parallel_tool_calls: - type: boolean - default: true - response_format: - oneOf: - - $ref: '#/components/schemas/AssistantsApiResponseFormatOption' - nullable: true - OpenAI.CreateThreadAndRunRequest: - type: object - required: - - assistant_id - properties: - assistant_id: - type: string - description: The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run. - thread: - allOf: - - $ref: '#/components/schemas/OpenAI.CreateThreadRequest' - description: If no thread is provided, an empty thread will be created. - model: - anyOf: - - type: string - - type: string - enum: - - gpt-4o - - gpt-4o-2024-05-13 - - gpt-4-turbo - - gpt-4-turbo-2024-04-09 - - gpt-4-0125-preview - - gpt-4-turbo-preview - - gpt-4-1106-preview - - gpt-4-vision-preview - - gpt-4 - - gpt-4-0314 - - gpt-4-0613 - - gpt-4-32k - - gpt-4-32k-0314 - - gpt-4-32k-0613 - - gpt-3.5-turbo - - gpt-3.5-turbo-16k - - gpt-3.5-turbo-0613 - - gpt-3.5-turbo-1106 - - gpt-3.5-turbo-0125 - - gpt-3.5-turbo-16k-0613 - nullable: true - description: The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used. - x-oaiTypeLabel: string - instructions: - type: string - nullable: true - description: Override the default system message of the assistant. This is useful for modifying the behavior on a per-run basis. - tools: - type: object - allOf: - - $ref: '#/components/schemas/CreateThreadAndRunRequestTools' - nullable: true - description: Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. - tool_resources: - type: object - properties: - code_interpreter: - type: object - properties: - file_ids: - type: array - items: - type: string - maxItems: 20 - description: A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. - default: [] - file_search: - type: object - properties: - vector_store_ids: - type: array - items: - type: string - maxItems: 1 - description: The ID of the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant. - nullable: true - description: A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. - x-oaiTypeLabel: map - temperature: - type: number - format: float - nullable: true - minimum: 0 - maximum: 2 - description: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - default: 1 - top_p: - type: number - format: float - nullable: true - minimum: 0 - maximum: 1 - description: |- - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - - We generally recommend altering this or temperature but not both. - default: 1 - stream: - type: boolean - nullable: true - description: 'If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message.' - max_prompt_tokens: - type: integer - format: int32 - nullable: true - minimum: 256 - description: The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. - max_completion_tokens: - type: integer - format: int32 - nullable: true - minimum: 256 - description: The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. - truncation_strategy: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.TruncationObject' - nullable: true - tool_choice: - oneOf: - - $ref: '#/components/schemas/AssistantsApiToolChoiceOption' - nullable: true - parallel_tool_calls: - type: boolean - default: true - response_format: - oneOf: - - $ref: '#/components/schemas/AssistantsApiResponseFormatOption' - nullable: true - OpenAI.CreateThreadRequest: - type: object - properties: - messages: - type: array - items: - $ref: '#/components/schemas/OpenAI.CreateMessageRequest' - description: A list of [messages](/docs/api-reference/messages) to start the thread with. - tool_resources: - type: object - properties: - code_interpreter: - type: object - properties: - file_ids: - type: array - items: - type: string - maxItems: 20 - description: A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. - default: [] - file_search: - anyOf: - - $ref: '#/components/schemas/OpenAI.CreateThreadRequestToolResourcesFileSearchVectorStoreIdReferences' - - $ref: '#/components/schemas/OpenAI.CreateThreadRequestToolResourcesFileSearchVectorStoreCreationHelpers' - nullable: true - description: A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. - x-oaiTypeLabel: map - OpenAI.CreateThreadRequestToolResourcesFileSearchVectorStoreCreationHelpers: - type: object - properties: - vector_stores: - type: array - items: - type: object - properties: - file_ids: - type: array - items: - type: string - maxItems: 10000 - description: |- - A list of [file](/docs/api-reference/files) IDs to add to the vector store. There can be - a maximum of 10000 files in a vector store. - metadata: - type: object - additionalProperties: - type: string - description: |- - Set of 16 key-value pairs that can be attached to a vector store. This can be useful for - storing additional information about the vector store in a structured format. Keys can - be a maximum of 64 characters long and values can be a maxium of 512 characters long. - x-oaiTypeLabel: map - maxItems: 1 - description: |- - A helper to create a [vector store](/docs/api-reference/vector-stores/object) with - file_ids and attach it to this thread. There can be a maximum of 1 vector store attached - to the thread. - OpenAI.CreateThreadRequestToolResourcesFileSearchVectorStoreIdReferences: - type: object - properties: - vector_store_ids: - type: array - items: - type: string - maxItems: 1 - description: |- - The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. - There can be a maximum of 1 vector store attached to the thread. - OpenAI.DoneEvent: - type: object - required: - - event - - data - properties: - event: - type: string - enum: - - done - data: - type: string - enum: - - '[DONE]' - description: Occurs when a stream ends. - OpenAI.Error: - type: object - required: - - code - - message - - param - - type - properties: - code: - type: string - nullable: true - message: - type: string - param: + param: type: string nullable: true type: type: string - OpenAI.ErrorEvent: - type: object - required: - - event - - data - properties: - event: - type: string - enum: - - error - data: - $ref: '#/components/schemas/OpenAI.Error' - description: Occurs when an [error](/docs/guides/error-codes/api-errors) occurs. This can happen due to an internal server error or a timeout. OpenAI.ErrorResponse: type: object required: @@ -3589,1541 +2255,321 @@ components: $ref: '#/components/schemas/OpenAI.Error' OpenAI.FunctionObject: type: object - required: - - name - properties: - description: - type: string - description: A description of what the function does, used by the model to choose when and how to call the function. - name: - type: string - description: The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. - parameters: - $ref: '#/components/schemas/OpenAI.FunctionParameters' - OpenAI.FunctionParameters: - type: object - additionalProperties: {} - description: |- - The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. - - Omitting `parameters` defines a function with an empty parameter list. - OpenAI.Image: - type: object - properties: - b64_json: - type: string - format: base64 - description: The base64-encoded JSON of the generated image, if `response_format` is `b64_json`. - url: - type: string - format: uri - description: The URL of the generated image, if `response_format` is `url` (default). - revised_prompt: - type: string - description: The prompt that was used to generate the image, if there was any revision to the prompt. - description: Represents the url or the content of an image generated by the OpenAI API. - OpenAI.ImagesResponse: - type: object - required: - - created - - data - properties: - created: - type: integer - format: unixtime - data: - type: array - items: - $ref: '#/components/schemas/OpenAI.Image' - OpenAI.ListRunStepsResponse: - type: object - required: - - object - - data - - first_id - - last_id - - has_more - properties: - object: - type: string - enum: - - list - data: - type: array - items: - $ref: '#/components/schemas/OpenAI.RunStepObject' - first_id: - type: string - last_id: - type: string - has_more: - type: boolean - OpenAI.ListRunsResponse: - type: object - required: - - object - - data - - first_id - - last_id - - has_more - properties: - object: - type: string - enum: - - list - data: - type: array - items: - $ref: '#/components/schemas/OpenAI.RunObject' - first_id: - type: string - last_id: - type: string - has_more: - type: boolean - OpenAI.MessageContent: - type: object - description: Represents a single piece of content in an Assistants API message. - OpenAI.MessageContentImageFileObject: - type: object - required: - - type - - image_file - properties: - type: - type: string - enum: - - image_file - description: Always `image_file`. - image_file: - type: object - properties: - file_id: - type: string - description: The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. - detail: - type: string - enum: - - auto - - low - - high - description: Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. - default: auto - required: - - file_id - allOf: - - $ref: '#/components/schemas/OpenAI.MessageContent' - description: References an image [File](/docs/api-reference/files) in the content of a message. - OpenAI.MessageContentImageUrlObject: - type: object - required: - - type - - image_url - properties: - type: - type: string - enum: - - image_url - description: The type of the content part. - image_url: - type: object - properties: - url: - type: string - format: uri - description: 'The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.' - detail: - type: string - enum: - - auto - - low - - high - description: Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` - default: auto - required: - - url - allOf: - - $ref: '#/components/schemas/OpenAI.MessageContent' - description: References an image URL in the content of a message. - OpenAI.MessageContentTextAnnotationsFileCitationObject: - type: object - required: - - type - - text - - file_citation - - start_index - - end_index - properties: - type: - type: string - enum: - - file_citation - description: Always `file_citation`. - text: - type: string - description: The text in the message content that needs to be replaced. - file_citation: - type: object - properties: - file_id: - type: string - description: The ID of the specific File the citation is from. - required: - - file_id - start_index: - type: integer - format: int32 - minimum: 0 - end_index: - type: integer - format: int32 - minimum: 0 - allOf: - - $ref: '#/components/schemas/OpenAI.MessageContentTextObjectAnnotation' - description: A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. - OpenAI.MessageContentTextAnnotationsFilePathObject: - type: object - required: - - type - - text - - file_path - - start_index - - end_index - properties: - type: - type: string - enum: - - file_path - description: Always `file_path`. - text: - type: string - description: The text in the message content that needs to be replaced. - file_path: - type: object - properties: - file_id: - type: string - description: The ID of the file that was generated. - required: - - file_id - start_index: - type: integer - format: int32 - minimum: 0 - end_index: - type: integer - format: int32 - minimum: 0 - allOf: - - $ref: '#/components/schemas/OpenAI.MessageContentTextObjectAnnotation' - description: A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - OpenAI.MessageContentTextObject: - type: object - required: - - type - - text - properties: - type: - type: string - enum: - - text - description: Always `text`. - text: - type: object - properties: - value: - type: string - description: The data that makes up the text. - annotations: - type: array - items: - $ref: '#/components/schemas/OpenAI.MessageContentTextObjectAnnotation' - x-oaiExpandable: true - required: - - value - - annotations - allOf: - - $ref: '#/components/schemas/OpenAI.MessageContent' - description: The text content that is part of a message. - OpenAI.MessageContentTextObjectAnnotation: - type: object - required: - - type - properties: - type: - type: string - description: The discriminated type identifier for the content item. - discriminator: - propertyName: type - mapping: - url_citation: '#/components/schemas/MessageContentTextAnnotationsBingSearchUrlCitation' - file_citation: '#/components/schemas/OpenAI.MessageContentTextAnnotationsFileCitationObject' - file_path: '#/components/schemas/OpenAI.MessageContentTextAnnotationsFilePathObject' - OpenAI.MessageDeltaContent: - type: object - required: - - type - properties: - type: - type: string - description: The discriminated type identifier for the content item. - discriminator: - propertyName: type - mapping: - image_file: '#/components/schemas/OpenAI.MessageDeltaContentImageFileObject' - image_url: '#/components/schemas/OpenAI.MessageDeltaContentImageUrlObject' - text: '#/components/schemas/OpenAI.MessageDeltaContentTextObject' - description: Represents a single piece of incremental content in an Assistants API streaming response. - OpenAI.MessageDeltaContentImageFileObject: - type: object - required: - - index - - type - properties: - index: - type: integer - format: int32 - description: The index of the content part in the message. - type: - type: string - enum: - - image_file - description: Always `image_file`. - image_file: - type: object - properties: - file_id: - type: string - description: The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. - detail: - type: string - enum: - - auto - - low - - high - description: Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. - default: auto - allOf: - - $ref: '#/components/schemas/OpenAI.MessageDeltaContent' - description: References an image [File](/docs/api-reference/files) in the content of a message. - OpenAI.MessageDeltaContentImageUrlObject: - type: object - required: - - index - - type - properties: - index: - type: integer - format: int32 - description: The index of the content part in the message. - type: - type: string - enum: - - image_url - description: Always `image_url`. - image_url: - type: object - properties: - url: - type: string - format: uri - description: 'The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.' - detail: - type: string - enum: - - auto - - low - - high - description: Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. - default: auto - allOf: - - $ref: '#/components/schemas/OpenAI.MessageDeltaContent' - description: References an image URL in the content of a message. - OpenAI.MessageDeltaContentTextAnnotationsFileCitationObject: - type: object - required: - - index - - type - properties: - index: - type: integer - format: int32 - description: The index of the annotation in the text content part. - type: - type: string - enum: - - file_citation - description: Always `file_citation`. - text: - type: string - description: The text in the message content that needs to be replaced. - file_citation: - type: object - properties: - file_id: - type: string - description: The ID of the specific File the citation is from. - quote: - type: string - description: The specific quote in the file. - start_index: - type: integer - format: int32 - minimum: 0 - end_index: - type: integer - format: int32 - minimum: 0 - allOf: - - $ref: '#/components/schemas/OpenAI.MessageDeltaTextContentAnnotation' - description: A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. - OpenAI.MessageDeltaContentTextAnnotationsFilePathObject: - type: object - required: - - index - - type - properties: - index: - type: integer - format: int32 - description: The index of the annotation in the text content part. - type: - type: string - enum: - - file_path - description: Always `file_path`. - text: - type: string - description: The text in the message content that needs to be replaced. - file_path: - type: object - properties: - file_id: - type: string - description: The ID of the file that was generated. - start_index: - type: integer - format: int32 - minimum: 0 - end_index: - type: integer - format: int32 - minimum: 0 - allOf: - - $ref: '#/components/schemas/OpenAI.MessageDeltaTextContentAnnotation' - description: A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - OpenAI.MessageDeltaContentTextObject: - type: object - required: - - index - - type - properties: - index: - type: integer - format: int32 - description: The index of the content part in the message. - type: - type: string - enum: - - text - description: Always `text`. - text: - type: object - properties: - value: - type: string - description: The data that makes up the text. - annotations: - type: array - items: - $ref: '#/components/schemas/OpenAI.MessageDeltaTextContentAnnotation' - x-oaiExpandable: true - allOf: - - $ref: '#/components/schemas/OpenAI.MessageDeltaContent' - description: The text content that is part of a message. - OpenAI.MessageDeltaObject: - type: object - required: - - id - - object - - delta - properties: - id: - type: string - description: The identifier of the message, which can be referenced in API endpoints. - object: - type: string - enum: - - thread.message.delta - description: The object type, which is always `thread.message.delta`. - delta: - type: object - properties: - role: - type: string - enum: - - user - - assistant - description: The entity that produced the message. One of `user` or `assistant`. - content: - type: array - items: - $ref: '#/components/schemas/OpenAI.MessageDeltaContent' - description: The content of the message in array of text and/or images. - x-oaiExpandable: true - description: The delta containing the fields that have changed on the Message. - description: Represents a message delta i.e. any changed fields on a message during streaming. - OpenAI.MessageDeltaTextContentAnnotation: - type: object - required: - - type - properties: - type: - type: string - description: The discriminated type identifier for the content item. - discriminator: - propertyName: type - mapping: - url_citation: '#/components/schemas/MessageDeltaContentTextAnnotationsBingSearchUrlCitation' - file_citation: '#/components/schemas/OpenAI.MessageDeltaContentTextAnnotationsFileCitationObject' - file_path: '#/components/schemas/OpenAI.MessageDeltaContentTextAnnotationsFilePathObject' - OpenAI.MessageObject: - type: object - required: - - id - - object - - created_at - - thread_id - - status - - incomplete_details - - completed_at - - incomplete_at - - role - - content - - assistant_id - - run_id - - attachments - - metadata - properties: - id: - type: string - description: The identifier, which can be referenced in API endpoints. - object: - type: string - enum: - - thread.message - description: The object type, which is always `thread.message`. - created_at: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) for when the message was created. - thread_id: - type: string - description: The [thread](/docs/api-reference/threads) ID that this message belongs to. - status: - type: string - enum: - - in_progress - - incomplete - - completed - description: The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. - incomplete_details: - type: object - properties: - reason: - type: string - enum: - - content_filter - - max_tokens - - run_cancelled - - run_expired - - run_failed - description: The reason the message is incomplete. - required: - - reason - nullable: true - description: On an incomplete message, details about why the message is incomplete. - completed_at: - type: integer - format: unixtime - nullable: true - description: The Unix timestamp (in seconds) for when the message was completed. - incomplete_at: - type: integer - format: unixtime - nullable: true - description: The Unix timestamp (in seconds) for when the message was marked as incomplete. - role: - type: string - enum: - - user - - assistant - description: The entity that produced the message. One of `user` or `assistant`. - content: - type: array - items: - $ref: '#/components/schemas/OpenAI.MessageContent' - description: The content of the message in array of text and/or images. - x-oaiExpandable: true - assistant_id: - type: string - nullable: true - description: If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message. - run_id: - type: string - nullable: true - description: The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. - attachments: - type: object - allOf: - - $ref: '#/components/schemas/MessageObjectAttachmentsItem' - nullable: true - description: A list of files attached to the message, and the tools they were added to. - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. - x-oaiTypeLabel: map - description: Represents a message within a [thread](/docs/api-reference/threads). - OpenAI.MessageRequestContentTextObject: - type: object - required: - - type - - text - properties: - type: - type: string - enum: - - text - description: Always `text`. - text: - type: string - description: Text content to be sent to the model - allOf: - - $ref: '#/components/schemas/OpenAI.MessageContent' - description: The text content that is part of a message. - OpenAI.ModifyRunRequest: - type: object - properties: - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. - x-oaiTypeLabel: map - OpenAI.RunCompletionUsage: - type: object - required: - - completion_tokens - - prompt_tokens - - total_tokens - properties: - completion_tokens: - type: integer - format: int32 - description: Number of completion tokens used over the course of the run. - prompt_tokens: - type: integer - format: int32 - description: Number of prompt tokens used over the course of the run. - total_tokens: - type: integer - format: int32 - description: Total number of tokens used (prompt + completion). - description: Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). - OpenAI.RunObject: - type: object - required: - - id - - object - - created_at - - thread_id - - assistant_id - - status - - required_action - - last_error - - expires_at - - started_at - - cancelled_at - - failed_at - - completed_at - - incomplete_details - - model - - instructions - - tools - - metadata - - usage - - max_prompt_tokens - - max_completion_tokens - - truncation_strategy - - tool_choice - - parallel_tool_calls - - response_format - properties: - id: - type: string - description: The identifier, which can be referenced in API endpoints. - object: - type: string - enum: - - thread.run - description: The object type, which is always `thread.run`. - created_at: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) for when the run was created. - thread_id: - type: string - description: The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run. - assistant_id: - type: string - description: The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run. - status: - type: string - enum: - - queued - - in_progress - - requires_action - - cancelling - - cancelled - - failed - - completed - - incomplete - - expired - description: The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. - required_action: - type: object - properties: - type: - type: string - enum: - - submit_tool_outputs - description: For now, this is always `submit_tool_outputs`. - submit_tool_outputs: - type: object - properties: - tool_calls: - type: array - items: - $ref: '#/components/schemas/OpenAI.RunToolCallObject' - description: A list of the relevant tool calls. - required: - - tool_calls - description: Details on the tool outputs needed for this run to continue. - required: - - type - - submit_tool_outputs - nullable: true - description: Details on the action required to continue the run. Will be `null` if no action is required. - last_error: - type: object - properties: - code: - type: string - enum: - - server_error - - rate_limit_exceeded - - invalid_prompt - description: One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. - message: - type: string - description: A human-readable description of the error. - required: - - code - - message - nullable: true - description: The last error associated with this run. Will be `null` if there are no errors. - expires_at: - type: integer - format: unixtime - nullable: true - description: The Unix timestamp (in seconds) for when the run will expire. - started_at: - type: integer - format: unixtime - nullable: true - description: The Unix timestamp (in seconds) for when the run was started. - cancelled_at: - type: integer - format: unixtime - nullable: true - description: The Unix timestamp (in seconds) for when the run was cancelled. - failed_at: - type: integer - format: unixtime - nullable: true - description: The Unix timestamp (in seconds) for when the run failed. - completed_at: - type: integer - format: unixtime - nullable: true - description: The Unix timestamp (in seconds) for when the run was completed. - incomplete_details: - type: object - properties: - reason: - type: string - enum: - - max_completion_tokens - - max_prompt_tokens - description: The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run. - nullable: true - description: Details on why the run is incomplete. Will be `null` if the run is not incomplete. - model: - type: string - description: The model that the [assistant](/docs/api-reference/assistants) used for this run. - instructions: - type: string - description: The instructions that the [assistant](/docs/api-reference/assistants) used for this run. - tools: - type: array - items: - $ref: '#/components/schemas/OpenAI.AssistantToolDefinition' - maxItems: 20 - description: The list of tools that the [assistant](/docs/api-reference/assistants) used for this run. - x-oaiExpandable: true - default: [] - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. - x-oaiTypeLabel: map - usage: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.RunCompletionUsage' - nullable: true - temperature: - type: number - format: float - nullable: true - description: The sampling temperature used for this run. If not set, defaults to 1. - top_p: - type: number - format: float - nullable: true - description: The nucleus sampling value used for this run. If not set, defaults to 1. - max_prompt_tokens: - type: integer - format: int32 - nullable: true - minimum: 256 - description: The maximum number of prompt tokens specified to have been used over the course of the run. - max_completion_tokens: - type: integer - format: int32 - nullable: true - minimum: 256 - description: The maximum number of completion tokens specified to have been used over the course of the run. - truncation_strategy: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.TruncationObject' - nullable: true - tool_choice: - oneOf: - - $ref: '#/components/schemas/AssistantsApiToolChoiceOption' - nullable: true - parallel_tool_calls: - type: boolean - default: true - response_format: - oneOf: - - $ref: '#/components/schemas/AssistantsApiResponseFormatOption' - nullable: true - description: Represents an execution run on a [thread](/docs/api-reference/threads). - OpenAI.RunStepCompletionUsage: - type: object - required: - - completion_tokens - - prompt_tokens - - total_tokens - properties: - completion_tokens: - type: integer - format: int32 - description: Number of completion tokens used over the course of the run step. - prompt_tokens: - type: integer - format: int32 - description: Number of prompt tokens used over the course of the run step. - total_tokens: - type: integer - format: int32 - description: Total number of tokens used (prompt + completion). - description: Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. - OpenAI.RunStepDeltaObject: - type: object - required: - - id - - object - - delta - properties: - id: - type: string - description: The identifier of the run step, which can be referenced in API endpoints. - object: - type: string - enum: - - thread.run.step.delta - description: The object type, which is always `thread.run.step.delta`. - delta: - type: object - properties: - step_details: - allOf: - - $ref: '#/components/schemas/OpenAI.RunStepDeltaStepDetails' - description: The details of the run step. - x-oaiExpandable: true - description: The delta containing the fields that have changed on the run step. - description: Represents a run step delta i.e. any changed fields on a run step during streaming. - OpenAI.RunStepDeltaStepDetails: - type: object - required: - - type - properties: - type: - type: string - description: The discriminated type identifier for the details object. - discriminator: - propertyName: type - mapping: - message_creation: '#/components/schemas/OpenAI.RunStepDeltaStepDetailsMessageCreationObject' - tool_calls: '#/components/schemas/OpenAI.RunStepDeltaStepDetailsToolCallsObject' - OpenAI.RunStepDeltaStepDetailsMessageCreationObject: - type: object - required: - - type - properties: - type: - type: string - enum: - - message_creation - description: Always `message_creation`. - message_creation: - type: object - properties: - message_id: - type: string - description: The ID of the message that was created by this run step. - allOf: - - $ref: '#/components/schemas/OpenAI.RunStepDeltaStepDetails' - description: Details of the message creation by the run step. - OpenAI.RunStepDeltaStepDetailsToolCallsCodeObject: - type: object - required: - - index - - type - properties: - index: - type: integer - format: int32 - description: The index of the tool call in the tool calls array. - id: - type: string - description: The ID of the tool call. - type: - type: string - enum: - - code_interpreter - description: The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - code_interpreter: - type: object - properties: - input: - type: string - description: The input to the Code Interpreter tool call. - outputs: - type: array - items: - $ref: '#/components/schemas/OpenAI.RunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject' - description: The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. - x-oaiExpandable: true - description: The Code Interpreter tool call definition. - allOf: - - $ref: '#/components/schemas/OpenAI.RunStepDeltaStepDetailsToolCallsObjectToolCallsObject' - description: Details of the Code Interpreter tool call the run step was involved in. - OpenAI.RunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject: - type: object - required: - - type - properties: - type: - type: string - description: The discriminated type identifier for the details object. - discriminator: - propertyName: type - mapping: - logs: '#/components/schemas/OpenAI.RunStepDeltaStepDetailsToolCallsCodeOutputLogsObject' - image: '#/components/schemas/OpenAI.RunStepDeltaStepDetailsToolCallsCodeOutputImageObject' - description: Abstractly represents a run step tool call details code interpreter output. - OpenAI.RunStepDeltaStepDetailsToolCallsCodeOutputImageObject: - type: object - required: - - index - - type - properties: - index: - type: integer - format: int32 - description: The index of the output in the outputs array. - type: - type: string - enum: - - image - description: Always `image`. - image: - type: object - properties: - file_id: - type: string - description: The [file](/docs/api-reference/files) ID of the image. - allOf: - - $ref: '#/components/schemas/OpenAI.RunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject' - OpenAI.RunStepDeltaStepDetailsToolCallsCodeOutputLogsObject: - type: object - required: - - index - - type - properties: - index: - type: integer - format: int32 - description: The index of the output in the outputs array. - type: - type: string - enum: - - logs - description: Always `logs`. - logs: - type: string - description: The text output from the Code Interpreter tool call. - allOf: - - $ref: '#/components/schemas/OpenAI.RunStepDeltaStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject' - description: Text output from the Code Interpreter tool call as part of a run step. - OpenAI.RunStepDeltaStepDetailsToolCallsFileSearchObject: - type: object - required: - - index - - type - - file_search + required: + - name properties: - index: - type: integer - format: int32 - description: The index of the tool call in the tool calls array. - id: + description: type: string - description: The ID of the tool call object. - type: + description: A description of what the function does, used by the model to choose when and how to call the function. + name: type: string - enum: - - file_search - description: The type of tool call. This is always going to be `file_search` for this type of tool call. - file_search: - type: object - additionalProperties: - type: string - description: For now, this is always going to be an empty object. - x-oaiTypeLabel: map - allOf: - - $ref: '#/components/schemas/OpenAI.RunStepDeltaStepDetailsToolCallsObjectToolCallsObject' - OpenAI.RunStepDeltaStepDetailsToolCallsFunctionObject: + description: The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. + parameters: + $ref: '#/components/schemas/OpenAI.FunctionParameters' + OpenAI.FunctionParameters: + type: object + additionalProperties: {} + description: |- + The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. + + Omitting `parameters` defines a function with an empty parameter list. + OpenAI.Image: type: object - required: - - index - - type properties: - index: - type: integer - format: int32 - description: The index of the tool call in the tool calls array. - id: + b64_json: type: string - description: The ID of the tool call object. - type: + format: base64 + description: The base64-encoded JSON of the generated image, if `response_format` is `b64_json`. + url: type: string - enum: - - function - description: The type of tool call. This is always going to be `function` for this type of tool call. - function: - type: object - properties: - name: - type: string - description: The name of the function. - arguments: - type: string - description: The arguments passed to the function. - output: - type: string - nullable: true - description: The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. - description: The definition of the function that was called. - allOf: - - $ref: '#/components/schemas/OpenAI.RunStepDeltaStepDetailsToolCallsObjectToolCallsObject' - OpenAI.RunStepDeltaStepDetailsToolCallsObject: + format: uri + description: The URL of the generated image, if `response_format` is `url` (default). + revised_prompt: + type: string + description: The prompt that was used to generate the image, if there was any revision to the prompt. + description: Represents the url or the content of an image generated by the OpenAI API. + OpenAI.ImagesResponse: type: object required: - - type + - created + - data properties: - type: - type: string - enum: - - tool_calls - description: Always `tool_calls`. - tool_calls: + created: + type: integer + format: unixtime + data: type: array items: - $ref: '#/components/schemas/OpenAI.RunStepDeltaStepDetailsToolCallsObjectToolCallsObject' - description: 'An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`.' - x-oaiExpandable: true - allOf: - - $ref: '#/components/schemas/OpenAI.RunStepDeltaStepDetails' - description: Details of the tool call. - OpenAI.RunStepDeltaStepDetailsToolCallsObjectToolCallsObject: + $ref: '#/components/schemas/OpenAI.Image' + OpenAI.MessageContent: type: object - required: - - type - properties: - type: - type: string - description: The discriminated type identifier for the details object. - discriminator: - propertyName: type - mapping: - browser: '#/components/schemas/RunStepDeltaStepDetailsToolCallsBingSearchObject' - code_interpreter: '#/components/schemas/OpenAI.RunStepDeltaStepDetailsToolCallsCodeObject' - file_search: '#/components/schemas/OpenAI.RunStepDeltaStepDetailsToolCallsFileSearchObject' - function: '#/components/schemas/OpenAI.RunStepDeltaStepDetailsToolCallsFunctionObject' - description: Abstractly represents a run step tool call details inner object. - OpenAI.RunStepDetailsMessageCreationObject: + description: Represents a single piece of content in an Assistants API message. + OpenAI.MessageContentImageFileObject: type: object required: - type - - message_creation + - image_file properties: type: type: string enum: - - message_creation - description: Always `message_creation`. - message_creation: + - image_file + description: Always `image_file`. + image_file: type: object properties: - message_id: + file_id: + type: string + description: The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. + detail: type: string - description: The ID of the message that was created by this run step. + enum: + - auto + - low + - high + description: Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. + default: auto required: - - message_id + - file_id allOf: - - $ref: '#/components/schemas/OpenAI.RunStepObjectStepDetails' - description: Details of the message creation by the run step. - OpenAI.RunStepDetailsToolCallsCodeObject: + - $ref: '#/components/schemas/OpenAI.MessageContent' + description: References an image [File](/docs/api-reference/files) in the content of a message. + OpenAI.MessageContentImageUrlObject: type: object required: - - id - type - - code_interpreter + - image_url properties: - id: - type: string - description: The ID of the tool call. type: type: string enum: - - code_interpreter - description: The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - code_interpreter: + - image_url + description: The type of the content part. + image_url: type: object properties: - input: + url: type: string - description: The input to the Code Interpreter tool call. - outputs: - type: array - items: - $ref: '#/components/schemas/OpenAI.RunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject' - description: The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. - x-oaiExpandable: true + format: uri + description: 'The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.' + detail: + type: string + enum: + - auto + - low + - high + description: Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` + default: auto required: - - input - - outputs - description: The Code Interpreter tool call definition. + - url allOf: - - $ref: '#/components/schemas/OpenAI.RunStepDetailsToolCallsObjectToolCallsObject' - description: Details of the Code Interpreter tool call the run step was involved in. - OpenAI.RunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject: - type: object - required: - - type - properties: - type: - type: string - description: The discriminated type identifier for the details object. - discriminator: - propertyName: type - mapping: - logs: '#/components/schemas/OpenAI.RunStepDetailsToolCallsCodeOutputLogsObject' - image: '#/components/schemas/OpenAI.RunStepDetailsToolCallsCodeOutputImageObject' - description: Abstractly represents a run step tool call details code interpreter output. - OpenAI.RunStepDetailsToolCallsCodeOutputImageObject: + - $ref: '#/components/schemas/OpenAI.MessageContent' + description: References an image URL in the content of a message. + OpenAI.MessageContentTextAnnotationsFileCitationObject: type: object required: - type - - image + - text + - file_citation + - start_index + - end_index properties: type: type: string enum: - - image - description: Always `image`. - image: + - file_citation + description: Always `file_citation`. + text: + type: string + description: The text in the message content that needs to be replaced. + file_citation: type: object properties: file_id: type: string - description: The [file](/docs/api-reference/files) ID of the image. + description: The ID of the specific File the citation is from. required: - file_id + start_index: + type: integer + format: int32 + minimum: 0 + end_index: + type: integer + format: int32 + minimum: 0 allOf: - - $ref: '#/components/schemas/OpenAI.RunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject' - OpenAI.RunStepDetailsToolCallsCodeOutputLogsObject: + - $ref: '#/components/schemas/OpenAI.MessageContentTextObjectAnnotation' + description: A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. + OpenAI.MessageContentTextAnnotationsFilePathObject: type: object required: - type - - logs + - text + - file_path + - start_index + - end_index properties: type: type: string enum: - - logs - description: Always `logs`. - logs: - type: string - description: The text output from the Code Interpreter tool call. - allOf: - - $ref: '#/components/schemas/OpenAI.RunStepDetailsToolCallsCodeObjectCodeInterpreterOutputsObject' - description: Text output from the Code Interpreter tool call as part of a run step. - OpenAI.RunStepDetailsToolCallsFileSearchObject: - type: object - required: - - id - - type - - file_search - properties: - id: - type: string - description: The ID of the tool call object. - type: + - file_path + description: Always `file_path`. + text: type: string - enum: - - file_search - description: The type of tool call. This is always going to be `file_search` for this type of tool call. - file_search: + description: The text in the message content that needs to be replaced. + file_path: type: object - additionalProperties: - type: string - description: For now, this is always going to be an empty object. - x-oaiTypeLabel: map + properties: + file_id: + type: string + description: The ID of the file that was generated. + required: + - file_id + start_index: + type: integer + format: int32 + minimum: 0 + end_index: + type: integer + format: int32 + minimum: 0 allOf: - - $ref: '#/components/schemas/OpenAI.RunStepDetailsToolCallsObjectToolCallsObject' - OpenAI.RunStepDetailsToolCallsFunctionObject: + - $ref: '#/components/schemas/OpenAI.MessageContentTextObjectAnnotation' + description: A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + OpenAI.MessageContentTextObject: type: object required: - - id - type - - function + - text properties: - id: - type: string - description: The ID of the tool call object. type: type: string enum: - - function - description: The type of tool call. This is always going to be `function` for this type of tool call. - function: + - text + description: Always `text`. + text: type: object properties: - name: - type: string - description: The name of the function. - arguments: - type: string - description: The arguments passed to the function. - output: + value: type: string - nullable: true - description: The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. + description: The data that makes up the text. + annotations: + type: array + items: + $ref: '#/components/schemas/OpenAI.MessageContentTextObjectAnnotation' + x-oaiExpandable: true required: - - name - - arguments - - output - description: The definition of the function that was called. - allOf: - - $ref: '#/components/schemas/OpenAI.RunStepDetailsToolCallsObjectToolCallsObject' - OpenAI.RunStepDetailsToolCallsObject: - type: object - required: - - type - - tool_calls - properties: - type: - type: string - enum: - - tool_calls - description: Always `tool_calls`. - tool_calls: - type: array - items: - $ref: '#/components/schemas/OpenAI.RunStepDetailsToolCallsObjectToolCallsObject' - description: 'An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`.' - x-oaiExpandable: true + - value + - annotations allOf: - - $ref: '#/components/schemas/OpenAI.RunStepObjectStepDetails' - description: Details of the tool call. - OpenAI.RunStepDetailsToolCallsObjectToolCallsObject: + - $ref: '#/components/schemas/OpenAI.MessageContent' + description: The text content that is part of a message. + OpenAI.MessageContentTextObjectAnnotation: type: object required: - type properties: type: type: string - description: The discriminated type identifier for the details object. + description: The discriminated type identifier for the content item. discriminator: propertyName: type mapping: - browser: '#/components/schemas/RunStepDetailsToolCallsBingSearchObject' - code_interpreter: '#/components/schemas/OpenAI.RunStepDetailsToolCallsCodeObject' - file_search: '#/components/schemas/OpenAI.RunStepDetailsToolCallsFileSearchObject' - function: '#/components/schemas/OpenAI.RunStepDetailsToolCallsFunctionObject' - description: Abstractly represents a run step tool call details inner object. - OpenAI.RunStepObject: + file_citation: '#/components/schemas/OpenAI.MessageContentTextAnnotationsFileCitationObject' + file_path: '#/components/schemas/OpenAI.MessageContentTextAnnotationsFilePathObject' + OpenAI.MessageObject: type: object required: - id - object - created_at - - assistant_id - thread_id - - run_id - - type - status - - step_details - - last_error - - expired_at - - cancelled_at - - failed_at + - incomplete_details - completed_at + - incomplete_at + - role + - content + - assistant_id + - run_id + - attachments - metadata - - usage properties: id: type: string - description: The identifier of the run step, which can be referenced in API endpoints. + description: The identifier, which can be referenced in API endpoints. object: type: string enum: - - thread.run.step - description: The object type, which is always `thread.run.step`. + - thread.message + description: The object type, which is always `thread.message`. created_at: type: integer format: unixtime - description: The Unix timestamp (in seconds) for when the run step was created. - assistant_id: - type: string - description: The ID of the [assistant](/docs/api-reference/assistants) associated with the run step. + description: The Unix timestamp (in seconds) for when the message was created. thread_id: type: string - description: The ID of the [thread](/docs/api-reference/threads) that was run. - run_id: - type: string - description: The ID of the [run](/docs/api-reference/runs) that this run step is a part of. - type: - type: string - enum: - - message_creation - - tool_calls - description: The type of run step, which can be either `message_creation` or `tool_calls`. + description: The [thread](/docs/api-reference/threads) ID that this message belongs to. status: type: string enum: - in_progress - - cancelled - - failed + - incomplete - completed - - expired - description: The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`. - step_details: - allOf: - - $ref: '#/components/schemas/OpenAI.RunStepObjectStepDetails' - description: The details of the run step. - x-oaiExpandable: true - last_error: + description: The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. + incomplete_details: type: object properties: - code: + reason: type: string enum: - - server_error - - rate_limit_exceeded - description: One of `server_error` or `rate_limit_exceeded`. - message: - type: string - description: A human-readable description of the error. + - content_filter + - max_tokens + - run_cancelled + - run_expired + - run_failed + description: The reason the message is incomplete. required: - - code - - message - nullable: true - description: The last error associated with this run step. Will be `null` if there are no errors. - expired_at: - type: integer - format: unixtime - nullable: true - description: The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired. - cancelled_at: - type: integer - format: unixtime + - reason nullable: true - description: The Unix timestamp (in seconds) for when the run step was cancelled. - failed_at: + description: On an incomplete message, details about why the message is incomplete. + completed_at: type: integer format: unixtime nullable: true - description: The Unix timestamp (in seconds) for when the run step failed. - completed_at: + description: The Unix timestamp (in seconds) for when the message was completed. + incomplete_at: type: integer format: unixtime nullable: true - description: The Unix timestamp (in seconds) for when the run step completed. - metadata: - type: object - additionalProperties: - type: string - nullable: true - description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. - x-oaiTypeLabel: map - usage: - type: object - allOf: - - $ref: '#/components/schemas/OpenAI.RunStepCompletionUsage' - nullable: true - description: Represents a step in execution of a run. - OpenAI.RunStepObjectStepDetails: - type: object - required: - - type - properties: - type: - type: string - description: The discriminated type identifier for the details object. - discriminator: - propertyName: type - mapping: - message_creation: '#/components/schemas/OpenAI.RunStepDetailsMessageCreationObject' - tool_calls: '#/components/schemas/OpenAI.RunStepDetailsToolCallsObject' - description: Abstractly represents a run step details object. - OpenAI.RunToolCallObject: - type: object - required: - - id - - type - - function - properties: - id: - type: string - description: The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint. - type: + description: The Unix timestamp (in seconds) for when the message was marked as incomplete. + role: type: string enum: - - function - description: The type of tool call the output is required for. For now, this is always `function`. - function: - type: object - properties: - name: - type: string - description: The name of the function. - arguments: - type: string - description: The arguments that the model expects you to pass to the function. - required: - - name - - arguments - description: The function definition. - description: Tool call objects - OpenAI.SubmitToolOutputsRunRequest: - type: object - required: - - tool_outputs - properties: - tool_outputs: + - user + - assistant + description: The entity that produced the message. One of `user` or `assistant`. + content: type: array items: - type: object - properties: - tool_call_id: - type: string - description: The ID of the tool call in the `required_action` object within the run object the output is being submitted for. - output: - type: string - description: The output of the tool call to be submitted to continue the run. - description: A list of tools for which the outputs are being submitted. - stream: - type: boolean - nullable: true - description: 'If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message.' - OpenAI.ThreadObject: - type: object - required: - - id - - object - - created_at - - tool_resources - - metadata - properties: - id: + $ref: '#/components/schemas/OpenAI.MessageContent' + description: The content of the message in array of text and/or images. + x-oaiExpandable: true + assistant_id: type: string - description: The identifier, which can be referenced in API endpoints. - object: + nullable: true + description: If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message. + run_id: type: string - enum: - - thread - description: The object type, which is always `thread`. - created_at: - type: integer - format: unixtime - description: The Unix timestamp (in seconds) for when the thread was created. - tool_resources: + nullable: true + description: The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. + attachments: type: object - properties: - code_interpreter: - type: object - properties: - file_ids: - type: array - items: - type: string - maxItems: 20 - description: A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. - default: [] - file_search: - type: object - properties: - vector_store_ids: - type: array - items: - type: string - maxItems: 1 - description: The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread. + allOf: + - $ref: '#/components/schemas/MessageObjectAttachments' nullable: true - description: A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + description: A list of files attached to the message, and the tools they were added to. metadata: type: object additionalProperties: @@ -5131,25 +2577,24 @@ components: nullable: true description: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. x-oaiTypeLabel: map - description: Represents a thread that contains [messages](/docs/api-reference/messages). - OpenAI.TruncationObject: + description: Represents a message within a [thread](/docs/api-reference/threads). + OpenAI.MessageRequestContentTextObject: type: object required: - type + - text properties: type: type: string enum: - - auto - - last_messages - description: The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`. - last_messages: - type: integer - format: int32 - nullable: true - minimum: 1 - description: The number of most recent messages from the thread when constructing the context for the run. - description: Controls for how a thread will be truncated prior to the run. Use this to control the intial context window of the run. + - text + description: Always `text`. + text: + type: string + description: Text content to be sent to the model + allOf: + - $ref: '#/components/schemas/OpenAI.MessageContent' + description: The text content that is part of a message. PineconeChatDataSource: type: object required: @@ -5259,257 +2704,6 @@ components: description: The parameter information to control the use of the Pinecone data source. allOf: - $ref: '#/components/schemas/AzureChatDataSource' - RunStepDeltaStepDetailsToolCallsBingSearchObject: - type: object - required: - - index - - type - - browser - properties: - index: - type: integer - format: int32 - description: The index of the tool call in the tool calls array. - id: - type: string - description: The ID of the tool call object. - type: - type: string - enum: - - browser - description: The type of tool call. This is always going to be `browser` for this type of tool call. - browser: - type: object - additionalProperties: {} - description: For now, this is always going to be an empty object. - x-oaiTypeLabel: map - allOf: - - $ref: '#/components/schemas/OpenAI.RunStepDeltaStepDetailsToolCallsObjectToolCallsObject' - RunStepDetailsToolCallsBingSearchObject: - type: object - required: - - id - - type - - browser - properties: - id: - type: string - description: The ID of the tool call object. - type: - type: string - enum: - - browser - description: The type of tool call. This is always going to be `browser` for this type of tool call. - browser: - type: object - additionalProperties: {} - description: For now, this is always going to be an empty object. - x-oaiTypeLabel: map - allOf: - - $ref: '#/components/schemas/AzureRunStepDetailsToolCallsObjectToolCallsObject' - RunStepStreamEvent: - anyOf: - - type: object - properties: - event: - type: string - enum: - - thread.run.step.created - data: - $ref: '#/components/schemas/OpenAI.RunStepObject' - required: - - event - - data - - type: object - properties: - event: - type: string - enum: - - thread.run.step.in_progress - data: - $ref: '#/components/schemas/OpenAI.RunStepObject' - required: - - event - - data - - type: object - properties: - event: - type: string - enum: - - thread.run.step.delta - data: - $ref: '#/components/schemas/OpenAI.RunStepDeltaObject' - required: - - event - - data - - type: object - properties: - event: - type: string - enum: - - thread.run.step.completed - data: - $ref: '#/components/schemas/OpenAI.RunStepObject' - required: - - event - - data - - type: object - properties: - event: - type: string - enum: - - thread.run.step.failed - data: - $ref: '#/components/schemas/OpenAI.RunStepObject' - required: - - event - - data - - type: object - properties: - event: - type: string - enum: - - thread.run.step.cancelled - data: - $ref: '#/components/schemas/OpenAI.RunStepObject' - required: - - event - - data - - type: object - properties: - event: - type: string - enum: - - thread.run.step.expired - data: - $ref: '#/components/schemas/OpenAI.RunStepObject' - required: - - event - - data - RunStreamEvent: - anyOf: - - type: object - properties: - event: - type: string - enum: - - thread.run.created - data: - $ref: '#/components/schemas/OpenAI.RunObject' - required: - - event - - data - - type: object - properties: - event: - type: string - enum: - - thread.run.queued - data: - $ref: '#/components/schemas/OpenAI.RunObject' - required: - - event - - data - - type: object - properties: - event: - type: string - enum: - - thread.run.in_progress - data: - $ref: '#/components/schemas/OpenAI.RunObject' - required: - - event - - data - - type: object - properties: - event: - type: string - enum: - - thread.run.requires_action - data: - $ref: '#/components/schemas/OpenAI.RunObject' - required: - - event - - data - - type: object - properties: - event: - type: string - enum: - - thread.run.completed - data: - $ref: '#/components/schemas/OpenAI.RunObject' - required: - - event - - data - - type: object - properties: - event: - type: string - enum: - - thread.run.incomplete - data: - $ref: '#/components/schemas/OpenAI.RunObject' - required: - - event - - data - - type: object - properties: - event: - type: string - enum: - - thread.run.failed - data: - $ref: '#/components/schemas/OpenAI.RunObject' - required: - - event - - data - - type: object - properties: - event: - type: string - enum: - - thread.run.cancelling - data: - $ref: '#/components/schemas/OpenAI.RunObject' - required: - - event - - data - - type: object - properties: - event: - type: string - enum: - - thread.run.cancelled - data: - $ref: '#/components/schemas/OpenAI.RunObject' - required: - - event - - data - - type: object - properties: - event: - type: string - enum: - - thread.run.expired - data: - $ref: '#/components/schemas/OpenAI.RunObject' - required: - - event - - data - ThreadStreamEvent: - type: object - properties: - event: - type: string - enum: - - thread.created - data: - $ref: '#/components/schemas/OpenAI.ThreadObject' - required: - - event - - data securitySchemes: ApiKeyAuth: type: apiKey diff --git a/.typespec.azure/assistants/client.tsp b/.typespec.azure/assistants/client.tsp index c2585f9ee..5471c7065 100644 --- a/.typespec.azure/assistants/client.tsp +++ b/.typespec.azure/assistants/client.tsp @@ -3,6 +3,3 @@ import "./models.tsp"; using Azure.ClientGenerator.Core; using AzureOpenAI; - -@@access(BingSearchToolDefinition, Access.public); -@@usage(BingSearchToolDefinition, Usage.input); diff --git a/.typespec.azure/assistants/models.tsp b/.typespec.azure/assistants/models.tsp index 1978375cd..4da4bf27f 100644 --- a/.typespec.azure/assistants/models.tsp +++ b/.typespec.azure/assistants/models.tsp @@ -4,17 +4,3 @@ import "../../.typespec/assistants"; using OpenAI; namespace AzureOpenAI; - -model BingSearchToolDefinition extends OpenAI.AssistantToolDefinition { - @doc(""" - The type of tool being defined: `browser` - """) - type: "browser"; - - browser?: { - @doc(""" - The resource ID of the Bing Search resource to use. - """) - bing_resource_id: string; - }; -} diff --git a/.typespec.azure/assistants/operations.tsp b/.typespec.azure/assistants/operations.tsp index 7de65c569..3a2df0910 100644 --- a/.typespec.azure/assistants/operations.tsp +++ b/.typespec.azure/assistants/operations.tsp @@ -9,14 +9,3 @@ using TypeSpec.OpenAPI; using OpenAI; namespace AzureOpenAI; - -@route("/assistants") -interface AzureAssistants { - @post - @operationId("createAssistant") - @tag("Assistants") - @summary("Create an assistant with a model and instructions.") - createAssistant( - @body assistant: CreateAssistantRequest, - ): AssistantObject | ErrorResponse; -} diff --git a/.typespec.azure/messages/client.tsp b/.typespec.azure/messages/client.tsp index a5e600af2..b7a2d6b71 100644 --- a/.typespec.azure/messages/client.tsp +++ b/.typespec.azure/messages/client.tsp @@ -4,11 +4,3 @@ import "./models.tsp"; using Azure.ClientGenerator.Core; namespace AzureOpenAI; - -@@access(MessageContentTextAnnotationsBingSearchUrlCitation, Access.public); -@@usage(MessageContentTextAnnotationsBingSearchUrlCitation, Usage.output); - -@@access(MessageDeltaContentTextAnnotationsBingSearchUrlCitation, - Access.public -); -@@usage(MessageDeltaContentTextAnnotationsBingSearchUrlCitation, Usage.output); diff --git a/.typespec.azure/messages/models.tsp b/.typespec.azure/messages/models.tsp index ba87abef7..4c8d4fa60 100644 --- a/.typespec.azure/messages/models.tsp +++ b/.typespec.azure/messages/models.tsp @@ -3,50 +3,3 @@ import "../../.typespec/messages"; using TypeSpec.OpenAPI; namespace AzureOpenAI; - -model MessageContentTextAnnotationsBingSearchUrlCitation - extends OpenAI.MessageContentTextObjectAnnotation { - @doc(""" - Always `url_citation`. - """) - type: "url_citation"; - - /** The text in the message content that needs to be replaced. */ - text: string; - - url_citation: { - url: url; - title: string; - }; - - @minValue(0) - start_index: int32; - - @minValue(0) - end_index: int32; -} - -model MessageDeltaContentTextAnnotationsBingSearchUrlCitation - extends OpenAI.MessageDeltaTextContentAnnotation { - /** The index of the annotation in the text content part. */ - index: int32; - - @doc(""" - Always `url_citation`. - """) - type: "url_citation"; - - /** The text in the message content that needs to be replaced. */ - text?: string; - - url_citation?: { - url?: url; - title?: string; - }; - - @minValue(0) - start_index?: int32; - - @minValue(0) - end_index?: int32; -} diff --git a/.typespec.azure/runs/client.tsp b/.typespec.azure/runs/client.tsp index 1987b2224..b7a2d6b71 100644 --- a/.typespec.azure/runs/client.tsp +++ b/.typespec.azure/runs/client.tsp @@ -4,20 +4,3 @@ import "./models.tsp"; using Azure.ClientGenerator.Core; namespace AzureOpenAI; - -@@access(OpenAI.RunStepDetailsToolCallsObjectToolCallsObject, Access.public); -@@usage(OpenAI.RunStepDetailsToolCallsObjectToolCallsObject, Usage.output); - -@@access(RunStepDetailsToolCallsBingSearchObject, Access.public); -@@usage(RunStepDetailsToolCallsBingSearchObject, Usage.output); - -@@access(RunStepDeltaStepDetailsToolCallsBingSearchObject, Access.public); -@@usage(RunStepDeltaStepDetailsToolCallsBingSearchObject, Usage.output); - -@@access(RunStepDetailsToolCallsBingSearchObject, Access.public); -@@usage(RunStepDetailsToolCallsBingSearchObject, Usage.output); - -@@access(RunStepDeltaStepDetailsToolCallsBingSearchObject, Access.public); -@@usage(RunStepDeltaStepDetailsToolCallsBingSearchObject, Usage.output); - -@@withoutOmittedProperties(AzureRunStepObject, "step_details"); diff --git a/.typespec.azure/runs/models.tsp b/.typespec.azure/runs/models.tsp index d489f4676..22bd3ba03 100644 --- a/.typespec.azure/runs/models.tsp +++ b/.typespec.azure/runs/models.tsp @@ -3,43 +3,3 @@ import "../../.typespec/runs"; using TypeSpec.OpenAPI; namespace AzureOpenAI; - -model AzureRunStepObject is OpenAI.RunStepObject; - -model AzureRunStepDetailsToolCallsObjectToolCallsObject - extends OpenAI.RunStepDetailsToolCallsObjectToolCallsObject {} - -// Tool customization: apply custom, common base type to union items -model RunStepDetailsToolCallsBingSearchObject - extends AzureRunStepDetailsToolCallsObjectToolCallsObject { - /** The ID of the tool call object. */ - id: string; - - @doc(""" - The type of tool call. This is always going to be `browser` for this type of tool call. - """) - type: "browser"; - - /** For now, this is always going to be an empty object. */ - @extension("x-oaiTypeLabel", "map") - browser: Record; -} - -// Tool customization: apply custom, common base type to union items -model RunStepDeltaStepDetailsToolCallsBingSearchObject - extends OpenAI.RunStepDeltaStepDetailsToolCallsObjectToolCallsObject { - /** The index of the tool call in the tool calls array. */ - index: int32; - - /** The ID of the tool call object. */ - id?: string; - - @doc(""" - The type of tool call. This is always going to be `browser` for this type of tool call. - """) - type: "browser"; - - /** For now, this is always going to be an empty object. */ - @extension("x-oaiTypeLabel", "map") - browser: Record; -} diff --git a/.typespec.azure/runs/operations.tsp b/.typespec.azure/runs/operations.tsp index 000979b4d..2f5c07af8 100644 --- a/.typespec.azure/runs/operations.tsp +++ b/.typespec.azure/runs/operations.tsp @@ -8,178 +8,3 @@ using TypeSpec.Http; using TypeSpec.OpenAPI; namespace AzureOpenAI; - -@route("threads") -interface AzureRuns { - @route("runs") - @post - @operationId("createThreadAndRun") - @tag("Assistants") - @summary("Create a thread and run it in one request.") - createThreadAndRun( - @body requestBody: OpenAI.CreateThreadAndRunRequest, - ): OpenAI.RunObject | OpenAI.AssistantStreamEvent[] | OpenAI.ErrorResponse; - - @route("{thread_id}/runs") - @post - @operationId("createRun") - @tag("Assistants") - @summary("Create a run.") - createRun( - /** The ID of the thread to run. */ - @path thread_id: string, - - @body requestBody: OpenAI.CreateRunRequest, - ): OpenAI.RunObject | OpenAI.AssistantStreamEvent[] | OpenAI.ErrorResponse; - - @route("{thread_id}/runs") - @get - @operationId("listRuns") - @tag("Assistants") - @summary("Returns a list of runs belonging to a thread.") - listRuns( - /** 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?: OpenAI.ListOrder = OpenAI.ListOrder.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, - ): OpenAI.ListRunsResponse | OpenAI.ErrorResponse; - - @route("{thread_id}/runs/{run_id}") - @get - @operationId("getRun") - @tag("Assistants") - @summary("Retrieves a run.") - getRun( - /** The ID of the [thread](/docs/api-reference/threads) that was run. */ - @path thread_id: string, - - /** The ID of the run to retrieve. */ - @path run_id: string, - ): OpenAI.RunObject | OpenAI.ErrorResponse; - - @route("{thread_id}/runs/{run_id}") - @post - @operationId("modifyRun") - @tag("Assistants") - @summary("Modifies a run.") - modifyRun( - /** The ID of the [thread](/docs/api-reference/threads) that was run. */ - @path thread_id: string, - - /** The ID of the run to modify. */ - @path run_id: string, - - @body requestBody: OpenAI.ModifyRunRequest, - ): OpenAI.RunObject | OpenAI.ErrorResponse; - - @route("{thread_id}/runs/{run_id}/cancel") - @post - @operationId("cancelRun") - @tag("Assistants") - @summary("Cancels a run that is `in_progress`.") - cancelRun( - /** The ID of the thread to which this run belongs. */ - @path thread_id: string, - - /** The ID of the run to cancel. */ - @path run_id: string, - ): OpenAI.RunObject | OpenAI.ErrorResponse; - - @route("{thread_id}/runs/{run_id}/submit_tool_outputs") - @post - @operationId("submitToolOutputsToRun") - @tag("Assistants") - @summary(""" - When a run has the `status: "requires_action"` and `required_action.type` is - `submit_tool_outputs`, this endpoint can be used to submit the outputs from the tool calls once - they're all completed. All outputs must be submitted in a single request. - """) - submitToolOutputsToRun( - /** The ID of the [thread](/docs/api-reference/threads) to which this run belongs. */ - @path thread_id: string, - - /** The ID of the run that requires the tool output submission. */ - @path run_id: string, - - @body requestBody: OpenAI.SubmitToolOutputsRunRequest, - ): OpenAI.RunObject | OpenAI.ErrorResponse; - - @route("{thread_id}/runs/{run_id}/steps") - @get - @operationId("listRunSteps") - @tag("Assistants") - @summary("Returns a list of run steps belonging to a run.") - listRunSteps( - /** The ID of the thread the run and run steps belong to. */ - @path thread_id: string, - - /** 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?: OpenAI.ListOrder = OpenAI.ListOrder.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, - ): OpenAI.ListRunStepsResponse | OpenAI.ErrorResponse; - - @route("{thread_id}/runs/{run_id}/steps/{step_id}") - @get - @operationId("getRunStep") - @tag("Assistants") - @summary("Retrieves a run step.") - getRunStep( - /** The ID of the thread to which the run and run step belongs. */ - @path thread_id: string, - - /** The ID of the run to which the run step belongs. */ - @path run_id: string, - - /** The ID of the run step to retrieve. */ - @path step_id: string, - ): AzureRunStepObject | OpenAI.ErrorResponse; -}