diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index b202549fcdd3..7778c282123c 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -13,6 +13,12 @@ "commands": [ "reportgenerator" ] + }, + "Azure.Sdk.Tools.TestProxy": { + "version": "1.0.0-dev.20251022.1", + "commands": [ + "test-proxy" + ] } } } \ No newline at end of file diff --git a/.vscode/cspell.json b/.vscode/cspell.json index 1acd9be1d979..d42077cc91ab 100644 --- a/.vscode/cspell.json +++ b/.vscode/cspell.json @@ -64,12 +64,14 @@ "aadds", "aadkerb", "adls", + "agentic", "aoai", "apos", "azsdk", "blazor", "byok", "centralus", + "clippy", "colls", "contoso", "cpus", @@ -211,17 +213,6 @@ "mobo" ] }, - { - "filename": "**/sdk/ai/**/*.cs", - "words": [ - "ansii", - "atbash", - "azureai", - "bleu", - "gleu", - "ubinary" - ] - }, { "filename": "**/sdk/analysisservices/**/*.cs", "words": [ diff --git a/Directory.Build.props b/Directory.Build.props index 0d1b0a607d34..1253ea8c4d61 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,7 +4,7 @@ $(MSBuildThisFileDirectory)eng $(RepoRoot)src $(RepoRoot)src/SDKs - true + true true true diff --git a/common/Perf/Azure.Test.Perf/Azure.Test.Perf.csproj b/common/Perf/Azure.Test.Perf/Azure.Test.Perf.csproj index 90979d773ed0..ffb4f61f4ed0 100644 --- a/common/Perf/Azure.Test.Perf/Azure.Test.Perf.csproj +++ b/common/Perf/Azure.Test.Perf/Azure.Test.Perf.csproj @@ -1,5 +1,4 @@  - - net8.0 latest + + + $(NoWarn);NU1510 + + true + true + false @@ -144,43 +155,90 @@ $(RepoEngPath)\CodeAnalysis.ruleset - - + - - true - false + + net10.0 + $(LtsTargetFramework);net8.0 - net452;net461;netstandard2.0 - $(LtsTargetFramework);netstandard2.0 - $(LtsTargetFramework) + + $(RequiredRunnableTargetFrameworks);net9.0 + + + + net462 + + + net452;net461;netstandard2.0 + + + + + $(DefaultLegacyTargetFrameworks) + + + $(RequiredRunnableTargetFrameworks);netstandard2.0 + + netstandard2.0 + + + $(LtsTargetFramework) + false - - net9.0;$(LtsTargetFramework); - - $(RequiredTargetFrameworks);net462 - + + + $(AllActiveCurrentTargetFrameworks) + + + $(RequiredTargetFrameworks);$(NetFxTargetFramework) + + $(LtsTargetFramework) - - - - + $(RequiredTargetFrameworks) true true - true - $(DefineConstants);FullNetFx + + + + + Analyzer diff --git a/eng/Directory.Build.Common.targets b/eng/Directory.Build.Common.targets index 2188d0207e57..e70429ff6633 100644 --- a/eng/Directory.Build.Common.targets +++ b/eng/Directory.Build.Common.targets @@ -21,7 +21,7 @@ $([MSBuild]::NormalizeDirectory($(MSBuildProjectDirectory)/../).TrimEnd("/").TrimEnd("\\")) - + true @@ -105,19 +105,6 @@ - - - - - - - - - - - - - @@ -156,12 +143,46 @@ + true AzSdk.reference.targets AzSdk.test.reference.targets + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false diff --git a/eng/Packages.Data.props b/eng/Packages.Data.props index 333c095fc16a..219f64b3900f 100644 --- a/eng/Packages.Data.props +++ b/eng/Packages.Data.props @@ -204,6 +204,12 @@ + + + + + + @@ -213,7 +219,7 @@ - + @@ -371,8 +377,13 @@ - - + + + + + + + @@ -407,6 +418,7 @@ + @@ -475,8 +487,13 @@ - + + diff --git a/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/Azure.Generator.Management.csproj b/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/Azure.Generator.Management.csproj index fd1c78914257..318b0a4af3a2 100644 --- a/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/Azure.Generator.Management.csproj +++ b/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/Azure.Generator.Management.csproj @@ -1,7 +1,6 @@  - net9.0 - net9.0 + $(RequiredTargetFrameworks) Azure.Generator.Management 1.0.0-beta.1 true diff --git a/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/test/Azure.Generator.Mgmt.Tests.csproj b/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/test/Azure.Generator.Mgmt.Tests.csproj index 21ebdb7fca3c..a0857d45f328 100644 --- a/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/test/Azure.Generator.Mgmt.Tests.csproj +++ b/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/test/Azure.Generator.Mgmt.Tests.csproj @@ -1,8 +1,7 @@  - net9.0 - net9.0 + $(RequiredTargetFrameworks) latest CS8002 diff --git a/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/test/Common/Azure.Generator.Management.Tests.Common.csproj b/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/test/Common/Azure.Generator.Management.Tests.Common.csproj index 12e4121bb0d6..70bff0ab352f 100644 --- a/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/test/Common/Azure.Generator.Management.Tests.Common.csproj +++ b/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/test/Common/Azure.Generator.Management.Tests.Common.csproj @@ -1,8 +1,7 @@  - net9.0 - net9.0 + $(RequiredTargetFrameworks) enable enable true diff --git a/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/test/Common/InputFactory.cs b/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/test/Common/InputFactory.cs index ea1c2e43e491..20072d4e354f 100644 --- a/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/test/Common/InputFactory.cs +++ b/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/test/Common/InputFactory.cs @@ -390,6 +390,7 @@ public static InputMethodParameter MethodParameter( /// /// /// + /// /// public static InputModelType Model( string name, diff --git a/eng/packages/http-client-csharp/generator/Azure.Generator.StubLibrary/src/Azure.Generator.StubLibrary.csproj b/eng/packages/http-client-csharp/generator/Azure.Generator.StubLibrary/src/Azure.Generator.StubLibrary.csproj index 68a6518a2325..ddfc06e61d50 100644 --- a/eng/packages/http-client-csharp/generator/Azure.Generator.StubLibrary/src/Azure.Generator.StubLibrary.csproj +++ b/eng/packages/http-client-csharp/generator/Azure.Generator.StubLibrary/src/Azure.Generator.StubLibrary.csproj @@ -3,8 +3,7 @@ StubPlugin 1.0.0-beta.1 - net9.0 - net9.0 + $(RequiredTargetFrameworks) diff --git a/eng/packages/http-client-csharp/generator/Azure.Generator/src/Azure.Generator.csproj b/eng/packages/http-client-csharp/generator/Azure.Generator/src/Azure.Generator.csproj index e64753c49d5d..270f3e9dfdb6 100644 --- a/eng/packages/http-client-csharp/generator/Azure.Generator/src/Azure.Generator.csproj +++ b/eng/packages/http-client-csharp/generator/Azure.Generator/src/Azure.Generator.csproj @@ -1,7 +1,6 @@  - net9.0 - net9.0 + $(RequiredTargetFrameworks) Azure.Generator 1.0.0-beta.1 true diff --git a/eng/packages/http-client-csharp/generator/Azure.Generator/test/Azure.Generator.Tests.csproj b/eng/packages/http-client-csharp/generator/Azure.Generator/test/Azure.Generator.Tests.csproj index 4949e8debd55..737b35181d97 100644 --- a/eng/packages/http-client-csharp/generator/Azure.Generator/test/Azure.Generator.Tests.csproj +++ b/eng/packages/http-client-csharp/generator/Azure.Generator/test/Azure.Generator.Tests.csproj @@ -1,7 +1,6 @@  - net9.0 - net9.0 + $(RequiredTargetFrameworks) latest CS8002 diff --git a/eng/packages/http-client-csharp/generator/Azure.Generator/test/common/Azure.Generator.Tests.Common.csproj b/eng/packages/http-client-csharp/generator/Azure.Generator/test/common/Azure.Generator.Tests.Common.csproj index 9eb32a65c8ef..99150aae8181 100644 --- a/eng/packages/http-client-csharp/generator/Azure.Generator/test/common/Azure.Generator.Tests.Common.csproj +++ b/eng/packages/http-client-csharp/generator/Azure.Generator/test/common/Azure.Generator.Tests.Common.csproj @@ -1,8 +1,7 @@  - net9.0 - net9.0 + $(RequiredTargetFrameworks) enable enable true diff --git a/eng/packages/http-client-csharp/generator/TestProjects/Local.Tests/TestProjects.Local.Tests.csproj b/eng/packages/http-client-csharp/generator/TestProjects/Local.Tests/TestProjects.Local.Tests.csproj index 0a368d7aad63..c4c15e92382f 100644 --- a/eng/packages/http-client-csharp/generator/TestProjects/Local.Tests/TestProjects.Local.Tests.csproj +++ b/eng/packages/http-client-csharp/generator/TestProjects/Local.Tests/TestProjects.Local.Tests.csproj @@ -1,8 +1,8 @@  - net8.0 - net8.0 + $(LtsTargetFramework) + $(RequiredTargetFrameworks) diff --git a/eng/packages/http-client-csharp/generator/TestProjects/Spector.Tests/TestProjects.Spector.Tests.csproj b/eng/packages/http-client-csharp/generator/TestProjects/Spector.Tests/TestProjects.Spector.Tests.csproj index b6c5f00dde49..0da81157771f 100644 --- a/eng/packages/http-client-csharp/generator/TestProjects/Spector.Tests/TestProjects.Spector.Tests.csproj +++ b/eng/packages/http-client-csharp/generator/TestProjects/Spector.Tests/TestProjects.Spector.Tests.csproj @@ -1,8 +1,8 @@  - net9.0 - net9.0 + $(LtsTargetFramework) + $(RequiredTargetFrameworks) diff --git a/eng/packages/plugins/client/Client.Plugin/src/Client.Plugin.csproj b/eng/packages/plugins/client/Client.Plugin/src/Client.Plugin.csproj index 100e7c4a991b..780956a70dbb 100644 --- a/eng/packages/plugins/client/Client.Plugin/src/Client.Plugin.csproj +++ b/eng/packages/plugins/client/Client.Plugin/src/Client.Plugin.csproj @@ -2,8 +2,8 @@ 1.0.0-beta.1 - net9.0 - net9.0 + $(LtsTargetFramework) + $(RequiredTargetFrameworks) true diff --git a/eng/packages/plugins/client/Client.Plugin/test/Client.Plugin.Tests.csproj b/eng/packages/plugins/client/Client.Plugin/test/Client.Plugin.Tests.csproj index 312dd424ba8d..52a5b9823f82 100644 --- a/eng/packages/plugins/client/Client.Plugin/test/Client.Plugin.Tests.csproj +++ b/eng/packages/plugins/client/Client.Plugin/test/Client.Plugin.Tests.csproj @@ -2,8 +2,8 @@ 1.0.0-beta.1 - net9.0 - net9.0 + $(LtsTargetFramework) + $(RequiredTargetFrameworks) diff --git a/eng/pipelines/templates/jobs/smoke-test-matrix.json b/eng/pipelines/templates/jobs/smoke-test-matrix.json index 6b78de2b6fd4..19df02af7c32 100644 --- a/eng/pipelines/templates/jobs/smoke-test-matrix.json +++ b/eng/pipelines/templates/jobs/smoke-test-matrix.json @@ -6,7 +6,7 @@ "OSVmImage": "env:WINDOWSVMIMAGE" } }, - "TestTargetFramework": ["net462", "net8.0", "net9.0"] + "TestTargetFramework": ["net462", "net8.0", "net9.0", "net10.0"] }, "include": [ { @@ -16,7 +16,7 @@ "OSVmImage": "env:LINUXVMIMAGE" } }, - "TestTargetFramework": "net8.0" + "TestTargetFramework": "net10.0" } ] } diff --git a/eng/pipelines/templates/stages/platform-matrix.json b/eng/pipelines/templates/stages/platform-matrix.json index 87d0885b9479..3692d6e5c1a3 100644 --- a/eng/pipelines/templates/stages/platform-matrix.json +++ b/eng/pipelines/templates/stages/platform-matrix.json @@ -25,6 +25,16 @@ "Pool": "env:WINDOWSPOOL", "TestTargetFramework": "net8.0" }, + "Windows2022_NET9.0": { + "OSVmImage": "env:WINDOWSVMIMAGE", + "Pool": "env:WINDOWSPOOL", + "TestTargetFramework": "net9.0" + }, + "Windows2022_NET10.0": { + "OSVmImage": "env:WINDOWSVMIMAGE", + "Pool": "env:WINDOWSPOOL", + "TestTargetFramework": "net10.0" + }, "MacOS_NET8.0": { "OSVmImage": "env:MACVMIMAGE", "Pool": "env:MACPOOL", @@ -34,6 +44,11 @@ "OSVmImage": "env:MACVMIMAGE", "Pool": "env:MACPOOL", "TestTargetFramework": "net9.0" + }, + "MacOS_NET10.0": { + "OSVmImage": "env:MACVMIMAGE", + "Pool": "env:MACPOOL", + "TestTargetFramework": "net10.0" } }, "AdditionalTestArguments": [ @@ -48,10 +63,10 @@ "include": [ { "Agent": { - "Windows2022_NET9.0": { + "Windows2022_NET10.0": { "OSVmImage": "env:WINDOWSVMIMAGE", "Pool": "env:WINDOWSPOOL", - "TestTargetFramework": "net9.0" + "TestTargetFramework": "net10.0" } }, "TestMode": { diff --git a/eng/pipelines/templates/steps/install-dotnet.yml b/eng/pipelines/templates/steps/install-dotnet.yml index cff03bbadf5f..d8338d13e6ee 100644 --- a/eng/pipelines/templates/steps/install-dotnet.yml +++ b/eng/pipelines/templates/steps/install-dotnet.yml @@ -14,6 +14,14 @@ steps: inputs: useGlobalJson: true performMultiLevelLookup: true + - task: UseDotNet@2 # We need .NET 9 for the .NET 9 tests + displayName: 'Use .NET 9.0 SDK' + retryCountOnTaskFailure: 3 + inputs: + # AspNetCore runtime pack can't be installed outside of SDK and we need it for integration tests + packageType: sdk + performMultiLevelLookup: true + version: "9.0.x" - task: UseDotNet@2 # We need .NET 8 for the .NET 8 tests displayName: 'Use .NET 8.0 SDK' retryCountOnTaskFailure: 3 diff --git a/eng/scripts/compatibility/Check-AOT-Compatibility.ps1 b/eng/scripts/compatibility/Check-AOT-Compatibility.ps1 index f7f002c56272..cb642e0b7cb2 100644 --- a/eng/scripts/compatibility/Check-AOT-Compatibility.ps1 +++ b/eng/scripts/compatibility/Check-AOT-Compatibility.ps1 @@ -27,7 +27,7 @@ $csprojContent = @" Exe - net9.0 + net10.0 true true false diff --git a/eng/scripts/dependencies/azure-sdk.deps.csproj b/eng/scripts/dependencies/azure-sdk.deps.csproj index b8d281df0547..f1c1b258aef6 100644 --- a/eng/scripts/dependencies/azure-sdk.deps.csproj +++ b/eng/scripts/dependencies/azure-sdk.deps.csproj @@ -1,6 +1,6 @@  - net9.0 + $(LtsTargetFramework) Exe false - $(LtsTargetFramework) - $(LtsTargetFramework) - + + $(RequiredRunnableTargetFrameworks) Azure.AI.AgentServer.AgentFramework diff --git a/sdk/agentserver/Azure.AI.AgentServer.Core/src/Azure.AI.AgentServer.Core.csproj b/sdk/agentserver/Azure.AI.AgentServer.Core/src/Azure.AI.AgentServer.Core.csproj index 6c75b3e8a52e..03c54e774146 100644 --- a/sdk/agentserver/Azure.AI.AgentServer.Core/src/Azure.AI.AgentServer.Core.csproj +++ b/sdk/agentserver/Azure.AI.AgentServer.Core/src/Azure.AI.AgentServer.Core.csproj @@ -1,9 +1,7 @@  - - $(LtsTargetFramework) - $(LtsTargetFramework) - + + $(RequiredRunnableTargetFrameworks) Azure.AI.AgentServer.Core diff --git a/sdk/ai/.gitignore b/sdk/ai/.gitignore new file mode 100644 index 000000000000..6c1d801e0a29 --- /dev/null +++ b/sdk/ai/.gitignore @@ -0,0 +1,4 @@ +# Runsetting files +Azure.AI.Projects/**/.runsettings +Azure.AI.Agents/**/.runsettings +Azure.AI.Agents.Persistent/**/.runsettings \ No newline at end of file diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/Azure.AI.Projects.OpenAI.sln b/sdk/ai/Azure.AI.Projects.OpenAI/Azure.AI.Projects.OpenAI.sln new file mode 100644 index 000000000000..2106e4233e05 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/Azure.AI.Projects.OpenAI.sln @@ -0,0 +1,30 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36511.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AI.Projects.OpenAI", "src\Azure.AI.Projects.OpenAI.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AI.Projects.OpenAI.Tests", "tests\Azure.AI.Projects.OpenAI.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/CHANGELOG.md b/sdk/ai/Azure.AI.Projects.OpenAI/CHANGELOG.md new file mode 100644 index 000000000000..452d2a169231 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/CHANGELOG.md @@ -0,0 +1,43 @@ +# Release History + +## 1.0.0-beta.4 (2025-11-17) + +## Features Added + +This change updates the baseline `OpenAI` dependency to the latest `2.7.0` official version. For inherited details, please see the [OpenAI .NET changelog](https://github.com/openai/openai-dotnet/tree/main/CHANGELOG.md). + +### Breaking Changes + +**Transitive from upgrade to System.ClientModel 1.8.1**: + +- The extension `StructuredInputs` on `ResponseCreationOptions` will now correctly return a `BinaryData` instance with enclosing quotes included when retrieving an encoded string value + +## 1.0.0-beta.3 (2025-11-15) + +### Bugs Fixed + +- Addressed an issue that caused paginated responses like conversation items to never terminate when large numbers of items are fetched + +## 1.0.0-beta.2 (2025-11-14) + +### Features Added + +- `ProjectResponsesClient.GetProjectResponses()` is added, supporting the ability to list previous responses with optional agent and conversation filters. + +### Breaking Changes (beta) + +- `ProjectConversationsClient.GetProjectConversations()` has an updated signature that accepts an `AgentReference` instead of distinct `agentName` and `agentId` parameters, aligned with the new "list responses" operation. + +### Bugs Fixed + +- Addressed a problem where not supplying an options instance to the `ProjectResponsesClient` constructor resulted in fallback to the `https://api.openai.com/v1` endpoint + +## 1.0.0-beta.1 (2025-11-14) + +This is the first release of the `Azure.AI.Projects.OpenAI` library, a new extension package for the official `OpenAI` .NET library that facilitates and simplifies use of Microsoft Foundry extensions to OpenAI APIs. + +### Features Added + +- `Responses` support, including C# 14 extension properties to `OpenAIResponse` and `ResponseCreationOptions`, together with a `ProjectResponsesClient` type (extends official `OpenAIResponseClient`) +- `Files` support, including a `ProjectFilesClient` type (extends official `OpenAIFileClient`) +- Types and functionality in support of `Azure.AI.Projects` OpenAI-based features, including new Microsoft Foundry Agents Service capabilities diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/Directory.Build.props b/sdk/ai/Azure.AI.Projects.OpenAI/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/README.md b/sdk/ai/Azure.AI.Projects.OpenAI/README.md new file mode 100644 index 000000000000..853b68a676b8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/README.md @@ -0,0 +1,810 @@ +# Azure AI Projects OpenAI client library for .NET + +Develop Agents using the Azure AI Foundry platform, leveraging an extensive ecosystem of models, tools, and capabilities from OpenAI, Microsoft, and other LLM providers. + +**Note:** This package can be used to create requests to the _existing_ agents. It was split from Azure.AI.Projects because the create, update, and delete operations on agents are recommended to be used with enhanced privileges. The Projects library provides simplified access to advanced functionality, such as creating and managing Agents, enumerating AI models, working with datasets, managing search indexes, evaluating generative AI performance, and enabling OpenTelemetry tracing. In this tutorial we are showing how to create agents with the specific data mining functionalities provided by tools. + +[Product documentation][product_doc] +| [Samples][samples] +| [API reference documentation][api_ref_docs] +| [Package (NuGet)][nuget] +| [SDK source code][source_code] + +## Table of contents + +- [Getting started](#getting-started) + - [Prerequisites](#prerequisites) + - [Install the package](#install-the-package) + - [Authenticate the client](#authenticate-the-client) +- [Key concepts](#key-concepts) + - [Service API versions](#service-api-versions) + - [Select a service API version](#select-a-service-api-version) +- [Additional concepts](#additional-concepts) +- [Examples] + - [Prompt Agents](#prompt-agents) + - [Agents](#agents) + - [Responses](#responses) + - [Conversations](#conversations) + - [Container App](#container-app) + - [File search](#file-search) + - [Code interpreter](#code-interpreter) + - [Computer use](#computer-use) + - [Function call](#function-call) + - [Web Search](#web-search) +- [Tracing](#tracing) + - [Tracing to Azure Monitor](#tracing-to-azure-monitor) + - [Tracing to Console](#tracing-to-console) +- [Troubleshooting](#troubleshooting) +- [Next steps](#next-steps) +- [Contributing](#contributing) + +## Getting started + +### Prerequisites + +To use Azure AI Agents capabilities, you must have an [Azure subscription](https://azure.microsoft.com/free/dotnet/). This will allow you to create an Azure AI resource and get a connection URL. + +### Install the package + +Install the client library for .NET with [NuGet](https://www.nuget.org/ ): + +```shell +dotnet add package Azure.AI.Projects.OpenAI --prerelease +``` + +> You must have an [Azure subscription](https://azure.microsoft.com/free/dotnet/) and [Cosmos DB account](https://docs.microsoft.com/azure/cosmos-db/account-overview) (SQL API). In order to take advantage of the C# 8.0 syntax, it is recommended that you compile using the [.NET Core SDK](https://dotnet.microsoft.com/download) 3.0 or higher with a [language version](https://docs.microsoft.com/dotnet/csharp/language-reference/configure-language-version#override-a-default) of `latest`. It is also possible to compile with the .NET Core SDK 2.1.x using a language version of `preview`. + +### Authenticate the client + +To be able to create, update and delete Agent, please install `Azure.AI.Projects` and use `AIProjectClient`. It is a good practice to only allow this operation for users with elevated permissions, for example, administrators. + +```C# Snippet:CreateAgentClientDirectlyFromProjectEndpoint +AIProjectClient projectClient = new( + endpoint: new Uri("https://.services.ai.azure.com/api/projects/"), + tokenProvider: new AzureCliCredential()); +AIProjectAgentsOperations agentClient = projectClient.Agents; +``` + +If you're already using an `AIProjectClient` from `Azure.AI.Projects`, you can initialize an `ProjectOpenAIClient` instance directly via an extension method: + +```C# Snippet:CreateAgentClientFromProjectsClient +AIProjectClient projectClient = new( + endpoint: new Uri("https://.services.ai.azure.com/api/projects/"), + tokenProvider: new AzureCliCredential()); +ProjectOpenAIClient agentClient = projectClient.OpenAI; +``` + +For operations based on OpenAI APIs like `/responses`, `/files`, and `/vector_stores`, you can retrieve `OpenAIResponseClient`, `OpenAIFileClient` and `VectorStoreClient` through the appropriate helper methods: + +```C# Snippet:GetOpenAIClientsFromProjects +ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent("AGENT_NAME"); +OpenAIFileClient fileClient = projectClient.OpenAI.GetOpenAIFileClient(); +VectorStoreClient vectorStoreClient = projectClient.OpenAI.GetVectorStoreClient(); +``` + +## Key concepts + +### Service API versions + +When clients send REST requests to the endpoint, one of the query parameters is `api-version`. It allows us to select the API versions supporting different features. Currently supported values for API versions are `2025-11-01` and `2025-11-15-preview` (default). + +#### Select a service API version + +The API version may be set supplying `version` parameter to `AgentClientOptions` constructor as shown in the example code below. + +```C# Snippet:SelectAPIVersion +ProjectOpenAIClientOptions option = new() +{ + ApiVersion = "2025-11-15-preview" +}; +ProjectOpenAIClient projectClient = new( + projectEndpoint: new Uri("https://.services.ai.azure.com/api/projects/"), + tokenProvider: new AzureCliCredential()); +``` + +### Additional concepts +The Azure.AI.Projects.OpenAI framework organized in a way that for each call, requiring the REST API request, there are synchronous and asynchronous counterparts where the letter has the "Async" suffix. For example, the following code demonstrates the creation of a `OpenAIResponse` object. + +Synchronous call: +```C# Snippet:Sample_CreateResponse_Sync +ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForModel(modelDeploymentName); +OpenAIResponse response = responseClient.CreateResponse("What is the size of France in square miles?"); +``` + +Asynchronous call: + +```C# Snippet:Sample_CreateResponse_Async +ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForModel(modelDeploymentName); +OpenAIResponse response = await responseClient.CreateResponseAsync("What is the size of France in square miles?"); +``` + +In the most of code snippets we will show only asynchronous sample for brevity. Please refer individual [samples](https://github.com/Azure/azure-sdk-for-net/tree/feature/ai-foundry/agents-v2/sdk/ai/Azure.AI.Projects.OpenAI/samples) for both synchronous and asynchronous code. + +## Examples + +### Prompt Agents + +#### Agents + +**Note:** Please intall `Azure.AI.Projects` to manipulate Agents. +When creating the Agents we need to supply Agent definitions to its constructor. To create a declarative prompt Agent, use the `PromptAgentDefinition`: + +```C# Snippet:CreateAPromptAgent +string RAW_PROJECT_ENDPOINT = Environment.GetEnvironmentVariable("AZURE_AI_FOUNDRY_PROJECT_ENDPOINT") + ?? throw new InvalidOperationException("Missing environment variable 'AZURE_AI_FOUNDRY_PROJECT_ENDPOINT'"); +string MODEL_DEPLOYMENT = Environment.GetEnvironmentVariable("AZURE_AI_FOUNDRY_MODEL_DEPLOYMENT") + ?? throw new InvalidOperationException("Missing environment variable 'AZURE_AI_FOUNDRY_MODEL_DEPLOYMENT'"); +string AGENT_NAME = Environment.GetEnvironmentVariable("AZURE_AI_FOUNDRY_AGENT_NAME") + ?? throw new InvalidOperationException("Missing environment variable 'AZURE_AI_FOUNDRY_AGENT_NAME'"); + +AIProjectClient projectClient = new(new Uri(RAW_PROJECT_ENDPOINT), new AzureCliCredential()); + +AgentDefinition agentDefinition = new PromptAgentDefinition(MODEL_DEPLOYMENT) +{ + Instructions = "You are a foo bar agent. In EVERY response you give, ALWAYS include both `foo` and `bar` strings somewhere in the response.", +}; + +AgentVersion newAgentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: AGENT_NAME, + options: new(agentDefinition)); +Console.WriteLine($"Created new agent version: {newAgentVersion.Name}"); +``` + +The code above will result in creation of `AgentVersion` object, which is the data object containing Agent's name and version. + +#### Responses + +OpenAI API allows you to get the response without creating an agent by using the response API. In this scenario we first create the response object. + +```C# Snippet:Sample_CreateResponse_Async +ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForModel(modelDeploymentName); +OpenAIResponse response = await responseClient.CreateResponseAsync("What is the size of France in square miles?"); +``` + +After the response was created we need to wait for it to complete. + +```C# Snippet:Sample_WriteOutput_ResponseBasic_Async +Console.WriteLine(response.GetOutputText()); +``` + +Alternatively, we can stream the response. +```C# Snippet:Sample_WriteOutput_ResponseStreaming_Async +await foreach (StreamingResponseUpdate streamResponse in responsesClient.CreateResponseStreamingAsync("What is the size of France in square miles?")) +{ + if (streamResponse is StreamingResponseCreatedUpdate createUpdate) + { + Console.WriteLine($"Stream response created with ID: {createUpdate.Response.Id}"); + } + else if (streamResponse is StreamingResponseOutputTextDeltaUpdate textDelta) + { + Console.WriteLine($"Delta: {textDelta.Delta}"); + } + else if (streamResponse is StreamingResponseOutputTextDoneUpdate textDoneUpdate) + { + Console.WriteLine($"Response done with full message: {textDoneUpdate.Text}"); + } + else if (streamResponse is StreamingResponseErrorUpdate errorUpdate) + { + throw new InvalidOperationException($"The stream has failed with the error: {errorUpdate.Message}"); + } +} +``` + +Responses can be used with the agents. First we need to create an `AgentVersion` object. + +```C# Snippet:CreateAgent_Basic_Async +PromptAgentDefinition agentDefinition = new(model: MODEL_DEPLOYMENT) +{ + Instructions = "You are a physics teacher with a sense of humor.", +}; +AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent", + options: new(agentDefinition) +); +``` + +To associate the Response with the Agent the agent reference needs to be created. It is done by calling `GetProjectResponsesClientForAgent` method. + +```C# Snippet:CreateResponseBasic_Async +var agentReference = new AgentReference(name: agentVersion.Name); +ProjectResponsesClient responseClient = openaiClient.GetProjectResponsesClientForAgent(agentReference); +ResponseCreationOptions responseCreationOptions = new(); +OpenAIResponse response = await responseClient.CreateResponseAsync( + [ResponseItem.CreateUserMessageItem("Write Maxwell's equation in LaTeX format.")], + responseCreationOptions); +Console.WriteLine(response.GetOutputText()); +``` + +Previous Response ID may be used to ask follow up questions. In this case we need to set `PreviousResponseId` property on `ResponseCreationOptions` object. + +```C# Snippet:FollowUp_Basic_Async +responseCreationOptions.PreviousResponseId = response.Id; +response = await responseClient.CreateResponseAsync( + [ResponseItem.CreateUserMessageItem("What was the previous question?")], + responseCreationOptions); +Console.WriteLine(response.GetOutputText()); +``` + +Finally, we can delete Agent. + +```C# Snippet:CleanUp_Basic_Async +await projectClient.Agents.DeleteAgentAsync(agentName: "myAgent"); +``` + +Previously created responses can also be listed, typically to find all responses associated with a particular agent or conversation. + +```C# Snippet:Sample_ListResponses_Async +await foreach (OpenAIResponse response + in projectClient.OpenAI.Responses.GetProjectResponsesAsync(agent: new AgentReference(agentName), conversationId: conversationId)) +{ + Console.WriteLine($"Matching response: {response.Id}"); +} +``` + +#### Conversations + +Conversations may be used to store the history of interaction with the agent. To add the responses to a conversation, +set the conversation parameter while calling `GetProjectResponsesClientForAgent`. + +```C# Snippet:ConversationClient +ResponseCreationOptions responseCreationOptions = new(); +// Optionally, use a conversation to automatically maintain state between calls. +ProjectConversation conversation = await projectClient.OpenAI.Conversations.CreateProjectConversationAsync(); +ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(AGENT_NAME, conversation); +``` + +Conversations may be deleted to clean up the resources. + +```C# Snippet:DeleteConversationClient +await openAIClient.GetConversationClient().DeleteConversationAsync(conversation.Id); +``` + +The conversation may be used to communicate messages to the agent. + +```C# Snippet:ExistingConversations +ProjectConversationCreationOptions conversationOptions = new() +{ + Items = { ResponseItem.CreateSystemMessageItem("Your preferred genre of story today is: horror.") }, + Metadata = { ["foo"] = "bar" }, +}; +ProjectConversation conversation = await projectClient.OpenAI.Conversations.CreateProjectConversationAsync(conversationOptions); + +// +// Add items to an existing conversation to supplement the interaction state +// +string EXISTING_CONVERSATION_ID = conversation.Id; + +_ = await projectClient.OpenAI.Conversations.CreateProjectConversationItemsAsync( + EXISTING_CONVERSATION_ID, + [ResponseItem.CreateSystemMessageItem(inputTextContent: "Story theme to use: department of licensing.")]); +// +// Use the agent and conversation in a response +// +ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(AGENT_NAME); +ResponseCreationOptions responseCreationOptions = new() +{ + AgentConversationId = EXISTING_CONVERSATION_ID, +}; + +List items = [ResponseItem.CreateUserMessageItem("Tell me a one-line story.")]; +OpenAIResponse response = await responseClient.CreateResponseAsync(items, responseCreationOptions); +``` + +### Container App + +[Azure Container App](https://learn.microsoft.com/azure/container-apps/ai-integration) may act as an agent if it implements the OpenAI-like protocol. Azure.AI.Projects.OpenAI allow you to interact with these applications as with regular agents. The main difference is that in this case agent needs to be created with `ContainerAppAgentDefinition`. This agent can be used in responses API as a regular agent. + +```C# Snippet:Sample_CreateContainerApp_ContainerApp_Async +AgentVersion containerAgentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "containerAgent", + options: new(new ContainerApplicationAgentDefinition( + containerProtocolVersions: [new ProtocolVersionRecord(protocol: AgentCommunicationMethod.Responses, version: "1")], + containerAppResourceId: containerAppResourceId, + ingressSubdomainSuffix: ingressSubdomainSuffix))); +``` + +### File search + +If Agents are provided with `FileSearchTool`, they can give the responses based on the information from the uploaded file(s). +Here are the steps needed to implement the file search. Upload the file: + +```C# Snippet:Sample_UploadFile_FileSearch_Async +string filePath = "sample_file_for_upload.txt"; +File.WriteAllText( + path: filePath, + contents: "The word 'apple' uses the code 442345, while the word 'banana' uses the code 673457."); +OpenAIFileClient fileClient = projectClient.OpenAI.GetOpenAIFileClient(); +OpenAIFile uploadedFile = await fileClient.UploadFileAsync(filePath: filePath, purpose: FileUploadPurpose.Assistants); +File.Delete(filePath); +``` + +Add it to `VectorStore`: + +```C# Snippet:Sample_CreateVectorStore_FileSearch_Async +VectorStoreClient vctStoreClient = projectClient.OpenAI.GetVectorStoreClient(); +VectorStoreCreationOptions options = new() +{ + Name = "MySampleStore", + FileIds = { uploadedFile.Id } +}; +VectorStore vectorStore = await vctStoreClient.CreateVectorStoreAsync(options); +``` + +Finally, create the tool, aware of the vector store and add it to the Agent. + +```C# Snippet:Sample_CreateAgent_FileSearch_Async +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a helpful agent that can help fetch data from files you know about.", + Tools = { ResponseTool.CreateFileSearchTool(vectorStoreIds: [vectorStore.Id]), } +}; +AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent", + options: new(agentDefinition)); +``` + +### Code interpreter + +The `CodeInterpreterTool` allows Agents to run the code in the container. Here are the steps needed to run Code interpreter. +Create an Agent: + +```C# Snippet:Sample_CreateAgent_CodeInterpreter_Async +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a personal math tutor. When asked a math question, write and run code using the python tool to answer the question.", + Tools = { + ResponseTool.CreateCodeInterpreterTool( + new CodeInterpreterToolContainer( + CodeInterpreterToolContainerConfiguration.CreateAutomaticContainerConfiguration([]) + ) + ), + } +}; +AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent", + options: new(agentDefinition)); +``` + +Now we can ask the agent a question, which requires running python code in the container. + +```C# Snippet:Sample_CreateResponse_CodeInterpreter_Async +AgentReference agentReference = new(name: agentVersion.Name, version: agentVersion.Version); +ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentReference); + +OpenAIResponse response = await responseClient.CreateResponseAsync("I need to solve the equation sin(x) + x^2 = 42"); +``` + +### Computer use + +`ComputerTool` allows Agents to assist customer in computer related tasks. Its constructor is provided with description of an operation system and screen resolution. + +```C# Snippet:Sample_CreateAgent_ComputerUse_Async +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a computer automation assistant.\n\n" + + "Be direct and efficient. When you reach the search results page, read and describe the actual search result titles and descriptions you can see.", + Tools = { + ResponseTool.CreateComputerTool( + environment: new ComputerToolEnvironment("windows"), + displayWidth: 1026, + displayHeight: 769 + ), + } +}; +AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent", + options: new(agentDefinition) +); +``` + +Users can create a message to the Agent, which contains text and screenshots. + +```C# Snippet:Sample_CreateResponse_ComputerUse_Async +ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name); +ResponseCreationOptions responseOptions = new(); +responseOptions.TruncationMode = ResponseTruncationMode.Auto; +ResponseItem request = ResponseItem.CreateUserMessageItem( + [ + ResponseContentPart.CreateInputTextPart("I need you to help me search for 'OpenAI news'. Please type 'OpenAI news' and submit the search. Once you see search results, the task is complete."), + ResponseContentPart.CreateInputImagePart(imageBytes: screenshots["browser_search"], imageBytesMediaType: "image/png", imageDetailLevel: ResponseImageDetailLevel.High) + ] +); +List inputItems = [request]; +bool computerUseCalled = false; +string currentScreenshot = "browser_search"; +int limitIteration = 10; +OpenAIResponse response; +do +{ + response = await CreateResponseAsync( + responseClient, + inputItems, + responseOptions + ); + computerUseCalled = false; + responseOptions.PreviousResponseId = response.Id; + inputItems.Clear(); + foreach (ResponseItem responseItem in response.OutputItems) + { + inputItems.Add(responseItem); + if (responseItem is ComputerCallResponseItem computerCall) + { + currentScreenshot = ProcessComputerUseCall(computerCall, currentScreenshot); + inputItems.Add(ResponseItem.CreateComputerCallOutputItem(callId: computerCall.CallId, output: ComputerCallOutput.CreateScreenshotOutput(screenshotImageBytes: screenshots[currentScreenshot], screenshotImageBytesMediaType: "image/png"))); + computerUseCalled = true; + } + } + limitIteration--; +} while (computerUseCalled && limitIteration > 0); +Console.WriteLine(response.GetOutputText()); +``` + +The Agent in turn can analyze it, and return actions, user need to do, then user sends another screenshot with the actions result. This continues until the task is complete. In our example we have created a simple method, which analyzes Agent's actions and returns the appropriate screenshot name. + +```C# Snippet:Sample_ProcessComputerUseCall_ComputerUse +private static string ProcessComputerUseCall(ComputerCallResponseItem item, string oldScreenshot) +{ + string currentScreenshot = "browser_search"; + switch (item.Action.Kind) + { + case ComputerCallActionKind.Type: + Console.WriteLine($" Typing text \"{item.Action.TypeText}\" - Simulating keyboard input"); + currentScreenshot = "search_typed"; + break; + case ComputerCallActionKind.KeyPress: + HashSet codes = [.. item.Action.KeyPressKeyCodes]; + if (codes.Contains("Return") || codes.Contains("ENTER")) + { + // If we have typed the value to the search field, go to search results. + if (string.Equals(oldScreenshot, "search_typed")) + { + Console.WriteLine(" -> Detected ENTER key press, when search field was populated, displaying results."); + currentScreenshot = "search_results"; + } + else + { + Console.WriteLine(" -> Detected ENTER key press, on results or unpopulated search, do nothing."); + currentScreenshot = oldScreenshot; + } + } + else + { + Console.WriteLine($" Key press: {item.Action.KeyPressKeyCodes.Aggregate("", (agg, next) => agg + "+" + next)} - Simulating key combination"); + } + break; + case ComputerCallActionKind.Click: + Console.WriteLine($" Click at ({item.Action.ClickCoordinates.Value.X}, {item.Action.ClickCoordinates.Value.Y}) - Simulating click on UI element"); + if (string.Equals(oldScreenshot, "search_typed")) + { + Console.WriteLine(" -> Assuming click on Search button when search field was populated, displaying results."); + currentScreenshot = "search_results"; + } + else + { + Console.WriteLine(" -> Assuming click on Search on results or when search was not populated, do nothing."); + currentScreenshot = oldScreenshot; + } + break; + case ComputerCallActionKind.Drag: + string pathStr = item.Action.DragPath.ToArray().Select(p => $"{p.X}, {p.Y}").Aggregate("", (agg, next) => $"{agg} -> {next}"); + Console.WriteLine($" Drag path: {pathStr} - Simulating drag operation"); + break; + case ComputerCallActionKind.Scroll: + Console.WriteLine($" Scroll at ({item.Action.ScrollCoordinates.Value.X}, {item.Action.ScrollCoordinates.Value.Y}) - Simulating scroll action"); + break; + case ComputerCallActionKind.Screenshot: + Console.WriteLine(" Taking screenshot - Capturing current screen state"); + break; + default: + break; + } + Console.WriteLine($" -> Action processed: {item.Action.Kind}"); + + return currentScreenshot; +} +``` + +### Function call. + +To supply Agents with the information from running local functions the `FunctionTool` is used. +In our example we define three toy functions: `GetUserFavoriteCity` that always returns "Seattle, WA" and `GetCityNickname`, which will handle only "Seattle, WA" and will throw exception in response to other city names. The last function `GetWeatherAtLocation` returns the weather in Seattle, WA. + +```C# Snippet:Sample_Functions_Function +/// Example of a function that defines no parameters +/// returns user favorite city. +private static string GetUserFavoriteCity() => "Seattle, WA"; + +/// +/// Example of a function with a single required parameter +/// +/// The location to get nickname for. +/// The city nickname. +/// +private static string GetCityNickname(string location) => location switch +{ + "Seattle, WA" => "The Emerald City", + _ => throw new NotImplementedException(), +}; + +/// +/// Example of a function with one required and one optional, enum parameter +/// +/// Get weather for location. +/// "c" or "f" +/// The weather in selected location. +/// +public static string GetWeatherAtLocation(string location, string temperatureUnit = "f") => location switch +{ + "Seattle, WA" => temperatureUnit == "f" ? "70f" : "21c", + _ => throw new NotImplementedException() +}; +``` + +For each function we need to create `FunctionTool`, which defines function name, description and parameters. + +```C# Snippet:Sample_FunctionTools_Function +public static readonly FunctionTool getUserFavoriteCityTool = ResponseTool.CreateFunctionTool( + functionName: "getUserFavoriteCity", + functionDescription: "Gets the user's favorite city.", + functionParameters: BinaryData.FromString("{}"), + strictModeEnabled: false +); + +public static readonly FunctionTool getCityNicknameTool = ResponseTool.CreateFunctionTool( + functionName: "getCityNickname", + functionDescription: "Gets the nickname of a city, e.g. 'LA' for 'Los Angeles, CA'.", + functionParameters: BinaryData.FromObjectAsJson( + new + { + Type = "object", + Properties = new + { + Location = new + { + Type = "string", + Description = "The city and state, e.g. San Francisco, CA", + }, + }, + Required = new[] { "location" }, + }, + new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase } + ), + strictModeEnabled: false +); + +private static readonly FunctionTool getCurrentWeatherAtLocationTool = ResponseTool.CreateFunctionTool( + functionName: "getCurrentWeatherAtLocation", + functionDescription: "Gets the current weather at a provided location.", + functionParameters: BinaryData.FromObjectAsJson( + new + { + Type = "object", + Properties = new + { + Location = new + { + Type = "string", + Description = "The city and state, e.g. San Francisco, CA", + }, + Unit = new + { + Type = "string", + Enum = new[] { "c", "f" }, + }, + }, + Required = new[] { "location" }, + }, + new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase } + ), + strictModeEnabled: false +); +``` + +We have created the method `GetResolvedToolOutput`. It runs the abovementioned functions and wraps their outputs into `ResponseItem` object. + +```C# Snippet:Sample_Resolver_Function +private static FunctionCallOutputResponseItem GetResolvedToolOutput(FunctionCallResponseItem item) +{ + if (item.FunctionName == getUserFavoriteCityTool.FunctionName) + { + return ResponseItem.CreateFunctionCallOutputItem(item.CallId, GetUserFavoriteCity()); + } + using JsonDocument argumentsJson = JsonDocument.Parse(item.FunctionArguments); + if (item.FunctionName == getCityNicknameTool.FunctionName) + { + string locationArgument = argumentsJson.RootElement.GetProperty("location").GetString(); + return ResponseItem.CreateFunctionCallOutputItem(item.CallId, GetCityNickname(locationArgument)); + } + if (item.FunctionName == getCurrentWeatherAtLocationTool.FunctionName) + { + string locationArgument = argumentsJson.RootElement.GetProperty("location").GetString(); + if (argumentsJson.RootElement.TryGetProperty("unit", out JsonElement unitElement)) + { + string unitArgument = unitElement.GetString(); + return ResponseItem.CreateFunctionCallOutputItem(item.CallId, GetWeatherAtLocation(locationArgument, unitArgument)); + } + return ResponseItem.CreateFunctionCallOutputItem(item.CallId, GetWeatherAtLocation(locationArgument)); + } + return null; +} +``` + +Create Agent with the `FunctionTool`. + +```C# Snippet:Sample_CreateAgent_Function_Async +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a weather bot. Use the provided functions to help answer questions. " + + "Customize your responses to the user's preferences as much as possible and use friendly " + + "nicknames for cities whenever possible.", + Tools = { getUserFavoriteCityTool, getCityNicknameTool, getCurrentWeatherAtLocationTool } +}; +AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent", + options: new(agentDefinition)); +``` + +To supply functions outputs, we will need to obtain responses multiple times. We will define method `CreateAndWaitForResponseAsync` for brevity. + +```C# Snippet:Sample_CheckResponse_Function_Async +public static async Task CreateAndCheckResponseAsync(OpenAIResponseClient responseClient, IEnumerable items) +{ + OpenAIResponse response = await responseClient.CreateResponseAsync( + inputItems: items); + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + return response; +} +``` + +If the local function call is required, the response item will be of `FunctionCallResponseItem` type and will contain the function name needed by the Agent. In this case we will use our helper method `GetResolvedToolOutput` to get the `FunctionCallOutputResponseItem` with function call result. To provide the right answer, we need to supply all the response items to `CreateResponse` or `CreateResponseAsync` call. At the end we will print out the function response. + +```C# Snippet:Sample_CreateResponse_Function_Async +ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name); + +ResponseItem request = ResponseItem.CreateUserMessageItem("What's the weather like in my favorite city?"); +List inputItems = [request]; +bool funcionCalled = false; +OpenAIResponse response; +do +{ + response = await CreateAndCheckResponseAsync( + responseClient, + inputItems); + funcionCalled = false; + foreach (ResponseItem responseItem in response.OutputItems) + { + inputItems.Add(responseItem); + if (responseItem is FunctionCallResponseItem functionToolCall) + { + Console.WriteLine($"Calling {functionToolCall.FunctionName}..."); + inputItems.Add(GetResolvedToolOutput(functionToolCall)); + funcionCalled = true; + } + } +} while (funcionCalled); +Console.WriteLine(response.GetOutputText()); +``` + +### Web Search + +The `WebSearchTool` allows the agent to perform web search. To improve the results we can set up the search location. After the agent was created, it can be used as usual. When needed it will use web search to answer the question. + +```C# Snippet:Sample_CreateAgent_WebSearch_Async +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a helpful assistant that can search the web", + Tools = { ResponseTool.CreateWebSearchTool(userLocation: WebSearchToolLocation.CreateApproximateLocation(country: "GB", city: "London", region: "London")), } +}; +AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent", + options: new(agentDefinition)); +``` + +## Tracing +**Note:** The tracing functionality is currently in preview with limited scope. Only agent creation operations generate dedicated gen_ai traces currently. As a preview feature, the trace structure including spans, attributes, and events may change in future releases. + +You can add an Application Insights Azure resource to your Azure AI Foundry project. See the Tracing tab in your AI Foundry project. If one was enabled, you use the Application Insights connection string, configure your Agents, and observe the full execution path through Azure Monitor. Typically, you might want to start tracing before you create an Agent. + +Tracing requires enabling OpenTelemetry support. One way to do this is to set the `AZURE_EXPERIMENTAL_ENABLE_ACTIVITY_SOURCE` environment variable value to `true`. You can also enable the feature with the following code: +```C# Snippet:EnableActivitySourceToGetAgentTraces +AppContext.SetSwitch("Azure.Experimental.EnableActivitySource", true); +``` + +To enabled content recording, set the `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT` environment variable to `true`. Content in this context refers to chat message content, function call tool related function names, function parameter names and values. Alternatively, you can control content recording with the following code: +```C# Snippet:DisableContentRecordingForAgentTraces +AppContext.SetSwitch("Azure.Experimental.TraceGenAIMessageContent", false); +``` +Set the value to `true` to enable content recording. + +### Tracing to Azure Monitor +First, set the `APPLICATIONINSIGHTS_CONNECTION_STRING` environment variable to point to your Azure Monitor resource. You can also retrieve the connection string programmatically using the Azure AI Projects client library (Azure.AI.Projects) by calling the `Telemetry.GetApplicationInsightsConnectionString()` method on the `AIProjectClient` class. + +For tracing to Azure Monitor from your application, the preferred option is to use Azure.Monitor.OpenTelemetry.AspNetCore. Install the package with [NuGet](https://www.nuget.org/ ): +```shell +dotnet add package Azure.Monitor.OpenTelemetry.AspNetCore +``` + +More information about using the Azure.Monitor.OpenTelemetry.AspNetCore package can be found [here](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/README.md ). + +Another option is to use Azure.Monitor.OpenTelemetry.Exporter package. Install the package with [NuGet](https://www.nuget.org/ ) +```shell +dotnet add package Azure.Monitor.OpenTelemetry.Exporter +``` + +Here is an example how to set up tracing to Azure monitor using Azure.Monitor.OpenTelemetry.Exporter: +```C# Snippet:AgentTelemetrySetupTracingToAzureMonitor +var tracerProvider = Sdk.CreateTracerProviderBuilder() + .AddSource("Azure.AI.Projects.Persistent.*") + .SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("AgentTracingSample")) + .AddAzureMonitorTraceExporter().Build(); +``` + +### Tracing to Console + +For tracing to console from your application, install the OpenTelemetry.Exporter.Console with [NuGet](https://www.nuget.org/ ): + +```shell +dotnet add package OpenTelemetry.Exporter.Console +``` + + +Here is an example how to set up tracing to console: +```C# Snippet:AgentTelemetrySetupTracingToConsole +var tracerProvider = Sdk.CreateTracerProviderBuilder() + .AddSource("Azure.AI.Projects.Persistent.*") // Add the required sources name + .SetResourceBuilder(OpenTelemetry.Resources.ResourceBuilder.CreateDefault().AddService("AgentTracingSample")) + .AddConsoleExporter() // Export traces to the console + .Build(); +``` + +## Troubleshooting + +Any operation that fails will throw a [ClientResultException][ClientResultException]. The exception's `Status` will hold the HTTP response status code. The exception's `Message` contains a detailed message that may be helpful in diagnosing the issue: + +```C# Snippet:ErrorHandling +try +{ + AgentVersion agent = await projectClient.Agents.GetAgentVersionAsync( + agentName: "agent_which_dies_not_exist", agentVersion: "1"); +} +catch (ClientResultException e) when (e.Status == 404) +{ + Console.WriteLine($"Exception status code: {e.Status}"); + Console.WriteLine($"Exception message: {e.Message}"); +} +``` + +To further diagnose and troubleshoot issues, you can enable logging following the [Azure SDK logging documentation](https://learn.microsoft.com/dotnet/azure/sdk/logging). This allows you to capture additional insights into request and response details, which can be particularly helpful when diagnosing complex issues. + +## Next steps + +Beyond the introductory scenarios discussed, the AI Agents client library offers support for additional scenarios to help take advantage of the full feature set of the AI services. To help explore some of these scenarios, the AI Agents client library offers a set of samples to serve as an illustration for common scenarios. Please see the [Samples](https://github.com/Azure/azure-sdk-for-net/tree/feature/ai-foundry/agents-v2/sdk/ai/Azure.AI.Projects.OpenAI/samples) + +## Contributing + +See the [Azure SDK CONTRIBUTING.md][aiprojects_contrib] for details on building, testing, and contributing to this library. + + +[style-guide-msft]: https://docs.microsoft.com/style-guide/capitalization +[style-guide-cloud]: https://aka.ms/azsdk/cloud-style-guide + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-net/sdk/ai/Azure.AI.Projects.OpenAI/README.png) + + +[ClientResultException]: https://learn.microsoft.com/dotnet/api/system.clientmodel.clientresultexception + +[samples]: https://github.com/Azure/azure-sdk-for-net/tree/feature/ai-foundry/agents-v2/sdk/ai/Azure.AI.Projects.OpenAI/samples + +[api_ref_docs]: https://learn.microsoft.com/dotnet/api/overview/azure/ai.agents.persistent-readme + +[nuget]: https://dev.azure.com/azure-sdk/public/_artifacts/feed/azure-sdk-for-net/NuGet/Azure.AI.Projects.OpenAI + +[source_code]: https://github.com/Azure/azure-sdk-for-net/tree/feature/ai-foundry/agents-v2/sdk/ai/Azure.AI.Projects.OpenAI +[product_doc]: https://learn.microsoft.com/azure/ai-studio/ +[azure_identity]: https://learn.microsoft.com/dotnet/api/overview/azure/identity-readme?view=azure-dotnet +[azure_identity_dac]: https://learn.microsoft.com/dotnet/api/azure.identity.defaultazurecredential?view=azure-dotnet +[aiprojects_contrib]: https://github.com/Azure/azure-sdk-for-net/blob/main/CONTRIBUTING.md +[cla]: https://cla.microsoft.com +[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/ +[code_of_conduct_faq]: https://opensource.microsoft.com/codeofconduct/faq/ +[email_opencode]: mailto:opencode@microsoft.com diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/_tsp-location.yaml b/sdk/ai/Azure.AI.Projects.OpenAI/_tsp-location.yaml new file mode 100644 index 000000000000..abade503b4d9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/_tsp-location.yaml @@ -0,0 +1,7 @@ +directory: specification/ai/Azure.AI.Projects.OpenAI +additionalDirectories: + - specification/ai/Azure.AI.Projects +commit: 36a958797ca18009a2008990674e71b0faf12def +repo: Azure/azure-rest-api-specs-pr +emitterPackageJsonPath: eng/http-client-csharp-emitter-package.json +entrypointFile: client.csharp.tsp \ No newline at end of file diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/api/Azure.AI.Projects.OpenAI.net8.0.cs b/sdk/ai/Azure.AI.Projects.OpenAI/api/Azure.AI.Projects.OpenAI.net8.0.cs new file mode 100644 index 000000000000..876ccbc3d7c3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/api/Azure.AI.Projects.OpenAI.net8.0.cs @@ -0,0 +1,1432 @@ +namespace Azure.AI.Projects +{ + public static partial class ClientConnectionProviderExtensions + { + public static Azure.AI.Projects.OpenAI.ProjectOpenAIClient GetProjectOpenAIClient(this System.ClientModel.Primitives.ClientConnectionProvider connectionProvider, Azure.AI.Projects.OpenAI.ProjectOpenAIClientOptions options = null) { throw null; } + public sealed partial class <>E__0 + { + internal <>E__0() { } + public Azure.AI.Projects.OpenAI.ProjectOpenAIClient GetProjectOpenAIClient(Azure.AI.Projects.OpenAI.ProjectOpenAIClientOptions options = null) { throw null; } + } + } +} +namespace Azure.AI.Projects.OpenAI +{ + public partial class A2ATool : Azure.AI.Projects.OpenAI.AgentTool, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public A2ATool(System.Uri baseUri) { } + public string AgentCardPath { get { throw null; } set { } } + public System.Uri BaseUri { get { throw null; } set { } } + public string ProjectConnectionId { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.A2ATool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.A2ATool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct AgentCommunicationMethod : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public AgentCommunicationMethod(string value) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentCommunicationMethod ActivityProtocol { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentCommunicationMethod Responses { get { throw null; } } + public bool Equals(Azure.AI.Projects.OpenAI.AgentCommunicationMethod other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.OpenAI.AgentCommunicationMethod left, Azure.AI.Projects.OpenAI.AgentCommunicationMethod right) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.AgentCommunicationMethod (string value) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.AgentCommunicationMethod? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.OpenAI.AgentCommunicationMethod left, Azure.AI.Projects.OpenAI.AgentCommunicationMethod right) { throw null; } + public override string ToString() { throw null; } + } + public abstract partial class AgentDefinition : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AgentDefinition() { } + public Azure.AI.Projects.OpenAI.ContentFilterConfiguration ContentFilterConfiguration { get { throw null; } set { } } + public static Azure.AI.Projects.OpenAI.ContainerApplicationAgentDefinition CreateContainerApplicationAgentDefinition(System.Collections.Generic.IEnumerable containerProtocolVersions, string containerAppResourceId, string ingressSubdomainSuffix) { throw null; } + public static Azure.AI.Projects.OpenAI.HostedAgentDefinition CreateHostedAgentDefinition(System.Collections.Generic.IEnumerable containerProtocolVersions, string cpuConfiguration, string memoryConfiguration) { throw null; } + public static Azure.AI.Projects.OpenAI.PromptAgentDefinition CreatePromptAgentDefinition(string model) { throw null; } + public static Azure.AI.Projects.OpenAI.WorkflowAgentDefinition CreateWorkflowAgentDefinitionFromYaml(string workflowYamlDocument) { throw null; } + protected virtual Azure.AI.Projects.OpenAI.AgentDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.AgentDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AgentDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AgentDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AgentInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AgentInfo() { } + public string Name { get { throw null; } } + public string Type { get { throw null; } } + public string Version { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.AgentInfo JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.AgentInfo PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AgentInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AgentInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AgentObjectVersions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AgentObjectVersions() { } + public Azure.AI.Projects.OpenAI.AgentVersion Latest { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.AgentObjectVersions JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.AgentObjectVersions PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AgentObjectVersions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AgentObjectVersions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AgentRecord : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AgentRecord() { } + public string Id { get { throw null; } } + public string Name { get { throw null; } } + public Azure.AI.Projects.OpenAI.AgentObjectVersions Versions { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.AgentRecord JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.AgentRecord PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AgentRecord System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AgentRecord System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AgentReference : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AgentReference(string name, string version = null) { } + public string Name { get { throw null; } } + public string Version { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.AgentReference JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static implicit operator Azure.AI.Projects.OpenAI.AgentReference (Azure.AI.Projects.OpenAI.AgentRecord agentRecord) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.AgentReference (Azure.AI.Projects.OpenAI.AgentVersion agentVersion) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.AgentReference (string agentName) { throw null; } + protected virtual Azure.AI.Projects.OpenAI.AgentReference PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AgentReference System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AgentReference System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public abstract partial class AgentResponseItem : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AgentResponseItem() { } + public Azure.AI.Projects.OpenAI.AgentResponseItemSource CreatedBy { get { throw null; } } + public virtual string Id { get { throw null; } } + public OpenAI.Responses.ResponseItem AsOpenAIResponseItem() { throw null; } + public static Azure.AI.Projects.OpenAI.AgentResponseItem CreateStructuredOutputsItem(System.BinaryData output = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentResponseItem CreateWorkflowActionItem(string actionKind, string actionId) { throw null; } + protected virtual Azure.AI.Projects.OpenAI.AgentResponseItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static implicit operator OpenAI.Responses.ResponseItem (Azure.AI.Projects.OpenAI.AgentResponseItem agentResponseItem) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.AgentResponseItem (OpenAI.Responses.ResponseItem responseItem) { throw null; } + protected virtual Azure.AI.Projects.OpenAI.AgentResponseItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AgentResponseItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AgentResponseItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct AgentResponseItemKind : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public AgentResponseItemKind(string value) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind CodeInterpreterCall { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind ComputerCall { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind ComputerCallOutput { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind FileSearchCall { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind FunctionCall { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind FunctionCallOutput { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind ImageGenerationCall { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind ItemReference { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind LocalShellCall { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind LocalShellCallOutput { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind McpApprovalRequest { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind McpApprovalResponse { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind McpCall { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind McpListTools { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind MemorySearchCall { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind Message { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind OauthConsentRequest { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind Reasoning { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind StructuredOutputs { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind WebSearchCall { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind WorkflowAction { get { throw null; } } + public bool Equals(Azure.AI.Projects.OpenAI.AgentResponseItemKind other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.OpenAI.AgentResponseItemKind left, Azure.AI.Projects.OpenAI.AgentResponseItemKind right) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.AgentResponseItemKind (string value) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.AgentResponseItemKind? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.OpenAI.AgentResponseItemKind left, Azure.AI.Projects.OpenAI.AgentResponseItemKind right) { throw null; } + public override string ToString() { throw null; } + } + public partial class AgentResponseItemSource : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AgentResponseItemSource() { } + public Azure.AI.Projects.OpenAI.AgentInfo Agent { get { throw null; } } + public string ResponseId { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.AgentResponseItemSource JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.AgentResponseItemSource PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AgentResponseItemSource System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AgentResponseItemSource System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AgentStructuredOutputsResponseItem : Azure.AI.Projects.OpenAI.AgentResponseItem, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AgentStructuredOutputsResponseItem(System.BinaryData output) { } + public System.BinaryData Output { get { throw null; } } + protected override Azure.AI.Projects.OpenAI.AgentResponseItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentResponseItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AgentStructuredOutputsResponseItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AgentStructuredOutputsResponseItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public abstract partial class AgentTool : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AgentTool() { } + public static OpenAI.Responses.ResponseTool CreateA2ATool(System.Uri baseUri, string agentCardPath = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AzureAISearchAgentTool CreateAzureAISearchTool(Azure.AI.Projects.OpenAI.AzureAISearchToolOptions options = null) { throw null; } + public static Azure.AI.Projects.OpenAI.BingCustomSearchAgentTool CreateBingCustomSearchTool(Azure.AI.Projects.OpenAI.BingCustomSearchToolParameters parameters) { throw null; } + public static Azure.AI.Projects.OpenAI.BingGroundingAgentTool CreateBingGroundingTool(Azure.AI.Projects.OpenAI.BingGroundingSearchToolOptions options) { throw null; } + public static Azure.AI.Projects.OpenAI.BrowserAutomationAgentTool CreateBrowserAutomationTool(Azure.AI.Projects.OpenAI.BrowserAutomationToolParameters parameters) { throw null; } + public static Azure.AI.Projects.OpenAI.LocalShellAgentTool CreateLocalShellTool() { throw null; } + public static Azure.AI.Projects.OpenAI.MicrosoftFabricAgentTool CreateMicrosoftFabricTool(Azure.AI.Projects.OpenAI.FabricDataAgentToolOptions options) { throw null; } + public static Azure.AI.Projects.OpenAI.OpenAPIAgentTool CreateOpenApiTool(Azure.AI.Projects.OpenAI.OpenAPIFunctionDefinition definition) { throw null; } + public static Azure.AI.Projects.OpenAI.SharepointAgentTool CreateSharepointTool(Azure.AI.Projects.OpenAI.SharePointGroundingToolOptions options) { throw null; } + public static Azure.AI.Projects.OpenAI.CaptureStructuredOutputsTool CreateStructuredOutputsTool(Azure.AI.Projects.OpenAI.StructuredOutputDefinition outputs) { throw null; } + protected virtual Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static implicit operator OpenAI.Responses.ResponseTool (Azure.AI.Projects.OpenAI.AgentTool agentTool) { throw null; } + protected virtual Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AgentTool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AgentTool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AgentVersion : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AgentVersion() { } + public System.DateTimeOffset CreatedAt { get { throw null; } } + public Azure.AI.Projects.OpenAI.AgentDefinition Definition { get { throw null; } } + public string Description { get { throw null; } } + public string Id { get { throw null; } } + public System.Collections.Generic.IDictionary Metadata { get { throw null; } } + public string Name { get { throw null; } } + public string Version { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.AgentVersion JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.AgentVersion PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AgentVersion System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AgentVersion System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AgentWorkflowActionResponseItem : Azure.AI.Projects.OpenAI.AgentResponseItem, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AgentWorkflowActionResponseItem() { } + public string ActionId { get { throw null; } } + public string Kind { get { throw null; } } + public string ParentActionId { get { throw null; } } + public string PreviousActionId { get { throw null; } } + public Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus? Status { get { throw null; } } + protected override Azure.AI.Projects.OpenAI.AgentResponseItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentResponseItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AgentWorkflowActionResponseItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AgentWorkflowActionResponseItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct AgentWorkflowActionStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public AgentWorkflowActionStatus(string value) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus Cancelled { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus Completed { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus Failed { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus InProgress { get { throw null; } } + public bool Equals(Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus left, Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus right) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus (string value) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus left, Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus right) { throw null; } + public override string ToString() { throw null; } + } + public static partial class AzureAIAgentsModelFactory + { + } + public partial class AzureAIProjectsOpenAIContext : System.ClientModel.Primitives.ModelReaderWriterContext + { + internal AzureAIProjectsOpenAIContext() { } + public static Azure.AI.Projects.OpenAI.AzureAIProjectsOpenAIContext Default { get { throw null; } } + protected override bool TryGetTypeBuilderCore(System.Type type, out System.ClientModel.Primitives.ModelReaderWriterTypeBuilder builder) { throw null; } + } + public partial class AzureAISearchAgentTool : Azure.AI.Projects.OpenAI.AgentTool, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AzureAISearchAgentTool(Azure.AI.Projects.OpenAI.AzureAISearchToolOptions options) { } + public Azure.AI.Projects.OpenAI.AzureAISearchToolOptions Options { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AzureAISearchAgentTool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AzureAISearchAgentTool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct AzureAISearchQueryType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public AzureAISearchQueryType(string value) { throw null; } + public static Azure.AI.Projects.OpenAI.AzureAISearchQueryType Semantic { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AzureAISearchQueryType Simple { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AzureAISearchQueryType Vector { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AzureAISearchQueryType VectorSemanticHybrid { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AzureAISearchQueryType VectorSimpleHybrid { get { throw null; } } + public bool Equals(Azure.AI.Projects.OpenAI.AzureAISearchQueryType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.OpenAI.AzureAISearchQueryType left, Azure.AI.Projects.OpenAI.AzureAISearchQueryType right) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.AzureAISearchQueryType (string value) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.AzureAISearchQueryType? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.OpenAI.AzureAISearchQueryType left, Azure.AI.Projects.OpenAI.AzureAISearchQueryType right) { throw null; } + public override string ToString() { throw null; } + } + public partial class AzureAISearchToolIndex : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AzureAISearchToolIndex() { } + public string Filter { get { throw null; } set { } } + public string IndexAssetId { get { throw null; } set { } } + public string IndexName { get { throw null; } set { } } + public string ProjectConnectionId { get { throw null; } set { } } + public Azure.AI.Projects.OpenAI.AzureAISearchQueryType? QueryType { get { throw null; } set { } } + public int? TopK { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.AzureAISearchToolIndex JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.AzureAISearchToolIndex PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AzureAISearchToolIndex System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AzureAISearchToolIndex System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AzureAISearchToolOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AzureAISearchToolOptions(System.Collections.Generic.IEnumerable indexes) { } + public System.Collections.Generic.IList Indexes { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.AzureAISearchToolOptions JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.AzureAISearchToolOptions PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AzureAISearchToolOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AzureAISearchToolOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AzureFunctionAgentTool : Azure.AI.Projects.OpenAI.AgentTool, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AzureFunctionAgentTool(Azure.AI.Projects.OpenAI.AzureFunctionDefinition azureFunction) { } + public Azure.AI.Projects.OpenAI.AzureFunctionDefinition AzureFunction { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AzureFunctionAgentTool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AzureFunctionAgentTool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AzureFunctionBinding : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AzureFunctionBinding(Azure.AI.Projects.OpenAI.AzureFunctionStorageQueue storageQueue) { } + public Azure.AI.Projects.OpenAI.AzureFunctionStorageQueue StorageQueue { get { throw null; } set { } } + public string Type { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.AzureFunctionBinding JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.AzureFunctionBinding PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AzureFunctionBinding System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AzureFunctionBinding System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AzureFunctionDefinition : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AzureFunctionDefinition(Azure.AI.Projects.OpenAI.AzureFunctionDefinitionFunction function, Azure.AI.Projects.OpenAI.AzureFunctionBinding inputBinding, Azure.AI.Projects.OpenAI.AzureFunctionBinding outputBinding) { } + public Azure.AI.Projects.OpenAI.AzureFunctionDefinitionFunction Function { get { throw null; } set { } } + public Azure.AI.Projects.OpenAI.AzureFunctionBinding InputBinding { get { throw null; } set { } } + public Azure.AI.Projects.OpenAI.AzureFunctionBinding OutputBinding { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.AzureFunctionDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.AzureFunctionDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AzureFunctionDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AzureFunctionDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AzureFunctionDefinitionFunction : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AzureFunctionDefinitionFunction(string name, System.BinaryData parameters) { } + public string Description { get { throw null; } set { } } + public string Name { get { throw null; } set { } } + public System.BinaryData Parameters { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.AzureFunctionDefinitionFunction JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.AzureFunctionDefinitionFunction PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AzureFunctionDefinitionFunction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AzureFunctionDefinitionFunction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AzureFunctionStorageQueue : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AzureFunctionStorageQueue(string queueServiceEndpoint, string queueName) { } + public string QueueName { get { throw null; } set { } } + public string QueueServiceEndpoint { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.AzureFunctionStorageQueue JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.AzureFunctionStorageQueue PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AzureFunctionStorageQueue System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AzureFunctionStorageQueue System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class BingCustomSearchAgentTool : Azure.AI.Projects.OpenAI.AgentTool, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public BingCustomSearchAgentTool(Azure.AI.Projects.OpenAI.BingCustomSearchToolParameters bingCustomSearchPreview) { } + public Azure.AI.Projects.OpenAI.BingCustomSearchToolParameters BingCustomSearchPreview { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.BingCustomSearchAgentTool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.BingCustomSearchAgentTool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class BingCustomSearchConfiguration : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public BingCustomSearchConfiguration(string projectConnectionId, string instanceName) { } + public long? Count { get { throw null; } set { } } + public string Freshness { get { throw null; } set { } } + public string InstanceName { get { throw null; } set { } } + public string Market { get { throw null; } set { } } + public string ProjectConnectionId { get { throw null; } set { } } + public string SetLang { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.BingCustomSearchConfiguration JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.BingCustomSearchConfiguration PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.BingCustomSearchConfiguration System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.BingCustomSearchConfiguration System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class BingCustomSearchToolParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public BingCustomSearchToolParameters(System.Collections.Generic.IEnumerable searchConfigurations) { } + public System.Collections.Generic.IList SearchConfigurations { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.BingCustomSearchToolParameters JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.BingCustomSearchToolParameters PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.BingCustomSearchToolParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.BingCustomSearchToolParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class BingGroundingAgentTool : Azure.AI.Projects.OpenAI.AgentTool, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public BingGroundingAgentTool(Azure.AI.Projects.OpenAI.BingGroundingSearchToolOptions bingGrounding) { } + public Azure.AI.Projects.OpenAI.BingGroundingSearchToolOptions BingGrounding { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.BingGroundingAgentTool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.BingGroundingAgentTool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class BingGroundingSearchConfiguration : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public BingGroundingSearchConfiguration(string projectConnectionId) { } + public long? Count { get { throw null; } set { } } + public string Freshness { get { throw null; } set { } } + public string Market { get { throw null; } set { } } + public string ProjectConnectionId { get { throw null; } set { } } + public string SetLang { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.BingGroundingSearchConfiguration JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.BingGroundingSearchConfiguration PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.BingGroundingSearchConfiguration System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.BingGroundingSearchConfiguration System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class BingGroundingSearchToolOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public BingGroundingSearchToolOptions(System.Collections.Generic.IEnumerable searchConfigurations) { } + public System.Collections.Generic.IList SearchConfigurations { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.BingGroundingSearchToolOptions JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.BingGroundingSearchToolOptions PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.BingGroundingSearchToolOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.BingGroundingSearchToolOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class BrowserAutomationAgentTool : Azure.AI.Projects.OpenAI.AgentTool, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public BrowserAutomationAgentTool(Azure.AI.Projects.OpenAI.BrowserAutomationToolParameters browserAutomationPreview) { } + public Azure.AI.Projects.OpenAI.BrowserAutomationToolParameters BrowserAutomationPreview { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.BrowserAutomationAgentTool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.BrowserAutomationAgentTool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class BrowserAutomationToolConnectionParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public BrowserAutomationToolConnectionParameters(string projectConnectionId) { } + public string ProjectConnectionId { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.BrowserAutomationToolConnectionParameters JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.BrowserAutomationToolConnectionParameters PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.BrowserAutomationToolConnectionParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.BrowserAutomationToolConnectionParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class BrowserAutomationToolParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public BrowserAutomationToolParameters(Azure.AI.Projects.OpenAI.BrowserAutomationToolConnectionParameters connection) { } + public Azure.AI.Projects.OpenAI.BrowserAutomationToolConnectionParameters Connection { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.BrowserAutomationToolParameters JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.BrowserAutomationToolParameters PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.BrowserAutomationToolParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.BrowserAutomationToolParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class CaptureStructuredOutputsTool : Azure.AI.Projects.OpenAI.AgentTool, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public CaptureStructuredOutputsTool(Azure.AI.Projects.OpenAI.StructuredOutputDefinition outputs) { } + public Azure.AI.Projects.OpenAI.StructuredOutputDefinition Outputs { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.CaptureStructuredOutputsTool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.CaptureStructuredOutputsTool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ChatSummaryMemoryItem : Azure.AI.Projects.OpenAI.MemoryItem, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ChatSummaryMemoryItem(string memoryId, System.DateTimeOffset updatedAt, string scope, string content) { } + protected override Azure.AI.Projects.OpenAI.MemoryItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.MemoryItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.ChatSummaryMemoryItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.ChatSummaryMemoryItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ContainerApplicationAgentDefinition : Azure.AI.Projects.OpenAI.AgentDefinition, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ContainerApplicationAgentDefinition(System.Collections.Generic.IEnumerable containerProtocolVersions, string containerAppResourceId, string ingressSubdomainSuffix) { } + public string ContainerAppResourceId { get { throw null; } set { } } + public System.Collections.Generic.IList ContainerProtocolVersions { get { throw null; } } + public string IngressSubdomainSuffix { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.ContainerApplicationAgentDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.ContainerApplicationAgentDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ContentFilterConfiguration : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ContentFilterConfiguration(string policyName) { } + public string PolicyName { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.ContentFilterConfiguration JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.ContentFilterConfiguration PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.ContentFilterConfiguration System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.ContentFilterConfiguration System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public static partial class ConversationClientExtensions + { + public sealed partial class <>E__0 + { + internal <>E__0() { } + } + } + public partial class ExtraDataDictionary : System.Collections.Generic.ICollection>, System.Collections.Generic.IDictionary, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + { + internal ExtraDataDictionary() { } + public int Count { get { throw null; } } + public bool IsReadOnly { get { throw null; } } + public System.BinaryData this[System.ReadOnlySpan key] { get { throw null; } set { } } + public System.BinaryData this[string key] { get { throw null; } set { } } + public System.Collections.Generic.ICollection Keys { get { throw null; } } + public System.Collections.Generic.ICollection Values { get { throw null; } } + public void Add(System.Collections.Generic.KeyValuePair item) { } + public void Add(string key, System.BinaryData value) { } + public void Add(string key, bool value) { } + public void Add(string key, int value) { } + public void Add(string key, string value) { } + public void Clear() { } + public bool Contains(System.Collections.Generic.KeyValuePair item) { throw null; } + public bool ContainsKey(string key) { throw null; } + public void CopyTo(System.Collections.Generic.KeyValuePair[] array, int arrayIndex) { } + public bool Remove(System.Collections.Generic.KeyValuePair item) { throw null; } + public bool Remove(string key) { throw null; } + public void SetData(System.BinaryData dictionaryJsonBytes) { } + System.Collections.Generic.IEnumerator> System.Collections.Generic.IEnumerable>.GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + public bool TryGetValue(System.ReadOnlySpan key, out System.BinaryData value) { throw null; } + public bool TryGetValue(string key, out System.BinaryData value) { throw null; } + } + public partial class FabricDataAgentToolOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public FabricDataAgentToolOptions() { } + public System.Collections.Generic.IList ProjectConnections { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.FabricDataAgentToolOptions JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.FabricDataAgentToolOptions PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.FabricDataAgentToolOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.FabricDataAgentToolOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class HostedAgentDefinition : Azure.AI.Projects.OpenAI.AgentDefinition, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public HostedAgentDefinition(System.Collections.Generic.IEnumerable containerProtocolVersions, string cpu, string memory) { } + public System.Collections.Generic.IList ContainerProtocolVersions { get { throw null; } } + public string Cpu { get { throw null; } set { } } + public System.Collections.Generic.IDictionary EnvironmentVariables { get { throw null; } } + public string Memory { get { throw null; } set { } } + public System.Collections.Generic.IList Tools { get { throw null; } } + protected override Azure.AI.Projects.OpenAI.AgentDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.HostedAgentDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.HostedAgentDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ImageBasedHostedAgentDefinition : Azure.AI.Projects.OpenAI.HostedAgentDefinition, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ImageBasedHostedAgentDefinition(System.Collections.Generic.IEnumerable containerProtocolVersions, string cpu, string memory, string image) : base (default(System.Collections.Generic.IEnumerable), default(string), default(string)) { } + public string Image { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.ImageBasedHostedAgentDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.ImageBasedHostedAgentDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class LocalShellAgentTool : Azure.AI.Projects.OpenAI.AgentTool, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public LocalShellAgentTool() { } + protected override Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.LocalShellAgentTool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.LocalShellAgentTool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct LocalShellAgentToolCallStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public LocalShellAgentToolCallStatus(string value) { throw null; } + public static Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus Completed { get { throw null; } } + public static Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus Incomplete { get { throw null; } } + public static Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus InProgress { get { throw null; } } + public bool Equals(Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus left, Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus right) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus (string value) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus left, Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus right) { throw null; } + public override string ToString() { throw null; } + } + public partial class LocalShellAgentToolExecutionAction : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public LocalShellAgentToolExecutionAction(System.Collections.Generic.IEnumerable command, System.Collections.Generic.IDictionary env) { } + public System.Collections.Generic.IList Command { get { throw null; } } + public System.Collections.Generic.IDictionary Env { get { throw null; } } + public int? TimeoutMs { get { throw null; } set { } } + public string User { get { throw null; } set { } } + public string WorkingDirectory { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.LocalShellAgentToolExecutionAction JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.LocalShellAgentToolExecutionAction PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.LocalShellAgentToolExecutionAction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.LocalShellAgentToolExecutionAction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class LocalShellToolCallAgentResponseItem : Azure.AI.Projects.OpenAI.AgentResponseItem, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal LocalShellToolCallAgentResponseItem() { } + public Azure.AI.Projects.OpenAI.LocalShellAgentToolExecutionAction Action { get { throw null; } } + public string CallId { get { throw null; } } + public Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus Status { get { throw null; } } + protected override Azure.AI.Projects.OpenAI.AgentResponseItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentResponseItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.LocalShellToolCallAgentResponseItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.LocalShellToolCallAgentResponseItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class LocalShellToolCallOutputAgentResponseItem : Azure.AI.Projects.OpenAI.AgentResponseItem, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal LocalShellToolCallOutputAgentResponseItem() { } + public string Output { get { throw null; } } + public Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus Status { get { throw null; } } + protected override Azure.AI.Projects.OpenAI.AgentResponseItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentResponseItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.LocalShellToolCallOutputAgentResponseItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.LocalShellToolCallOutputAgentResponseItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public abstract partial class MemoryItem : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemoryItem() { } + public string Content { get { throw null; } } + public string MemoryId { get { throw null; } } + public string Scope { get { throw null; } } + public System.DateTimeOffset UpdatedAt { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.MemoryItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.MemoryItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.MemoryItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.MemoryItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemorySearchItem : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MemorySearchItem(Azure.AI.Projects.OpenAI.MemoryItem memoryItem) { } + public Azure.AI.Projects.OpenAI.MemoryItem MemoryItem { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.MemorySearchItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.MemorySearchItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.MemorySearchItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.MemorySearchItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemorySearchTool : Azure.AI.Projects.OpenAI.AgentTool, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MemorySearchTool(string memoryStoreName, string scope) { } + public string MemoryStoreName { get { throw null; } set { } } + public string Scope { get { throw null; } set { } } + public Azure.AI.Projects.OpenAI.MemorySearchToolOptions SearchOptions { get { throw null; } set { } } + public int? UpdateDelay { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.MemorySearchTool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.MemorySearchTool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemorySearchToolCallResponseItem : Azure.AI.Projects.OpenAI.AgentResponseItem, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemorySearchToolCallResponseItem() { } + public System.Collections.Generic.IList Results { get { throw null; } } + public Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus Status { get { throw null; } } + protected override Azure.AI.Projects.OpenAI.AgentResponseItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentResponseItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.MemorySearchToolCallResponseItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.MemorySearchToolCallResponseItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct MemorySearchToolCallStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public MemorySearchToolCallStatus(string value) { throw null; } + public static Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus Completed { get { throw null; } } + public static Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus Failed { get { throw null; } } + public static Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus Incomplete { get { throw null; } } + public static Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus InProgress { get { throw null; } } + public static Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus Searching { get { throw null; } } + public bool Equals(Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus left, Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus right) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus (string value) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus left, Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus right) { throw null; } + public override string ToString() { throw null; } + } + public partial class MemorySearchToolOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MemorySearchToolOptions() { } + public int? MaxMemories { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.MemorySearchToolOptions JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.MemorySearchToolOptions PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.MemorySearchToolOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.MemorySearchToolOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MicrosoftFabricAgentTool : Azure.AI.Projects.OpenAI.AgentTool, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MicrosoftFabricAgentTool(Azure.AI.Projects.OpenAI.FabricDataAgentToolOptions fabricDataagentPreview) { } + public Azure.AI.Projects.OpenAI.FabricDataAgentToolOptions FabricDataagentPreview { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.MicrosoftFabricAgentTool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.MicrosoftFabricAgentTool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class OAuthConsentRequestResponseItem : Azure.AI.Projects.OpenAI.AgentResponseItem, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal OAuthConsentRequestResponseItem() { } + public string ConsentLink { get { throw null; } } + public override string Id { get { throw null; } } + public string ServerLabel { get { throw null; } } + protected override Azure.AI.Projects.OpenAI.AgentResponseItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentResponseItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.OAuthConsentRequestResponseItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.OAuthConsentRequestResponseItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public static partial class OpenAIFileExtensions + { + public static string GetAzureFileStatus(this OpenAI.Files.OpenAIFile file) { throw null; } + } + public static partial class OpenAIResponseExtension + { + public static System.ClientModel.ClientResult CreateResponse(this OpenAI.Responses.OpenAIResponseClient responseClient, Azure.AI.Projects.OpenAI.ProjectConversation conversation, Azure.AI.Projects.OpenAI.AgentReference agentRef, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> CreateResponseAsync(this OpenAI.Responses.OpenAIResponseClient responseClient, Azure.AI.Projects.OpenAI.ProjectConversation conversation, Azure.AI.Projects.OpenAI.AgentReference agentRef, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public static partial class OpenAIResponseExtensions + { + public static Azure.AI.Projects.OpenAI.AgentReference get_Agent(OpenAI.Responses.OpenAIResponse response) { throw null; } + public static string get_AgentConversationId(OpenAI.Responses.OpenAIResponse response) { throw null; } + public sealed partial class <>E__0 + { + internal <>E__0() { } + public Azure.AI.Projects.OpenAI.AgentReference Agent { get { throw null; } } + public string AgentConversationId { get { throw null; } } + } + } + public partial class OpenAPIAgentTool : Azure.AI.Projects.OpenAI.AgentTool, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public OpenAPIAgentTool(Azure.AI.Projects.OpenAI.OpenAPIFunctionDefinition openapi) { } + public Azure.AI.Projects.OpenAI.OpenAPIFunctionDefinition Openapi { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.OpenAPIAgentTool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.OpenAPIAgentTool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class OpenAPIAnonymousAuthenticationDetails : Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public OpenAPIAnonymousAuthenticationDetails() { } + protected override Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.OpenAPIAnonymousAuthenticationDetails System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.OpenAPIAnonymousAuthenticationDetails System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public abstract partial class OpenAPIAuthenticationDetails : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal OpenAPIAuthenticationDetails() { } + protected virtual Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class OpenAPIFunctionDefinition : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public OpenAPIFunctionDefinition(string name, System.BinaryData spec, Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails auth) { } + public Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails Auth { get { throw null; } set { } } + public System.Collections.Generic.IList DefaultParams { get { throw null; } } + public string Description { get { throw null; } set { } } + public System.Collections.Generic.IReadOnlyList Functions { get { throw null; } } + public string Name { get { throw null; } set { } } + public System.BinaryData Spec { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.OpenAPIFunctionDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.OpenAPIFunctionDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.OpenAPIFunctionDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.OpenAPIFunctionDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class OpenAPIFunctionEntry : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public OpenAPIFunctionEntry(string name, System.BinaryData parameters) { } + public string Description { get { throw null; } set { } } + public string Name { get { throw null; } set { } } + public System.BinaryData Parameters { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.OpenAPIFunctionEntry JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.OpenAPIFunctionEntry PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.OpenAPIFunctionEntry System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.OpenAPIFunctionEntry System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class OpenAPIManagedAuthenticationDetails : Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public OpenAPIManagedAuthenticationDetails(Azure.AI.Projects.OpenAI.OpenApiManagedSecurityScheme securityScheme) { } + public Azure.AI.Projects.OpenAI.OpenApiManagedSecurityScheme SecurityScheme { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.OpenAPIManagedAuthenticationDetails System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.OpenAPIManagedAuthenticationDetails System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class OpenApiManagedSecurityScheme : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public OpenApiManagedSecurityScheme(string audience) { } + public string Audience { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.OpenApiManagedSecurityScheme JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.OpenApiManagedSecurityScheme PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.OpenApiManagedSecurityScheme System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.OpenApiManagedSecurityScheme System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class OpenAPIProjectConnectionAuthenticationDetails : Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public OpenAPIProjectConnectionAuthenticationDetails(Azure.AI.Projects.OpenAI.OpenAPIProjectConnectionSecurityScheme securityScheme) { } + public Azure.AI.Projects.OpenAI.OpenAPIProjectConnectionSecurityScheme SecurityScheme { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.OpenAPIProjectConnectionAuthenticationDetails System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.OpenAPIProjectConnectionAuthenticationDetails System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class OpenAPIProjectConnectionSecurityScheme : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public OpenAPIProjectConnectionSecurityScheme(string projectConnectionId) { } + public string ProjectConnectionId { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.OpenAPIProjectConnectionSecurityScheme JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.OpenAPIProjectConnectionSecurityScheme PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.OpenAPIProjectConnectionSecurityScheme System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.OpenAPIProjectConnectionSecurityScheme System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ProjectConversation : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ProjectConversation() { } + public System.DateTimeOffset CreatedAt { get { throw null; } } + public string Id { get { throw null; } } + public System.Collections.Generic.IDictionary Metadata { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.ProjectConversation JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static implicit operator string (Azure.AI.Projects.OpenAI.ProjectConversation conversation) { throw null; } + protected virtual Azure.AI.Projects.OpenAI.ProjectConversation PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.ProjectConversation System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.ProjectConversation System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ProjectConversationCreationOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ProjectConversationCreationOptions() { } + public System.Collections.Generic.IList Items { get { throw null; } } + public System.Collections.Generic.IDictionary Metadata { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.ProjectConversationCreationOptions JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.ProjectConversationCreationOptions PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.ProjectConversationCreationOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.ProjectConversationCreationOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ProjectConversationsClient : OpenAI.Conversations.ConversationClient + { + protected ProjectConversationsClient() { } + public ProjectConversationsClient(System.ClientModel.Primitives.ClientPipeline pipeline, OpenAI.OpenAIClientOptions options) { } + public virtual System.ClientModel.ClientResult CreateProjectConversation(Azure.AI.Projects.OpenAI.ProjectConversationCreationOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateProjectConversationAsync(Azure.AI.Projects.OpenAI.ProjectConversationCreationOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult> CreateProjectConversationItems(string conversationId, System.Collections.Generic.IEnumerable items, System.Collections.Generic.IEnumerable include = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task>> CreateProjectConversationItemsAsync(string conversationId, System.Collections.Generic.IEnumerable items, System.Collections.Generic.IEnumerable include = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult GetProjectConversation(string conversationId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetProjectConversationAsync(string conversationId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult GetProjectConversationItem(string conversationId, string itemId, System.Collections.Generic.IEnumerable include = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetProjectConversationItemAsync(string conversationId, string itemId, System.Collections.Generic.IEnumerable include = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.CollectionResult GetProjectConversationItems(string conversationId, Azure.AI.Projects.OpenAI.AgentResponseItemKind? itemKind = default(Azure.AI.Projects.OpenAI.AgentResponseItemKind?), int? limit = default(int?), string order = null, string after = null, string before = null, System.Collections.Generic.IEnumerable include = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetProjectConversationItemsAsync(string conversationId, Azure.AI.Projects.OpenAI.AgentResponseItemKind? itemKind = default(Azure.AI.Projects.OpenAI.AgentResponseItemKind?), int? limit = default(int?), string order = null, string after = null, string before = null, System.Collections.Generic.IEnumerable include = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.CollectionResult GetProjectConversations(Azure.AI.Projects.OpenAI.AgentReference agent = null, int? limit = default(int?), string order = null, string after = null, string before = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetProjectConversationsAsync(Azure.AI.Projects.OpenAI.AgentReference agent = null, int? limit = default(int?), string order = null, string after = null, string before = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult UpdateProjectConversation(string conversationId, Azure.AI.Projects.OpenAI.ProjectConversationUpdateOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateProjectConversationAsync(string conversationId, Azure.AI.Projects.OpenAI.ProjectConversationUpdateOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class ProjectConversationUpdateOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ProjectConversationUpdateOptions() { } + public System.Collections.Generic.IDictionary Metadata { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.ProjectConversationUpdateOptions JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.ProjectConversationUpdateOptions PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.ProjectConversationUpdateOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.ProjectConversationUpdateOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ProjectFilesClient : OpenAI.Files.OpenAIFileClient + { + protected ProjectFilesClient() { } + } + public partial class ProjectOpenAIClient : OpenAI.OpenAIClient + { + protected ProjectOpenAIClient() { } + public ProjectOpenAIClient(System.ClientModel.Primitives.AuthenticationPolicy authenticationPolicy, Azure.AI.Projects.OpenAI.ProjectOpenAIClientOptions options) { } + protected internal ProjectOpenAIClient(System.ClientModel.Primitives.ClientPipeline pipeline, Azure.AI.Projects.OpenAI.ProjectOpenAIClientOptions options) { } + public ProjectOpenAIClient(System.Uri projectEndpoint, System.ClientModel.AuthenticationTokenProvider tokenProvider, Azure.AI.Projects.OpenAI.ProjectOpenAIClientOptions options = null) { } + public virtual Azure.AI.Projects.OpenAI.ProjectConversationsClient Conversations { get { throw null; } } + public virtual Azure.AI.Projects.OpenAI.ProjectFilesClient Files { get { throw null; } } + public virtual Azure.AI.Projects.OpenAI.ProjectResponsesClient Responses { get { throw null; } } + public virtual Azure.AI.Projects.OpenAI.ProjectVectorStoresClient VectorStores { get { throw null; } } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override OpenAI.Conversations.ConversationClient GetConversationClient() { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override OpenAI.Files.OpenAIFileClient GetOpenAIFileClient() { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override OpenAI.Responses.OpenAIResponseClient GetOpenAIResponseClient(string defaultModel) { throw null; } + public virtual Azure.AI.Projects.OpenAI.ProjectConversationsClient GetProjectConversationsClient() { throw null; } + public virtual Azure.AI.Projects.OpenAI.ProjectFilesClient GetProjectFilesClient() { throw null; } + public virtual Azure.AI.Projects.OpenAI.ProjectResponsesClient GetProjectResponsesClient() { throw null; } + public virtual Azure.AI.Projects.OpenAI.ProjectResponsesClient GetProjectResponsesClientForAgent(Azure.AI.Projects.OpenAI.AgentReference defaultAgent, string defaultConversationId = null) { throw null; } + public virtual Azure.AI.Projects.OpenAI.ProjectResponsesClient GetProjectResponsesClientForModel(string defaultModel, string defaultConversationId = null) { throw null; } + public virtual Azure.AI.Projects.OpenAI.ProjectVectorStoresClient GetProjectVectorStoresClient() { throw null; } + } + public partial class ProjectOpenAIClientOptions : OpenAI.OpenAIClientOptions + { + public ProjectOpenAIClientOptions() { } + public string ApiVersion { get { throw null; } set { } } + } + public partial class ProjectResponsesClient : OpenAI.Responses.OpenAIResponseClient + { + protected ProjectResponsesClient() { } + public ProjectResponsesClient(System.ClientModel.AuthenticationTokenProvider tokenProvider, Azure.AI.Projects.OpenAI.ProjectResponsesClientOptions options) { } + public ProjectResponsesClient(System.ClientModel.AuthenticationTokenProvider tokenProvider, Azure.AI.Projects.OpenAI.ProjectResponsesClientOptions options = null, Azure.AI.Projects.OpenAI.AgentReference defaultAgent = null, string defaultConversationId = null) { } + public ProjectResponsesClient(System.Uri projectEndpoint, System.ClientModel.AuthenticationTokenProvider tokenProvider, Azure.AI.Projects.OpenAI.AgentReference defaultAgent, string defaultConversationId = null, Azure.AI.Projects.OpenAI.ProjectResponsesClientOptions options = null) { } + public ProjectResponsesClient(System.Uri projectEndpoint, System.ClientModel.AuthenticationTokenProvider tokenProvider, Azure.AI.Projects.OpenAI.ProjectResponsesClientOptions options = null) { } + public override System.ClientModel.ClientResult CreateResponse(System.Collections.Generic.IEnumerable inputItems, OpenAI.Responses.ResponseCreationOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public override System.ClientModel.ClientResult CreateResponse(string userInputText, OpenAI.Responses.ResponseCreationOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public override System.Threading.Tasks.Task> CreateResponseAsync(System.Collections.Generic.IEnumerable inputItems, OpenAI.Responses.ResponseCreationOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public override System.Threading.Tasks.Task> CreateResponseAsync(string userInputText, OpenAI.Responses.ResponseCreationOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public override System.ClientModel.CollectionResult CreateResponseStreaming(System.Collections.Generic.IEnumerable inputItems, OpenAI.Responses.ResponseCreationOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public override System.ClientModel.CollectionResult CreateResponseStreaming(string userInputText, OpenAI.Responses.ResponseCreationOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public override System.ClientModel.AsyncCollectionResult CreateResponseStreamingAsync(System.Collections.Generic.IEnumerable inputItems, OpenAI.Responses.ResponseCreationOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public override System.ClientModel.AsyncCollectionResult CreateResponseStreamingAsync(string userInputText, OpenAI.Responses.ResponseCreationOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.CollectionResult GetProjectResponses(Azure.AI.Projects.OpenAI.AgentReference agent = null, string conversationId = null, int? limit = default(int?), string order = null, string after = null, string before = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetProjectResponsesAsync(Azure.AI.Projects.OpenAI.AgentReference agent = null, string conversationId = null, int? limit = default(int?), string order = null, string after = null, string before = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class ProjectResponsesClientOptions : Azure.AI.Projects.OpenAI.ProjectOpenAIClientOptions + { + public ProjectResponsesClientOptions() { } + } + public static partial class ProjectsOpenAIModelFactory + { + public static Azure.AI.Projects.OpenAI.A2ATool A2ATool(System.Uri baseUri = null, string agentCardPath = null, string projectConnectionId = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentDefinition AgentDefinition(string kind = null, Azure.AI.Projects.OpenAI.ContentFilterConfiguration contentFilterConfiguration = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentInfo AgentInfo(string name = null, string version = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentObjectVersions AgentObjectVersions(Azure.AI.Projects.OpenAI.AgentVersion latest = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentRecord AgentRecord(string id = null, string name = null, Azure.AI.Projects.OpenAI.AgentObjectVersions versions = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentReference AgentReference(string name = null, string version = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentResponseItem AgentResponseItem(string type = null, string id = null, Azure.AI.Projects.OpenAI.AgentResponseItemSource createdBy = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentResponseItemSource AgentResponseItemSource(Azure.AI.Projects.OpenAI.AgentInfo agent = null, string responseId = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentStructuredOutputsResponseItem AgentStructuredOutputsResponseItem(string id = null, Azure.AI.Projects.OpenAI.AgentResponseItemSource createdBy = null, System.BinaryData output = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentTool AgentTool(string type = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentVersion AgentVersion(System.Collections.Generic.IDictionary metadata = null, string id = null, string name = null, string version = null, string description = null, System.DateTimeOffset createdAt = default(System.DateTimeOffset), Azure.AI.Projects.OpenAI.AgentDefinition definition = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentWorkflowActionResponseItem AgentWorkflowActionResponseItem(string id = null, Azure.AI.Projects.OpenAI.AgentResponseItemSource createdBy = null, string kind = null, string actionId = null, string parentActionId = null, string previousActionId = null, Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus? status = default(Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus?)) { throw null; } + public static Azure.AI.Projects.OpenAI.AzureAISearchAgentTool AzureAISearchAgentTool(Azure.AI.Projects.OpenAI.AzureAISearchToolOptions options = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AzureAISearchToolIndex AzureAISearchToolIndex(string projectConnectionId = null, string indexName = null, Azure.AI.Projects.OpenAI.AzureAISearchQueryType? queryType = default(Azure.AI.Projects.OpenAI.AzureAISearchQueryType?), int? topK = default(int?), string filter = null, string indexAssetId = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AzureAISearchToolOptions AzureAISearchToolOptions(System.Collections.Generic.IEnumerable indexes = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AzureFunctionAgentTool AzureFunctionAgentTool(Azure.AI.Projects.OpenAI.AzureFunctionDefinition azureFunction = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AzureFunctionBinding AzureFunctionBinding(Azure.AI.Projects.OpenAI.AzureFunctionStorageQueue storageQueue = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AzureFunctionDefinition AzureFunctionDefinition(Azure.AI.Projects.OpenAI.AzureFunctionDefinitionFunction function = null, Azure.AI.Projects.OpenAI.AzureFunctionBinding inputBinding = null, Azure.AI.Projects.OpenAI.AzureFunctionBinding outputBinding = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AzureFunctionDefinitionFunction AzureFunctionDefinitionFunction(string name = null, string description = null, System.BinaryData parameters = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AzureFunctionStorageQueue AzureFunctionStorageQueue(string queueServiceEndpoint = null, string queueName = null) { throw null; } + public static Azure.AI.Projects.OpenAI.BingCustomSearchAgentTool BingCustomSearchAgentTool(Azure.AI.Projects.OpenAI.BingCustomSearchToolParameters bingCustomSearchPreview = null) { throw null; } + public static Azure.AI.Projects.OpenAI.BingCustomSearchConfiguration BingCustomSearchConfiguration(string projectConnectionId = null, string instanceName = null, string market = null, string setLang = null, long? count = default(long?), string freshness = null) { throw null; } + public static Azure.AI.Projects.OpenAI.BingCustomSearchToolParameters BingCustomSearchToolParameters(System.Collections.Generic.IEnumerable searchConfigurations = null) { throw null; } + public static Azure.AI.Projects.OpenAI.BingGroundingAgentTool BingGroundingAgentTool(Azure.AI.Projects.OpenAI.BingGroundingSearchToolOptions bingGrounding = null) { throw null; } + public static Azure.AI.Projects.OpenAI.BingGroundingSearchConfiguration BingGroundingSearchConfiguration(string projectConnectionId = null, string market = null, string setLang = null, long? count = default(long?), string freshness = null) { throw null; } + public static Azure.AI.Projects.OpenAI.BingGroundingSearchToolOptions BingGroundingSearchToolOptions(System.Collections.Generic.IEnumerable searchConfigurations = null) { throw null; } + public static Azure.AI.Projects.OpenAI.BrowserAutomationAgentTool BrowserAutomationAgentTool(Azure.AI.Projects.OpenAI.BrowserAutomationToolParameters browserAutomationPreview = null) { throw null; } + public static Azure.AI.Projects.OpenAI.BrowserAutomationToolConnectionParameters BrowserAutomationToolConnectionParameters(string projectConnectionId = null) { throw null; } + public static Azure.AI.Projects.OpenAI.BrowserAutomationToolParameters BrowserAutomationToolParameters(Azure.AI.Projects.OpenAI.BrowserAutomationToolConnectionParameters connection = null) { throw null; } + public static Azure.AI.Projects.OpenAI.CaptureStructuredOutputsTool CaptureStructuredOutputsTool(Azure.AI.Projects.OpenAI.StructuredOutputDefinition outputs = null) { throw null; } + public static Azure.AI.Projects.OpenAI.ChatSummaryMemoryItem ChatSummaryMemoryItem(string memoryId = null, System.DateTimeOffset updatedAt = default(System.DateTimeOffset), string scope = null, string content = null) { throw null; } + public static Azure.AI.Projects.OpenAI.ContainerApplicationAgentDefinition ContainerApplicationAgentDefinition(Azure.AI.Projects.OpenAI.ContentFilterConfiguration contentFilterConfiguration = null, System.Collections.Generic.IEnumerable containerProtocolVersions = null, string containerAppResourceId = null, string ingressSubdomainSuffix = null) { throw null; } + public static Azure.AI.Projects.OpenAI.ContentFilterConfiguration ContentFilterConfiguration(string policyName = null) { throw null; } + public static Azure.AI.Projects.OpenAI.FabricDataAgentToolOptions FabricDataAgentToolOptions(System.Collections.Generic.IEnumerable projectConnections = null) { throw null; } + public static Azure.AI.Projects.OpenAI.HostedAgentDefinition HostedAgentDefinition(Azure.AI.Projects.OpenAI.ContentFilterConfiguration contentFilterConfiguration = null, System.Collections.Generic.IEnumerable tools = null, System.Collections.Generic.IEnumerable containerProtocolVersions = null, string cpu = null, string memory = null, System.Collections.Generic.IDictionary environmentVariables = null) { throw null; } + public static Azure.AI.Projects.OpenAI.ImageBasedHostedAgentDefinition ImageBasedHostedAgentDefinition(Azure.AI.Projects.OpenAI.ContentFilterConfiguration contentFilterConfiguration = null, System.Collections.Generic.IEnumerable tools = null, System.Collections.Generic.IEnumerable containerProtocolVersions = null, string cpu = null, string memory = null, System.Collections.Generic.IDictionary environmentVariables = null, string image = null) { throw null; } + public static Azure.AI.Projects.OpenAI.LocalShellAgentTool LocalShellAgentTool() { throw null; } + public static Azure.AI.Projects.OpenAI.LocalShellAgentToolExecutionAction LocalShellAgentToolExecutionAction(System.Collections.Generic.IEnumerable command = null, int? timeoutMs = default(int?), string workingDirectory = null, System.Collections.Generic.IDictionary env = null, string user = null) { throw null; } + public static Azure.AI.Projects.OpenAI.LocalShellToolCallAgentResponseItem LocalShellToolCallAgentResponseItem(string id = null, Azure.AI.Projects.OpenAI.AgentResponseItemSource createdBy = null, Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus status = default(Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus), string callId = null, Azure.AI.Projects.OpenAI.LocalShellAgentToolExecutionAction action = null) { throw null; } + public static Azure.AI.Projects.OpenAI.LocalShellToolCallOutputAgentResponseItem LocalShellToolCallOutputAgentResponseItem(string id = null, Azure.AI.Projects.OpenAI.AgentResponseItemSource createdBy = null, Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus status = default(Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus), string output = null) { throw null; } + public static Azure.AI.Projects.OpenAI.MemoryItem MemoryItem(string memoryId = null, System.DateTimeOffset updatedAt = default(System.DateTimeOffset), string scope = null, string content = null, string kind = null) { throw null; } + public static Azure.AI.Projects.OpenAI.MemorySearchItem MemorySearchItem(Azure.AI.Projects.OpenAI.MemoryItem memoryItem = null) { throw null; } + public static Azure.AI.Projects.OpenAI.MemorySearchTool MemorySearchTool(string memoryStoreName = null, string scope = null, Azure.AI.Projects.OpenAI.MemorySearchToolOptions searchOptions = null, int? updateDelay = default(int?)) { throw null; } + public static Azure.AI.Projects.OpenAI.MemorySearchToolCallResponseItem MemorySearchToolCallResponseItem(string id = null, Azure.AI.Projects.OpenAI.AgentResponseItemSource createdBy = null, Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus status = default(Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus), System.Collections.Generic.IEnumerable results = null) { throw null; } + public static Azure.AI.Projects.OpenAI.MemorySearchToolOptions MemorySearchToolOptions(int? maxMemories = default(int?)) { throw null; } + public static Azure.AI.Projects.OpenAI.MicrosoftFabricAgentTool MicrosoftFabricAgentTool(Azure.AI.Projects.OpenAI.FabricDataAgentToolOptions fabricDataagentPreview = null) { throw null; } + public static Azure.AI.Projects.OpenAI.OAuthConsentRequestResponseItem OAuthConsentRequestResponseItem(Azure.AI.Projects.OpenAI.AgentResponseItemSource createdBy = null, string id = null, string consentLink = null, string serverLabel = null) { throw null; } + public static Azure.AI.Projects.OpenAI.OpenAPIAgentTool OpenAPIAgentTool(Azure.AI.Projects.OpenAI.OpenAPIFunctionDefinition openapi = null) { throw null; } + public static Azure.AI.Projects.OpenAI.OpenAPIAnonymousAuthenticationDetails OpenAPIAnonymousAuthenticationDetails() { throw null; } + public static Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails OpenAPIAuthenticationDetails(string type = null) { throw null; } + public static Azure.AI.Projects.OpenAI.OpenAPIFunctionDefinition OpenAPIFunctionDefinition(string name = null, string description = null, System.BinaryData spec = null, Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails auth = null, System.Collections.Generic.IEnumerable defaultParams = null, System.Collections.Generic.IEnumerable functions = null) { throw null; } + public static Azure.AI.Projects.OpenAI.OpenAPIFunctionEntry OpenAPIFunctionEntry(string name = null, string description = null, System.BinaryData parameters = null) { throw null; } + public static Azure.AI.Projects.OpenAI.OpenAPIManagedAuthenticationDetails OpenAPIManagedAuthenticationDetails(Azure.AI.Projects.OpenAI.OpenApiManagedSecurityScheme securityScheme = null) { throw null; } + public static Azure.AI.Projects.OpenAI.OpenApiManagedSecurityScheme OpenApiManagedSecurityScheme(string audience = null) { throw null; } + public static Azure.AI.Projects.OpenAI.OpenAPIProjectConnectionAuthenticationDetails OpenAPIProjectConnectionAuthenticationDetails(Azure.AI.Projects.OpenAI.OpenAPIProjectConnectionSecurityScheme securityScheme = null) { throw null; } + public static Azure.AI.Projects.OpenAI.OpenAPIProjectConnectionSecurityScheme OpenAPIProjectConnectionSecurityScheme(string projectConnectionId = null) { throw null; } + public static Azure.AI.Projects.OpenAI.ProjectConversation ProjectConversation(string id = null, System.DateTimeOffset createdAt = default(System.DateTimeOffset), System.Collections.Generic.IDictionary metadata = null) { throw null; } + public static Azure.AI.Projects.OpenAI.ProjectConversationUpdateOptions ProjectConversationUpdateOptions(System.Collections.Generic.IDictionary metadata = null) { throw null; } + public static Azure.AI.Projects.OpenAI.ProtocolVersionRecord ProtocolVersionRecord(Azure.AI.Projects.OpenAI.AgentCommunicationMethod protocol = default(Azure.AI.Projects.OpenAI.AgentCommunicationMethod), string version = null) { throw null; } + public static Azure.AI.Projects.OpenAI.SharepointAgentTool SharepointAgentTool(Azure.AI.Projects.OpenAI.SharePointGroundingToolOptions sharepointGroundingPreview = null) { throw null; } + public static Azure.AI.Projects.OpenAI.SharePointGroundingToolOptions SharePointGroundingToolOptions(System.Collections.Generic.IEnumerable projectConnections = null) { throw null; } + public static Azure.AI.Projects.OpenAI.StructuredInputDefinition StructuredInputDefinition(string description = null, System.BinaryData defaultValue = null, System.BinaryData schema = null, bool? isRequired = default(bool?)) { throw null; } + public static Azure.AI.Projects.OpenAI.StructuredOutputDefinition StructuredOutputDefinition(string name = null, string description = null, System.BinaryData schema = null, bool? strict = default(bool?)) { throw null; } + public static Azure.AI.Projects.OpenAI.ToolProjectConnection ToolProjectConnection(string projectConnectionId = null) { throw null; } + public static Azure.AI.Projects.OpenAI.WorkflowAgentDefinition WorkflowAgentDefinition(Azure.AI.Projects.OpenAI.ContentFilterConfiguration contentFilterConfiguration = null, string workflowYaml = null) { throw null; } + } + public partial class ProjectVectorStoresClient : OpenAI.VectorStores.VectorStoreClient + { + protected ProjectVectorStoresClient() { } + } + public partial class PromptAgentDefinition : Azure.AI.Projects.OpenAI.AgentDefinition, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public PromptAgentDefinition(string model) { } + public string Instructions { get { throw null; } set { } } + public string Model { get { throw null; } set { } } + public OpenAI.Responses.ResponseReasoningOptions ReasoningOptions { get { throw null; } set { } } + public System.Collections.Generic.IDictionary StructuredInputs { get { throw null; } } + public float? Temperature { get { throw null; } set { } } + public OpenAI.Responses.ResponseTextOptions TextOptions { get { throw null; } set { } } + public System.Collections.Generic.IList Tools { get { throw null; } } + public float? TopP { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.PromptAgentDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.PromptAgentDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ProtocolVersionRecord : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ProtocolVersionRecord(Azure.AI.Projects.OpenAI.AgentCommunicationMethod protocol, string version) { } + public Azure.AI.Projects.OpenAI.AgentCommunicationMethod Protocol { get { throw null; } set { } } + public string Version { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.ProtocolVersionRecord JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.ProtocolVersionRecord PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.ProtocolVersionRecord System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.ProtocolVersionRecord System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public static partial class ResponseCreationOptionsExtensions + { + public static Azure.AI.Projects.OpenAI.AgentReference get_Agent(OpenAI.Responses.ResponseCreationOptions options) { throw null; } + public static string get_AgentConversationId(OpenAI.Responses.ResponseCreationOptions options) { throw null; } + public static string get_Model(OpenAI.Responses.ResponseCreationOptions options) { throw null; } + public static Azure.AI.Projects.OpenAI.ExtraDataDictionary get_StructuredInputs(OpenAI.Responses.ResponseCreationOptions options) { throw null; } + public static void set_Agent(OpenAI.Responses.ResponseCreationOptions options, Azure.AI.Projects.OpenAI.AgentReference value) { } + public static void set_AgentConversationId(OpenAI.Responses.ResponseCreationOptions options, string value) { } + public static void set_Model(OpenAI.Responses.ResponseCreationOptions options, string value) { } + public sealed partial class <>E__0 + { + internal <>E__0() { } + public Azure.AI.Projects.OpenAI.AgentReference Agent { get { throw null; } set { } } + public string AgentConversationId { get { throw null; } set { } } + public string Model { get { throw null; } set { } } + public Azure.AI.Projects.OpenAI.ExtraDataDictionary StructuredInputs { get { throw null; } } + } + } + public static partial class ResponseItemExtensions + { + public static Azure.AI.Projects.OpenAI.AgentResponseItem AsAgentResponseItem(this OpenAI.Responses.ResponseItem responseItem) { throw null; } + } + public static partial class ResponseToolExtensions + { + public static Azure.AI.Projects.OpenAI.AgentTool AsAgentTool(this OpenAI.Responses.ResponseTool responseTool) { throw null; } + } + public partial class SharepointAgentTool : Azure.AI.Projects.OpenAI.AgentTool, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public SharepointAgentTool(Azure.AI.Projects.OpenAI.SharePointGroundingToolOptions sharepointGroundingPreview) { } + public Azure.AI.Projects.OpenAI.SharePointGroundingToolOptions SharepointGroundingPreview { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.SharepointAgentTool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.SharepointAgentTool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class SharePointGroundingToolOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public SharePointGroundingToolOptions() { } + public System.Collections.Generic.IList ProjectConnections { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.SharePointGroundingToolOptions JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.SharePointGroundingToolOptions PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.SharePointGroundingToolOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.SharePointGroundingToolOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class StructuredInputDefinition : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public StructuredInputDefinition() { } + public System.BinaryData DefaultValue { get { throw null; } set { } } + public string Description { get { throw null; } set { } } + public bool? IsRequired { get { throw null; } set { } } + public System.BinaryData Schema { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.StructuredInputDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.StructuredInputDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.StructuredInputDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.StructuredInputDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class StructuredOutputDefinition : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public StructuredOutputDefinition(string name, string description, System.BinaryData schema, bool? strict) { } + public string Description { get { throw null; } set { } } + public string Name { get { throw null; } set { } } + public System.BinaryData Schema { get { throw null; } set { } } + public bool? Strict { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.StructuredOutputDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.StructuredOutputDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.StructuredOutputDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.StructuredOutputDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ToolProjectConnection : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ToolProjectConnection(string projectConnectionId) { } + public string ProjectConnectionId { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.ToolProjectConnection JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.ToolProjectConnection PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.ToolProjectConnection System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.ToolProjectConnection System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class WorkflowAgentDefinition : Azure.AI.Projects.OpenAI.AgentDefinition, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal WorkflowAgentDefinition() { } + public static Azure.AI.Projects.OpenAI.WorkflowAgentDefinition FromYaml(string workflowYamlDocument) { throw null; } + protected override Azure.AI.Projects.OpenAI.AgentDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.WorkflowAgentDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.WorkflowAgentDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/api/Azure.AI.Projects.OpenAI.netstandard2.0.cs b/sdk/ai/Azure.AI.Projects.OpenAI/api/Azure.AI.Projects.OpenAI.netstandard2.0.cs new file mode 100644 index 000000000000..876ccbc3d7c3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/api/Azure.AI.Projects.OpenAI.netstandard2.0.cs @@ -0,0 +1,1432 @@ +namespace Azure.AI.Projects +{ + public static partial class ClientConnectionProviderExtensions + { + public static Azure.AI.Projects.OpenAI.ProjectOpenAIClient GetProjectOpenAIClient(this System.ClientModel.Primitives.ClientConnectionProvider connectionProvider, Azure.AI.Projects.OpenAI.ProjectOpenAIClientOptions options = null) { throw null; } + public sealed partial class <>E__0 + { + internal <>E__0() { } + public Azure.AI.Projects.OpenAI.ProjectOpenAIClient GetProjectOpenAIClient(Azure.AI.Projects.OpenAI.ProjectOpenAIClientOptions options = null) { throw null; } + } + } +} +namespace Azure.AI.Projects.OpenAI +{ + public partial class A2ATool : Azure.AI.Projects.OpenAI.AgentTool, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public A2ATool(System.Uri baseUri) { } + public string AgentCardPath { get { throw null; } set { } } + public System.Uri BaseUri { get { throw null; } set { } } + public string ProjectConnectionId { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.A2ATool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.A2ATool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct AgentCommunicationMethod : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public AgentCommunicationMethod(string value) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentCommunicationMethod ActivityProtocol { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentCommunicationMethod Responses { get { throw null; } } + public bool Equals(Azure.AI.Projects.OpenAI.AgentCommunicationMethod other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.OpenAI.AgentCommunicationMethod left, Azure.AI.Projects.OpenAI.AgentCommunicationMethod right) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.AgentCommunicationMethod (string value) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.AgentCommunicationMethod? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.OpenAI.AgentCommunicationMethod left, Azure.AI.Projects.OpenAI.AgentCommunicationMethod right) { throw null; } + public override string ToString() { throw null; } + } + public abstract partial class AgentDefinition : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AgentDefinition() { } + public Azure.AI.Projects.OpenAI.ContentFilterConfiguration ContentFilterConfiguration { get { throw null; } set { } } + public static Azure.AI.Projects.OpenAI.ContainerApplicationAgentDefinition CreateContainerApplicationAgentDefinition(System.Collections.Generic.IEnumerable containerProtocolVersions, string containerAppResourceId, string ingressSubdomainSuffix) { throw null; } + public static Azure.AI.Projects.OpenAI.HostedAgentDefinition CreateHostedAgentDefinition(System.Collections.Generic.IEnumerable containerProtocolVersions, string cpuConfiguration, string memoryConfiguration) { throw null; } + public static Azure.AI.Projects.OpenAI.PromptAgentDefinition CreatePromptAgentDefinition(string model) { throw null; } + public static Azure.AI.Projects.OpenAI.WorkflowAgentDefinition CreateWorkflowAgentDefinitionFromYaml(string workflowYamlDocument) { throw null; } + protected virtual Azure.AI.Projects.OpenAI.AgentDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.AgentDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AgentDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AgentDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AgentInfo : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AgentInfo() { } + public string Name { get { throw null; } } + public string Type { get { throw null; } } + public string Version { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.AgentInfo JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.AgentInfo PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AgentInfo System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AgentInfo System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AgentObjectVersions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AgentObjectVersions() { } + public Azure.AI.Projects.OpenAI.AgentVersion Latest { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.AgentObjectVersions JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.AgentObjectVersions PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AgentObjectVersions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AgentObjectVersions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AgentRecord : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AgentRecord() { } + public string Id { get { throw null; } } + public string Name { get { throw null; } } + public Azure.AI.Projects.OpenAI.AgentObjectVersions Versions { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.AgentRecord JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.AgentRecord PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AgentRecord System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AgentRecord System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AgentReference : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AgentReference(string name, string version = null) { } + public string Name { get { throw null; } } + public string Version { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.AgentReference JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static implicit operator Azure.AI.Projects.OpenAI.AgentReference (Azure.AI.Projects.OpenAI.AgentRecord agentRecord) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.AgentReference (Azure.AI.Projects.OpenAI.AgentVersion agentVersion) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.AgentReference (string agentName) { throw null; } + protected virtual Azure.AI.Projects.OpenAI.AgentReference PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AgentReference System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AgentReference System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public abstract partial class AgentResponseItem : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AgentResponseItem() { } + public Azure.AI.Projects.OpenAI.AgentResponseItemSource CreatedBy { get { throw null; } } + public virtual string Id { get { throw null; } } + public OpenAI.Responses.ResponseItem AsOpenAIResponseItem() { throw null; } + public static Azure.AI.Projects.OpenAI.AgentResponseItem CreateStructuredOutputsItem(System.BinaryData output = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentResponseItem CreateWorkflowActionItem(string actionKind, string actionId) { throw null; } + protected virtual Azure.AI.Projects.OpenAI.AgentResponseItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static implicit operator OpenAI.Responses.ResponseItem (Azure.AI.Projects.OpenAI.AgentResponseItem agentResponseItem) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.AgentResponseItem (OpenAI.Responses.ResponseItem responseItem) { throw null; } + protected virtual Azure.AI.Projects.OpenAI.AgentResponseItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AgentResponseItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AgentResponseItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct AgentResponseItemKind : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public AgentResponseItemKind(string value) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind CodeInterpreterCall { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind ComputerCall { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind ComputerCallOutput { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind FileSearchCall { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind FunctionCall { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind FunctionCallOutput { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind ImageGenerationCall { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind ItemReference { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind LocalShellCall { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind LocalShellCallOutput { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind McpApprovalRequest { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind McpApprovalResponse { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind McpCall { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind McpListTools { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind MemorySearchCall { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind Message { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind OauthConsentRequest { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind Reasoning { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind StructuredOutputs { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind WebSearchCall { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentResponseItemKind WorkflowAction { get { throw null; } } + public bool Equals(Azure.AI.Projects.OpenAI.AgentResponseItemKind other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.OpenAI.AgentResponseItemKind left, Azure.AI.Projects.OpenAI.AgentResponseItemKind right) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.AgentResponseItemKind (string value) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.AgentResponseItemKind? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.OpenAI.AgentResponseItemKind left, Azure.AI.Projects.OpenAI.AgentResponseItemKind right) { throw null; } + public override string ToString() { throw null; } + } + public partial class AgentResponseItemSource : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AgentResponseItemSource() { } + public Azure.AI.Projects.OpenAI.AgentInfo Agent { get { throw null; } } + public string ResponseId { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.AgentResponseItemSource JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.AgentResponseItemSource PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AgentResponseItemSource System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AgentResponseItemSource System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AgentStructuredOutputsResponseItem : Azure.AI.Projects.OpenAI.AgentResponseItem, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AgentStructuredOutputsResponseItem(System.BinaryData output) { } + public System.BinaryData Output { get { throw null; } } + protected override Azure.AI.Projects.OpenAI.AgentResponseItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentResponseItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AgentStructuredOutputsResponseItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AgentStructuredOutputsResponseItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public abstract partial class AgentTool : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AgentTool() { } + public static OpenAI.Responses.ResponseTool CreateA2ATool(System.Uri baseUri, string agentCardPath = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AzureAISearchAgentTool CreateAzureAISearchTool(Azure.AI.Projects.OpenAI.AzureAISearchToolOptions options = null) { throw null; } + public static Azure.AI.Projects.OpenAI.BingCustomSearchAgentTool CreateBingCustomSearchTool(Azure.AI.Projects.OpenAI.BingCustomSearchToolParameters parameters) { throw null; } + public static Azure.AI.Projects.OpenAI.BingGroundingAgentTool CreateBingGroundingTool(Azure.AI.Projects.OpenAI.BingGroundingSearchToolOptions options) { throw null; } + public static Azure.AI.Projects.OpenAI.BrowserAutomationAgentTool CreateBrowserAutomationTool(Azure.AI.Projects.OpenAI.BrowserAutomationToolParameters parameters) { throw null; } + public static Azure.AI.Projects.OpenAI.LocalShellAgentTool CreateLocalShellTool() { throw null; } + public static Azure.AI.Projects.OpenAI.MicrosoftFabricAgentTool CreateMicrosoftFabricTool(Azure.AI.Projects.OpenAI.FabricDataAgentToolOptions options) { throw null; } + public static Azure.AI.Projects.OpenAI.OpenAPIAgentTool CreateOpenApiTool(Azure.AI.Projects.OpenAI.OpenAPIFunctionDefinition definition) { throw null; } + public static Azure.AI.Projects.OpenAI.SharepointAgentTool CreateSharepointTool(Azure.AI.Projects.OpenAI.SharePointGroundingToolOptions options) { throw null; } + public static Azure.AI.Projects.OpenAI.CaptureStructuredOutputsTool CreateStructuredOutputsTool(Azure.AI.Projects.OpenAI.StructuredOutputDefinition outputs) { throw null; } + protected virtual Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static implicit operator OpenAI.Responses.ResponseTool (Azure.AI.Projects.OpenAI.AgentTool agentTool) { throw null; } + protected virtual Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AgentTool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AgentTool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AgentVersion : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AgentVersion() { } + public System.DateTimeOffset CreatedAt { get { throw null; } } + public Azure.AI.Projects.OpenAI.AgentDefinition Definition { get { throw null; } } + public string Description { get { throw null; } } + public string Id { get { throw null; } } + public System.Collections.Generic.IDictionary Metadata { get { throw null; } } + public string Name { get { throw null; } } + public string Version { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.AgentVersion JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.AgentVersion PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AgentVersion System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AgentVersion System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AgentWorkflowActionResponseItem : Azure.AI.Projects.OpenAI.AgentResponseItem, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AgentWorkflowActionResponseItem() { } + public string ActionId { get { throw null; } } + public string Kind { get { throw null; } } + public string ParentActionId { get { throw null; } } + public string PreviousActionId { get { throw null; } } + public Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus? Status { get { throw null; } } + protected override Azure.AI.Projects.OpenAI.AgentResponseItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentResponseItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AgentWorkflowActionResponseItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AgentWorkflowActionResponseItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct AgentWorkflowActionStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public AgentWorkflowActionStatus(string value) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus Cancelled { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus Completed { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus Failed { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus InProgress { get { throw null; } } + public bool Equals(Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus left, Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus right) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus (string value) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus left, Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus right) { throw null; } + public override string ToString() { throw null; } + } + public static partial class AzureAIAgentsModelFactory + { + } + public partial class AzureAIProjectsOpenAIContext : System.ClientModel.Primitives.ModelReaderWriterContext + { + internal AzureAIProjectsOpenAIContext() { } + public static Azure.AI.Projects.OpenAI.AzureAIProjectsOpenAIContext Default { get { throw null; } } + protected override bool TryGetTypeBuilderCore(System.Type type, out System.ClientModel.Primitives.ModelReaderWriterTypeBuilder builder) { throw null; } + } + public partial class AzureAISearchAgentTool : Azure.AI.Projects.OpenAI.AgentTool, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AzureAISearchAgentTool(Azure.AI.Projects.OpenAI.AzureAISearchToolOptions options) { } + public Azure.AI.Projects.OpenAI.AzureAISearchToolOptions Options { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AzureAISearchAgentTool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AzureAISearchAgentTool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct AzureAISearchQueryType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public AzureAISearchQueryType(string value) { throw null; } + public static Azure.AI.Projects.OpenAI.AzureAISearchQueryType Semantic { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AzureAISearchQueryType Simple { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AzureAISearchQueryType Vector { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AzureAISearchQueryType VectorSemanticHybrid { get { throw null; } } + public static Azure.AI.Projects.OpenAI.AzureAISearchQueryType VectorSimpleHybrid { get { throw null; } } + public bool Equals(Azure.AI.Projects.OpenAI.AzureAISearchQueryType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.OpenAI.AzureAISearchQueryType left, Azure.AI.Projects.OpenAI.AzureAISearchQueryType right) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.AzureAISearchQueryType (string value) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.AzureAISearchQueryType? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.OpenAI.AzureAISearchQueryType left, Azure.AI.Projects.OpenAI.AzureAISearchQueryType right) { throw null; } + public override string ToString() { throw null; } + } + public partial class AzureAISearchToolIndex : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AzureAISearchToolIndex() { } + public string Filter { get { throw null; } set { } } + public string IndexAssetId { get { throw null; } set { } } + public string IndexName { get { throw null; } set { } } + public string ProjectConnectionId { get { throw null; } set { } } + public Azure.AI.Projects.OpenAI.AzureAISearchQueryType? QueryType { get { throw null; } set { } } + public int? TopK { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.AzureAISearchToolIndex JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.AzureAISearchToolIndex PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AzureAISearchToolIndex System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AzureAISearchToolIndex System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AzureAISearchToolOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AzureAISearchToolOptions(System.Collections.Generic.IEnumerable indexes) { } + public System.Collections.Generic.IList Indexes { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.AzureAISearchToolOptions JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.AzureAISearchToolOptions PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AzureAISearchToolOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AzureAISearchToolOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AzureFunctionAgentTool : Azure.AI.Projects.OpenAI.AgentTool, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AzureFunctionAgentTool(Azure.AI.Projects.OpenAI.AzureFunctionDefinition azureFunction) { } + public Azure.AI.Projects.OpenAI.AzureFunctionDefinition AzureFunction { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AzureFunctionAgentTool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AzureFunctionAgentTool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AzureFunctionBinding : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AzureFunctionBinding(Azure.AI.Projects.OpenAI.AzureFunctionStorageQueue storageQueue) { } + public Azure.AI.Projects.OpenAI.AzureFunctionStorageQueue StorageQueue { get { throw null; } set { } } + public string Type { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.AzureFunctionBinding JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.AzureFunctionBinding PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AzureFunctionBinding System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AzureFunctionBinding System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AzureFunctionDefinition : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AzureFunctionDefinition(Azure.AI.Projects.OpenAI.AzureFunctionDefinitionFunction function, Azure.AI.Projects.OpenAI.AzureFunctionBinding inputBinding, Azure.AI.Projects.OpenAI.AzureFunctionBinding outputBinding) { } + public Azure.AI.Projects.OpenAI.AzureFunctionDefinitionFunction Function { get { throw null; } set { } } + public Azure.AI.Projects.OpenAI.AzureFunctionBinding InputBinding { get { throw null; } set { } } + public Azure.AI.Projects.OpenAI.AzureFunctionBinding OutputBinding { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.AzureFunctionDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.AzureFunctionDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AzureFunctionDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AzureFunctionDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AzureFunctionDefinitionFunction : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AzureFunctionDefinitionFunction(string name, System.BinaryData parameters) { } + public string Description { get { throw null; } set { } } + public string Name { get { throw null; } set { } } + public System.BinaryData Parameters { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.AzureFunctionDefinitionFunction JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.AzureFunctionDefinitionFunction PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AzureFunctionDefinitionFunction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AzureFunctionDefinitionFunction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AzureFunctionStorageQueue : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AzureFunctionStorageQueue(string queueServiceEndpoint, string queueName) { } + public string QueueName { get { throw null; } set { } } + public string QueueServiceEndpoint { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.AzureFunctionStorageQueue JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.AzureFunctionStorageQueue PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.AzureFunctionStorageQueue System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.AzureFunctionStorageQueue System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class BingCustomSearchAgentTool : Azure.AI.Projects.OpenAI.AgentTool, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public BingCustomSearchAgentTool(Azure.AI.Projects.OpenAI.BingCustomSearchToolParameters bingCustomSearchPreview) { } + public Azure.AI.Projects.OpenAI.BingCustomSearchToolParameters BingCustomSearchPreview { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.BingCustomSearchAgentTool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.BingCustomSearchAgentTool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class BingCustomSearchConfiguration : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public BingCustomSearchConfiguration(string projectConnectionId, string instanceName) { } + public long? Count { get { throw null; } set { } } + public string Freshness { get { throw null; } set { } } + public string InstanceName { get { throw null; } set { } } + public string Market { get { throw null; } set { } } + public string ProjectConnectionId { get { throw null; } set { } } + public string SetLang { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.BingCustomSearchConfiguration JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.BingCustomSearchConfiguration PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.BingCustomSearchConfiguration System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.BingCustomSearchConfiguration System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class BingCustomSearchToolParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public BingCustomSearchToolParameters(System.Collections.Generic.IEnumerable searchConfigurations) { } + public System.Collections.Generic.IList SearchConfigurations { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.BingCustomSearchToolParameters JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.BingCustomSearchToolParameters PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.BingCustomSearchToolParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.BingCustomSearchToolParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class BingGroundingAgentTool : Azure.AI.Projects.OpenAI.AgentTool, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public BingGroundingAgentTool(Azure.AI.Projects.OpenAI.BingGroundingSearchToolOptions bingGrounding) { } + public Azure.AI.Projects.OpenAI.BingGroundingSearchToolOptions BingGrounding { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.BingGroundingAgentTool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.BingGroundingAgentTool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class BingGroundingSearchConfiguration : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public BingGroundingSearchConfiguration(string projectConnectionId) { } + public long? Count { get { throw null; } set { } } + public string Freshness { get { throw null; } set { } } + public string Market { get { throw null; } set { } } + public string ProjectConnectionId { get { throw null; } set { } } + public string SetLang { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.BingGroundingSearchConfiguration JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.BingGroundingSearchConfiguration PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.BingGroundingSearchConfiguration System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.BingGroundingSearchConfiguration System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class BingGroundingSearchToolOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public BingGroundingSearchToolOptions(System.Collections.Generic.IEnumerable searchConfigurations) { } + public System.Collections.Generic.IList SearchConfigurations { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.BingGroundingSearchToolOptions JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.BingGroundingSearchToolOptions PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.BingGroundingSearchToolOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.BingGroundingSearchToolOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class BrowserAutomationAgentTool : Azure.AI.Projects.OpenAI.AgentTool, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public BrowserAutomationAgentTool(Azure.AI.Projects.OpenAI.BrowserAutomationToolParameters browserAutomationPreview) { } + public Azure.AI.Projects.OpenAI.BrowserAutomationToolParameters BrowserAutomationPreview { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.BrowserAutomationAgentTool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.BrowserAutomationAgentTool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class BrowserAutomationToolConnectionParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public BrowserAutomationToolConnectionParameters(string projectConnectionId) { } + public string ProjectConnectionId { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.BrowserAutomationToolConnectionParameters JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.BrowserAutomationToolConnectionParameters PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.BrowserAutomationToolConnectionParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.BrowserAutomationToolConnectionParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class BrowserAutomationToolParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public BrowserAutomationToolParameters(Azure.AI.Projects.OpenAI.BrowserAutomationToolConnectionParameters connection) { } + public Azure.AI.Projects.OpenAI.BrowserAutomationToolConnectionParameters Connection { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.BrowserAutomationToolParameters JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.BrowserAutomationToolParameters PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.BrowserAutomationToolParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.BrowserAutomationToolParameters System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class CaptureStructuredOutputsTool : Azure.AI.Projects.OpenAI.AgentTool, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public CaptureStructuredOutputsTool(Azure.AI.Projects.OpenAI.StructuredOutputDefinition outputs) { } + public Azure.AI.Projects.OpenAI.StructuredOutputDefinition Outputs { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.CaptureStructuredOutputsTool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.CaptureStructuredOutputsTool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ChatSummaryMemoryItem : Azure.AI.Projects.OpenAI.MemoryItem, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ChatSummaryMemoryItem(string memoryId, System.DateTimeOffset updatedAt, string scope, string content) { } + protected override Azure.AI.Projects.OpenAI.MemoryItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.MemoryItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.ChatSummaryMemoryItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.ChatSummaryMemoryItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ContainerApplicationAgentDefinition : Azure.AI.Projects.OpenAI.AgentDefinition, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ContainerApplicationAgentDefinition(System.Collections.Generic.IEnumerable containerProtocolVersions, string containerAppResourceId, string ingressSubdomainSuffix) { } + public string ContainerAppResourceId { get { throw null; } set { } } + public System.Collections.Generic.IList ContainerProtocolVersions { get { throw null; } } + public string IngressSubdomainSuffix { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.ContainerApplicationAgentDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.ContainerApplicationAgentDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ContentFilterConfiguration : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ContentFilterConfiguration(string policyName) { } + public string PolicyName { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.ContentFilterConfiguration JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.ContentFilterConfiguration PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.ContentFilterConfiguration System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.ContentFilterConfiguration System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public static partial class ConversationClientExtensions + { + public sealed partial class <>E__0 + { + internal <>E__0() { } + } + } + public partial class ExtraDataDictionary : System.Collections.Generic.ICollection>, System.Collections.Generic.IDictionary, System.Collections.Generic.IEnumerable>, System.Collections.IEnumerable + { + internal ExtraDataDictionary() { } + public int Count { get { throw null; } } + public bool IsReadOnly { get { throw null; } } + public System.BinaryData this[System.ReadOnlySpan key] { get { throw null; } set { } } + public System.BinaryData this[string key] { get { throw null; } set { } } + public System.Collections.Generic.ICollection Keys { get { throw null; } } + public System.Collections.Generic.ICollection Values { get { throw null; } } + public void Add(System.Collections.Generic.KeyValuePair item) { } + public void Add(string key, System.BinaryData value) { } + public void Add(string key, bool value) { } + public void Add(string key, int value) { } + public void Add(string key, string value) { } + public void Clear() { } + public bool Contains(System.Collections.Generic.KeyValuePair item) { throw null; } + public bool ContainsKey(string key) { throw null; } + public void CopyTo(System.Collections.Generic.KeyValuePair[] array, int arrayIndex) { } + public bool Remove(System.Collections.Generic.KeyValuePair item) { throw null; } + public bool Remove(string key) { throw null; } + public void SetData(System.BinaryData dictionaryJsonBytes) { } + System.Collections.Generic.IEnumerator> System.Collections.Generic.IEnumerable>.GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + public bool TryGetValue(System.ReadOnlySpan key, out System.BinaryData value) { throw null; } + public bool TryGetValue(string key, out System.BinaryData value) { throw null; } + } + public partial class FabricDataAgentToolOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public FabricDataAgentToolOptions() { } + public System.Collections.Generic.IList ProjectConnections { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.FabricDataAgentToolOptions JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.FabricDataAgentToolOptions PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.FabricDataAgentToolOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.FabricDataAgentToolOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class HostedAgentDefinition : Azure.AI.Projects.OpenAI.AgentDefinition, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public HostedAgentDefinition(System.Collections.Generic.IEnumerable containerProtocolVersions, string cpu, string memory) { } + public System.Collections.Generic.IList ContainerProtocolVersions { get { throw null; } } + public string Cpu { get { throw null; } set { } } + public System.Collections.Generic.IDictionary EnvironmentVariables { get { throw null; } } + public string Memory { get { throw null; } set { } } + public System.Collections.Generic.IList Tools { get { throw null; } } + protected override Azure.AI.Projects.OpenAI.AgentDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.HostedAgentDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.HostedAgentDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ImageBasedHostedAgentDefinition : Azure.AI.Projects.OpenAI.HostedAgentDefinition, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ImageBasedHostedAgentDefinition(System.Collections.Generic.IEnumerable containerProtocolVersions, string cpu, string memory, string image) : base (default(System.Collections.Generic.IEnumerable), default(string), default(string)) { } + public string Image { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.ImageBasedHostedAgentDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.ImageBasedHostedAgentDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class LocalShellAgentTool : Azure.AI.Projects.OpenAI.AgentTool, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public LocalShellAgentTool() { } + protected override Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.LocalShellAgentTool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.LocalShellAgentTool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct LocalShellAgentToolCallStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public LocalShellAgentToolCallStatus(string value) { throw null; } + public static Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus Completed { get { throw null; } } + public static Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus Incomplete { get { throw null; } } + public static Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus InProgress { get { throw null; } } + public bool Equals(Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus left, Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus right) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus (string value) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus left, Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus right) { throw null; } + public override string ToString() { throw null; } + } + public partial class LocalShellAgentToolExecutionAction : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public LocalShellAgentToolExecutionAction(System.Collections.Generic.IEnumerable command, System.Collections.Generic.IDictionary env) { } + public System.Collections.Generic.IList Command { get { throw null; } } + public System.Collections.Generic.IDictionary Env { get { throw null; } } + public int? TimeoutMs { get { throw null; } set { } } + public string User { get { throw null; } set { } } + public string WorkingDirectory { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.LocalShellAgentToolExecutionAction JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.LocalShellAgentToolExecutionAction PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.LocalShellAgentToolExecutionAction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.LocalShellAgentToolExecutionAction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class LocalShellToolCallAgentResponseItem : Azure.AI.Projects.OpenAI.AgentResponseItem, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal LocalShellToolCallAgentResponseItem() { } + public Azure.AI.Projects.OpenAI.LocalShellAgentToolExecutionAction Action { get { throw null; } } + public string CallId { get { throw null; } } + public Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus Status { get { throw null; } } + protected override Azure.AI.Projects.OpenAI.AgentResponseItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentResponseItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.LocalShellToolCallAgentResponseItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.LocalShellToolCallAgentResponseItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class LocalShellToolCallOutputAgentResponseItem : Azure.AI.Projects.OpenAI.AgentResponseItem, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal LocalShellToolCallOutputAgentResponseItem() { } + public string Output { get { throw null; } } + public Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus Status { get { throw null; } } + protected override Azure.AI.Projects.OpenAI.AgentResponseItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentResponseItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.LocalShellToolCallOutputAgentResponseItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.LocalShellToolCallOutputAgentResponseItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public abstract partial class MemoryItem : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemoryItem() { } + public string Content { get { throw null; } } + public string MemoryId { get { throw null; } } + public string Scope { get { throw null; } } + public System.DateTimeOffset UpdatedAt { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.MemoryItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.MemoryItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.MemoryItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.MemoryItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemorySearchItem : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MemorySearchItem(Azure.AI.Projects.OpenAI.MemoryItem memoryItem) { } + public Azure.AI.Projects.OpenAI.MemoryItem MemoryItem { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.MemorySearchItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.MemorySearchItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.MemorySearchItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.MemorySearchItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemorySearchTool : Azure.AI.Projects.OpenAI.AgentTool, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MemorySearchTool(string memoryStoreName, string scope) { } + public string MemoryStoreName { get { throw null; } set { } } + public string Scope { get { throw null; } set { } } + public Azure.AI.Projects.OpenAI.MemorySearchToolOptions SearchOptions { get { throw null; } set { } } + public int? UpdateDelay { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.MemorySearchTool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.MemorySearchTool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemorySearchToolCallResponseItem : Azure.AI.Projects.OpenAI.AgentResponseItem, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemorySearchToolCallResponseItem() { } + public System.Collections.Generic.IList Results { get { throw null; } } + public Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus Status { get { throw null; } } + protected override Azure.AI.Projects.OpenAI.AgentResponseItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentResponseItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.MemorySearchToolCallResponseItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.MemorySearchToolCallResponseItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct MemorySearchToolCallStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public MemorySearchToolCallStatus(string value) { throw null; } + public static Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus Completed { get { throw null; } } + public static Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus Failed { get { throw null; } } + public static Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus Incomplete { get { throw null; } } + public static Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus InProgress { get { throw null; } } + public static Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus Searching { get { throw null; } } + public bool Equals(Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus left, Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus right) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus (string value) { throw null; } + public static implicit operator Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus left, Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus right) { throw null; } + public override string ToString() { throw null; } + } + public partial class MemorySearchToolOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MemorySearchToolOptions() { } + public int? MaxMemories { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.MemorySearchToolOptions JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.MemorySearchToolOptions PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.MemorySearchToolOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.MemorySearchToolOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MicrosoftFabricAgentTool : Azure.AI.Projects.OpenAI.AgentTool, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MicrosoftFabricAgentTool(Azure.AI.Projects.OpenAI.FabricDataAgentToolOptions fabricDataagentPreview) { } + public Azure.AI.Projects.OpenAI.FabricDataAgentToolOptions FabricDataagentPreview { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.MicrosoftFabricAgentTool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.MicrosoftFabricAgentTool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class OAuthConsentRequestResponseItem : Azure.AI.Projects.OpenAI.AgentResponseItem, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal OAuthConsentRequestResponseItem() { } + public string ConsentLink { get { throw null; } } + public override string Id { get { throw null; } } + public string ServerLabel { get { throw null; } } + protected override Azure.AI.Projects.OpenAI.AgentResponseItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentResponseItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.OAuthConsentRequestResponseItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.OAuthConsentRequestResponseItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public static partial class OpenAIFileExtensions + { + public static string GetAzureFileStatus(this OpenAI.Files.OpenAIFile file) { throw null; } + } + public static partial class OpenAIResponseExtension + { + public static System.ClientModel.ClientResult CreateResponse(this OpenAI.Responses.OpenAIResponseClient responseClient, Azure.AI.Projects.OpenAI.ProjectConversation conversation, Azure.AI.Projects.OpenAI.AgentReference agentRef, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static System.Threading.Tasks.Task> CreateResponseAsync(this OpenAI.Responses.OpenAIResponseClient responseClient, Azure.AI.Projects.OpenAI.ProjectConversation conversation, Azure.AI.Projects.OpenAI.AgentReference agentRef, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public static partial class OpenAIResponseExtensions + { + public static Azure.AI.Projects.OpenAI.AgentReference get_Agent(OpenAI.Responses.OpenAIResponse response) { throw null; } + public static string get_AgentConversationId(OpenAI.Responses.OpenAIResponse response) { throw null; } + public sealed partial class <>E__0 + { + internal <>E__0() { } + public Azure.AI.Projects.OpenAI.AgentReference Agent { get { throw null; } } + public string AgentConversationId { get { throw null; } } + } + } + public partial class OpenAPIAgentTool : Azure.AI.Projects.OpenAI.AgentTool, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public OpenAPIAgentTool(Azure.AI.Projects.OpenAI.OpenAPIFunctionDefinition openapi) { } + public Azure.AI.Projects.OpenAI.OpenAPIFunctionDefinition Openapi { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.OpenAPIAgentTool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.OpenAPIAgentTool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class OpenAPIAnonymousAuthenticationDetails : Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public OpenAPIAnonymousAuthenticationDetails() { } + protected override Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.OpenAPIAnonymousAuthenticationDetails System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.OpenAPIAnonymousAuthenticationDetails System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public abstract partial class OpenAPIAuthenticationDetails : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal OpenAPIAuthenticationDetails() { } + protected virtual Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class OpenAPIFunctionDefinition : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public OpenAPIFunctionDefinition(string name, System.BinaryData spec, Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails auth) { } + public Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails Auth { get { throw null; } set { } } + public System.Collections.Generic.IList DefaultParams { get { throw null; } } + public string Description { get { throw null; } set { } } + public System.Collections.Generic.IReadOnlyList Functions { get { throw null; } } + public string Name { get { throw null; } set { } } + public System.BinaryData Spec { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.OpenAPIFunctionDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.OpenAPIFunctionDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.OpenAPIFunctionDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.OpenAPIFunctionDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class OpenAPIFunctionEntry : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public OpenAPIFunctionEntry(string name, System.BinaryData parameters) { } + public string Description { get { throw null; } set { } } + public string Name { get { throw null; } set { } } + public System.BinaryData Parameters { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.OpenAPIFunctionEntry JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.OpenAPIFunctionEntry PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.OpenAPIFunctionEntry System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.OpenAPIFunctionEntry System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class OpenAPIManagedAuthenticationDetails : Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public OpenAPIManagedAuthenticationDetails(Azure.AI.Projects.OpenAI.OpenApiManagedSecurityScheme securityScheme) { } + public Azure.AI.Projects.OpenAI.OpenApiManagedSecurityScheme SecurityScheme { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.OpenAPIManagedAuthenticationDetails System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.OpenAPIManagedAuthenticationDetails System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class OpenApiManagedSecurityScheme : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public OpenApiManagedSecurityScheme(string audience) { } + public string Audience { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.OpenApiManagedSecurityScheme JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.OpenApiManagedSecurityScheme PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.OpenApiManagedSecurityScheme System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.OpenApiManagedSecurityScheme System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class OpenAPIProjectConnectionAuthenticationDetails : Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public OpenAPIProjectConnectionAuthenticationDetails(Azure.AI.Projects.OpenAI.OpenAPIProjectConnectionSecurityScheme securityScheme) { } + public Azure.AI.Projects.OpenAI.OpenAPIProjectConnectionSecurityScheme SecurityScheme { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.OpenAPIProjectConnectionAuthenticationDetails System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.OpenAPIProjectConnectionAuthenticationDetails System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class OpenAPIProjectConnectionSecurityScheme : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public OpenAPIProjectConnectionSecurityScheme(string projectConnectionId) { } + public string ProjectConnectionId { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.OpenAPIProjectConnectionSecurityScheme JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.OpenAPIProjectConnectionSecurityScheme PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.OpenAPIProjectConnectionSecurityScheme System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.OpenAPIProjectConnectionSecurityScheme System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ProjectConversation : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ProjectConversation() { } + public System.DateTimeOffset CreatedAt { get { throw null; } } + public string Id { get { throw null; } } + public System.Collections.Generic.IDictionary Metadata { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.ProjectConversation JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static implicit operator string (Azure.AI.Projects.OpenAI.ProjectConversation conversation) { throw null; } + protected virtual Azure.AI.Projects.OpenAI.ProjectConversation PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.ProjectConversation System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.ProjectConversation System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ProjectConversationCreationOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ProjectConversationCreationOptions() { } + public System.Collections.Generic.IList Items { get { throw null; } } + public System.Collections.Generic.IDictionary Metadata { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.ProjectConversationCreationOptions JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.ProjectConversationCreationOptions PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.ProjectConversationCreationOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.ProjectConversationCreationOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ProjectConversationsClient : OpenAI.Conversations.ConversationClient + { + protected ProjectConversationsClient() { } + public ProjectConversationsClient(System.ClientModel.Primitives.ClientPipeline pipeline, OpenAI.OpenAIClientOptions options) { } + public virtual System.ClientModel.ClientResult CreateProjectConversation(Azure.AI.Projects.OpenAI.ProjectConversationCreationOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> CreateProjectConversationAsync(Azure.AI.Projects.OpenAI.ProjectConversationCreationOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult> CreateProjectConversationItems(string conversationId, System.Collections.Generic.IEnumerable items, System.Collections.Generic.IEnumerable include = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task>> CreateProjectConversationItemsAsync(string conversationId, System.Collections.Generic.IEnumerable items, System.Collections.Generic.IEnumerable include = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult GetProjectConversation(string conversationId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetProjectConversationAsync(string conversationId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult GetProjectConversationItem(string conversationId, string itemId, System.Collections.Generic.IEnumerable include = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetProjectConversationItemAsync(string conversationId, string itemId, System.Collections.Generic.IEnumerable include = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.CollectionResult GetProjectConversationItems(string conversationId, Azure.AI.Projects.OpenAI.AgentResponseItemKind? itemKind = default(Azure.AI.Projects.OpenAI.AgentResponseItemKind?), int? limit = default(int?), string order = null, string after = null, string before = null, System.Collections.Generic.IEnumerable include = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetProjectConversationItemsAsync(string conversationId, Azure.AI.Projects.OpenAI.AgentResponseItemKind? itemKind = default(Azure.AI.Projects.OpenAI.AgentResponseItemKind?), int? limit = default(int?), string order = null, string after = null, string before = null, System.Collections.Generic.IEnumerable include = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.CollectionResult GetProjectConversations(Azure.AI.Projects.OpenAI.AgentReference agent = null, int? limit = default(int?), string order = null, string after = null, string before = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetProjectConversationsAsync(Azure.AI.Projects.OpenAI.AgentReference agent = null, int? limit = default(int?), string order = null, string after = null, string before = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult UpdateProjectConversation(string conversationId, Azure.AI.Projects.OpenAI.ProjectConversationUpdateOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateProjectConversationAsync(string conversationId, Azure.AI.Projects.OpenAI.ProjectConversationUpdateOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class ProjectConversationUpdateOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ProjectConversationUpdateOptions() { } + public System.Collections.Generic.IDictionary Metadata { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.ProjectConversationUpdateOptions JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.ProjectConversationUpdateOptions PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.ProjectConversationUpdateOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.ProjectConversationUpdateOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ProjectFilesClient : OpenAI.Files.OpenAIFileClient + { + protected ProjectFilesClient() { } + } + public partial class ProjectOpenAIClient : OpenAI.OpenAIClient + { + protected ProjectOpenAIClient() { } + public ProjectOpenAIClient(System.ClientModel.Primitives.AuthenticationPolicy authenticationPolicy, Azure.AI.Projects.OpenAI.ProjectOpenAIClientOptions options) { } + protected internal ProjectOpenAIClient(System.ClientModel.Primitives.ClientPipeline pipeline, Azure.AI.Projects.OpenAI.ProjectOpenAIClientOptions options) { } + public ProjectOpenAIClient(System.Uri projectEndpoint, System.ClientModel.AuthenticationTokenProvider tokenProvider, Azure.AI.Projects.OpenAI.ProjectOpenAIClientOptions options = null) { } + public virtual Azure.AI.Projects.OpenAI.ProjectConversationsClient Conversations { get { throw null; } } + public virtual Azure.AI.Projects.OpenAI.ProjectFilesClient Files { get { throw null; } } + public virtual Azure.AI.Projects.OpenAI.ProjectResponsesClient Responses { get { throw null; } } + public virtual Azure.AI.Projects.OpenAI.ProjectVectorStoresClient VectorStores { get { throw null; } } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override OpenAI.Conversations.ConversationClient GetConversationClient() { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override OpenAI.Files.OpenAIFileClient GetOpenAIFileClient() { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override OpenAI.Responses.OpenAIResponseClient GetOpenAIResponseClient(string defaultModel) { throw null; } + public virtual Azure.AI.Projects.OpenAI.ProjectConversationsClient GetProjectConversationsClient() { throw null; } + public virtual Azure.AI.Projects.OpenAI.ProjectFilesClient GetProjectFilesClient() { throw null; } + public virtual Azure.AI.Projects.OpenAI.ProjectResponsesClient GetProjectResponsesClient() { throw null; } + public virtual Azure.AI.Projects.OpenAI.ProjectResponsesClient GetProjectResponsesClientForAgent(Azure.AI.Projects.OpenAI.AgentReference defaultAgent, string defaultConversationId = null) { throw null; } + public virtual Azure.AI.Projects.OpenAI.ProjectResponsesClient GetProjectResponsesClientForModel(string defaultModel, string defaultConversationId = null) { throw null; } + public virtual Azure.AI.Projects.OpenAI.ProjectVectorStoresClient GetProjectVectorStoresClient() { throw null; } + } + public partial class ProjectOpenAIClientOptions : OpenAI.OpenAIClientOptions + { + public ProjectOpenAIClientOptions() { } + public string ApiVersion { get { throw null; } set { } } + } + public partial class ProjectResponsesClient : OpenAI.Responses.OpenAIResponseClient + { + protected ProjectResponsesClient() { } + public ProjectResponsesClient(System.ClientModel.AuthenticationTokenProvider tokenProvider, Azure.AI.Projects.OpenAI.ProjectResponsesClientOptions options) { } + public ProjectResponsesClient(System.ClientModel.AuthenticationTokenProvider tokenProvider, Azure.AI.Projects.OpenAI.ProjectResponsesClientOptions options = null, Azure.AI.Projects.OpenAI.AgentReference defaultAgent = null, string defaultConversationId = null) { } + public ProjectResponsesClient(System.Uri projectEndpoint, System.ClientModel.AuthenticationTokenProvider tokenProvider, Azure.AI.Projects.OpenAI.AgentReference defaultAgent, string defaultConversationId = null, Azure.AI.Projects.OpenAI.ProjectResponsesClientOptions options = null) { } + public ProjectResponsesClient(System.Uri projectEndpoint, System.ClientModel.AuthenticationTokenProvider tokenProvider, Azure.AI.Projects.OpenAI.ProjectResponsesClientOptions options = null) { } + public override System.ClientModel.ClientResult CreateResponse(System.Collections.Generic.IEnumerable inputItems, OpenAI.Responses.ResponseCreationOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public override System.ClientModel.ClientResult CreateResponse(string userInputText, OpenAI.Responses.ResponseCreationOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public override System.Threading.Tasks.Task> CreateResponseAsync(System.Collections.Generic.IEnumerable inputItems, OpenAI.Responses.ResponseCreationOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public override System.Threading.Tasks.Task> CreateResponseAsync(string userInputText, OpenAI.Responses.ResponseCreationOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public override System.ClientModel.CollectionResult CreateResponseStreaming(System.Collections.Generic.IEnumerable inputItems, OpenAI.Responses.ResponseCreationOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public override System.ClientModel.CollectionResult CreateResponseStreaming(string userInputText, OpenAI.Responses.ResponseCreationOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public override System.ClientModel.AsyncCollectionResult CreateResponseStreamingAsync(System.Collections.Generic.IEnumerable inputItems, OpenAI.Responses.ResponseCreationOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public override System.ClientModel.AsyncCollectionResult CreateResponseStreamingAsync(string userInputText, OpenAI.Responses.ResponseCreationOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.CollectionResult GetProjectResponses(Azure.AI.Projects.OpenAI.AgentReference agent = null, string conversationId = null, int? limit = default(int?), string order = null, string after = null, string before = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetProjectResponsesAsync(Azure.AI.Projects.OpenAI.AgentReference agent = null, string conversationId = null, int? limit = default(int?), string order = null, string after = null, string before = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class ProjectResponsesClientOptions : Azure.AI.Projects.OpenAI.ProjectOpenAIClientOptions + { + public ProjectResponsesClientOptions() { } + } + public static partial class ProjectsOpenAIModelFactory + { + public static Azure.AI.Projects.OpenAI.A2ATool A2ATool(System.Uri baseUri = null, string agentCardPath = null, string projectConnectionId = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentDefinition AgentDefinition(string kind = null, Azure.AI.Projects.OpenAI.ContentFilterConfiguration contentFilterConfiguration = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentInfo AgentInfo(string name = null, string version = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentObjectVersions AgentObjectVersions(Azure.AI.Projects.OpenAI.AgentVersion latest = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentRecord AgentRecord(string id = null, string name = null, Azure.AI.Projects.OpenAI.AgentObjectVersions versions = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentReference AgentReference(string name = null, string version = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentResponseItem AgentResponseItem(string type = null, string id = null, Azure.AI.Projects.OpenAI.AgentResponseItemSource createdBy = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentResponseItemSource AgentResponseItemSource(Azure.AI.Projects.OpenAI.AgentInfo agent = null, string responseId = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentStructuredOutputsResponseItem AgentStructuredOutputsResponseItem(string id = null, Azure.AI.Projects.OpenAI.AgentResponseItemSource createdBy = null, System.BinaryData output = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentTool AgentTool(string type = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentVersion AgentVersion(System.Collections.Generic.IDictionary metadata = null, string id = null, string name = null, string version = null, string description = null, System.DateTimeOffset createdAt = default(System.DateTimeOffset), Azure.AI.Projects.OpenAI.AgentDefinition definition = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AgentWorkflowActionResponseItem AgentWorkflowActionResponseItem(string id = null, Azure.AI.Projects.OpenAI.AgentResponseItemSource createdBy = null, string kind = null, string actionId = null, string parentActionId = null, string previousActionId = null, Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus? status = default(Azure.AI.Projects.OpenAI.AgentWorkflowActionStatus?)) { throw null; } + public static Azure.AI.Projects.OpenAI.AzureAISearchAgentTool AzureAISearchAgentTool(Azure.AI.Projects.OpenAI.AzureAISearchToolOptions options = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AzureAISearchToolIndex AzureAISearchToolIndex(string projectConnectionId = null, string indexName = null, Azure.AI.Projects.OpenAI.AzureAISearchQueryType? queryType = default(Azure.AI.Projects.OpenAI.AzureAISearchQueryType?), int? topK = default(int?), string filter = null, string indexAssetId = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AzureAISearchToolOptions AzureAISearchToolOptions(System.Collections.Generic.IEnumerable indexes = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AzureFunctionAgentTool AzureFunctionAgentTool(Azure.AI.Projects.OpenAI.AzureFunctionDefinition azureFunction = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AzureFunctionBinding AzureFunctionBinding(Azure.AI.Projects.OpenAI.AzureFunctionStorageQueue storageQueue = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AzureFunctionDefinition AzureFunctionDefinition(Azure.AI.Projects.OpenAI.AzureFunctionDefinitionFunction function = null, Azure.AI.Projects.OpenAI.AzureFunctionBinding inputBinding = null, Azure.AI.Projects.OpenAI.AzureFunctionBinding outputBinding = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AzureFunctionDefinitionFunction AzureFunctionDefinitionFunction(string name = null, string description = null, System.BinaryData parameters = null) { throw null; } + public static Azure.AI.Projects.OpenAI.AzureFunctionStorageQueue AzureFunctionStorageQueue(string queueServiceEndpoint = null, string queueName = null) { throw null; } + public static Azure.AI.Projects.OpenAI.BingCustomSearchAgentTool BingCustomSearchAgentTool(Azure.AI.Projects.OpenAI.BingCustomSearchToolParameters bingCustomSearchPreview = null) { throw null; } + public static Azure.AI.Projects.OpenAI.BingCustomSearchConfiguration BingCustomSearchConfiguration(string projectConnectionId = null, string instanceName = null, string market = null, string setLang = null, long? count = default(long?), string freshness = null) { throw null; } + public static Azure.AI.Projects.OpenAI.BingCustomSearchToolParameters BingCustomSearchToolParameters(System.Collections.Generic.IEnumerable searchConfigurations = null) { throw null; } + public static Azure.AI.Projects.OpenAI.BingGroundingAgentTool BingGroundingAgentTool(Azure.AI.Projects.OpenAI.BingGroundingSearchToolOptions bingGrounding = null) { throw null; } + public static Azure.AI.Projects.OpenAI.BingGroundingSearchConfiguration BingGroundingSearchConfiguration(string projectConnectionId = null, string market = null, string setLang = null, long? count = default(long?), string freshness = null) { throw null; } + public static Azure.AI.Projects.OpenAI.BingGroundingSearchToolOptions BingGroundingSearchToolOptions(System.Collections.Generic.IEnumerable searchConfigurations = null) { throw null; } + public static Azure.AI.Projects.OpenAI.BrowserAutomationAgentTool BrowserAutomationAgentTool(Azure.AI.Projects.OpenAI.BrowserAutomationToolParameters browserAutomationPreview = null) { throw null; } + public static Azure.AI.Projects.OpenAI.BrowserAutomationToolConnectionParameters BrowserAutomationToolConnectionParameters(string projectConnectionId = null) { throw null; } + public static Azure.AI.Projects.OpenAI.BrowserAutomationToolParameters BrowserAutomationToolParameters(Azure.AI.Projects.OpenAI.BrowserAutomationToolConnectionParameters connection = null) { throw null; } + public static Azure.AI.Projects.OpenAI.CaptureStructuredOutputsTool CaptureStructuredOutputsTool(Azure.AI.Projects.OpenAI.StructuredOutputDefinition outputs = null) { throw null; } + public static Azure.AI.Projects.OpenAI.ChatSummaryMemoryItem ChatSummaryMemoryItem(string memoryId = null, System.DateTimeOffset updatedAt = default(System.DateTimeOffset), string scope = null, string content = null) { throw null; } + public static Azure.AI.Projects.OpenAI.ContainerApplicationAgentDefinition ContainerApplicationAgentDefinition(Azure.AI.Projects.OpenAI.ContentFilterConfiguration contentFilterConfiguration = null, System.Collections.Generic.IEnumerable containerProtocolVersions = null, string containerAppResourceId = null, string ingressSubdomainSuffix = null) { throw null; } + public static Azure.AI.Projects.OpenAI.ContentFilterConfiguration ContentFilterConfiguration(string policyName = null) { throw null; } + public static Azure.AI.Projects.OpenAI.FabricDataAgentToolOptions FabricDataAgentToolOptions(System.Collections.Generic.IEnumerable projectConnections = null) { throw null; } + public static Azure.AI.Projects.OpenAI.HostedAgentDefinition HostedAgentDefinition(Azure.AI.Projects.OpenAI.ContentFilterConfiguration contentFilterConfiguration = null, System.Collections.Generic.IEnumerable tools = null, System.Collections.Generic.IEnumerable containerProtocolVersions = null, string cpu = null, string memory = null, System.Collections.Generic.IDictionary environmentVariables = null) { throw null; } + public static Azure.AI.Projects.OpenAI.ImageBasedHostedAgentDefinition ImageBasedHostedAgentDefinition(Azure.AI.Projects.OpenAI.ContentFilterConfiguration contentFilterConfiguration = null, System.Collections.Generic.IEnumerable tools = null, System.Collections.Generic.IEnumerable containerProtocolVersions = null, string cpu = null, string memory = null, System.Collections.Generic.IDictionary environmentVariables = null, string image = null) { throw null; } + public static Azure.AI.Projects.OpenAI.LocalShellAgentTool LocalShellAgentTool() { throw null; } + public static Azure.AI.Projects.OpenAI.LocalShellAgentToolExecutionAction LocalShellAgentToolExecutionAction(System.Collections.Generic.IEnumerable command = null, int? timeoutMs = default(int?), string workingDirectory = null, System.Collections.Generic.IDictionary env = null, string user = null) { throw null; } + public static Azure.AI.Projects.OpenAI.LocalShellToolCallAgentResponseItem LocalShellToolCallAgentResponseItem(string id = null, Azure.AI.Projects.OpenAI.AgentResponseItemSource createdBy = null, Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus status = default(Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus), string callId = null, Azure.AI.Projects.OpenAI.LocalShellAgentToolExecutionAction action = null) { throw null; } + public static Azure.AI.Projects.OpenAI.LocalShellToolCallOutputAgentResponseItem LocalShellToolCallOutputAgentResponseItem(string id = null, Azure.AI.Projects.OpenAI.AgentResponseItemSource createdBy = null, Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus status = default(Azure.AI.Projects.OpenAI.LocalShellAgentToolCallStatus), string output = null) { throw null; } + public static Azure.AI.Projects.OpenAI.MemoryItem MemoryItem(string memoryId = null, System.DateTimeOffset updatedAt = default(System.DateTimeOffset), string scope = null, string content = null, string kind = null) { throw null; } + public static Azure.AI.Projects.OpenAI.MemorySearchItem MemorySearchItem(Azure.AI.Projects.OpenAI.MemoryItem memoryItem = null) { throw null; } + public static Azure.AI.Projects.OpenAI.MemorySearchTool MemorySearchTool(string memoryStoreName = null, string scope = null, Azure.AI.Projects.OpenAI.MemorySearchToolOptions searchOptions = null, int? updateDelay = default(int?)) { throw null; } + public static Azure.AI.Projects.OpenAI.MemorySearchToolCallResponseItem MemorySearchToolCallResponseItem(string id = null, Azure.AI.Projects.OpenAI.AgentResponseItemSource createdBy = null, Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus status = default(Azure.AI.Projects.OpenAI.MemorySearchToolCallStatus), System.Collections.Generic.IEnumerable results = null) { throw null; } + public static Azure.AI.Projects.OpenAI.MemorySearchToolOptions MemorySearchToolOptions(int? maxMemories = default(int?)) { throw null; } + public static Azure.AI.Projects.OpenAI.MicrosoftFabricAgentTool MicrosoftFabricAgentTool(Azure.AI.Projects.OpenAI.FabricDataAgentToolOptions fabricDataagentPreview = null) { throw null; } + public static Azure.AI.Projects.OpenAI.OAuthConsentRequestResponseItem OAuthConsentRequestResponseItem(Azure.AI.Projects.OpenAI.AgentResponseItemSource createdBy = null, string id = null, string consentLink = null, string serverLabel = null) { throw null; } + public static Azure.AI.Projects.OpenAI.OpenAPIAgentTool OpenAPIAgentTool(Azure.AI.Projects.OpenAI.OpenAPIFunctionDefinition openapi = null) { throw null; } + public static Azure.AI.Projects.OpenAI.OpenAPIAnonymousAuthenticationDetails OpenAPIAnonymousAuthenticationDetails() { throw null; } + public static Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails OpenAPIAuthenticationDetails(string type = null) { throw null; } + public static Azure.AI.Projects.OpenAI.OpenAPIFunctionDefinition OpenAPIFunctionDefinition(string name = null, string description = null, System.BinaryData spec = null, Azure.AI.Projects.OpenAI.OpenAPIAuthenticationDetails auth = null, System.Collections.Generic.IEnumerable defaultParams = null, System.Collections.Generic.IEnumerable functions = null) { throw null; } + public static Azure.AI.Projects.OpenAI.OpenAPIFunctionEntry OpenAPIFunctionEntry(string name = null, string description = null, System.BinaryData parameters = null) { throw null; } + public static Azure.AI.Projects.OpenAI.OpenAPIManagedAuthenticationDetails OpenAPIManagedAuthenticationDetails(Azure.AI.Projects.OpenAI.OpenApiManagedSecurityScheme securityScheme = null) { throw null; } + public static Azure.AI.Projects.OpenAI.OpenApiManagedSecurityScheme OpenApiManagedSecurityScheme(string audience = null) { throw null; } + public static Azure.AI.Projects.OpenAI.OpenAPIProjectConnectionAuthenticationDetails OpenAPIProjectConnectionAuthenticationDetails(Azure.AI.Projects.OpenAI.OpenAPIProjectConnectionSecurityScheme securityScheme = null) { throw null; } + public static Azure.AI.Projects.OpenAI.OpenAPIProjectConnectionSecurityScheme OpenAPIProjectConnectionSecurityScheme(string projectConnectionId = null) { throw null; } + public static Azure.AI.Projects.OpenAI.ProjectConversation ProjectConversation(string id = null, System.DateTimeOffset createdAt = default(System.DateTimeOffset), System.Collections.Generic.IDictionary metadata = null) { throw null; } + public static Azure.AI.Projects.OpenAI.ProjectConversationUpdateOptions ProjectConversationUpdateOptions(System.Collections.Generic.IDictionary metadata = null) { throw null; } + public static Azure.AI.Projects.OpenAI.ProtocolVersionRecord ProtocolVersionRecord(Azure.AI.Projects.OpenAI.AgentCommunicationMethod protocol = default(Azure.AI.Projects.OpenAI.AgentCommunicationMethod), string version = null) { throw null; } + public static Azure.AI.Projects.OpenAI.SharepointAgentTool SharepointAgentTool(Azure.AI.Projects.OpenAI.SharePointGroundingToolOptions sharepointGroundingPreview = null) { throw null; } + public static Azure.AI.Projects.OpenAI.SharePointGroundingToolOptions SharePointGroundingToolOptions(System.Collections.Generic.IEnumerable projectConnections = null) { throw null; } + public static Azure.AI.Projects.OpenAI.StructuredInputDefinition StructuredInputDefinition(string description = null, System.BinaryData defaultValue = null, System.BinaryData schema = null, bool? isRequired = default(bool?)) { throw null; } + public static Azure.AI.Projects.OpenAI.StructuredOutputDefinition StructuredOutputDefinition(string name = null, string description = null, System.BinaryData schema = null, bool? strict = default(bool?)) { throw null; } + public static Azure.AI.Projects.OpenAI.ToolProjectConnection ToolProjectConnection(string projectConnectionId = null) { throw null; } + public static Azure.AI.Projects.OpenAI.WorkflowAgentDefinition WorkflowAgentDefinition(Azure.AI.Projects.OpenAI.ContentFilterConfiguration contentFilterConfiguration = null, string workflowYaml = null) { throw null; } + } + public partial class ProjectVectorStoresClient : OpenAI.VectorStores.VectorStoreClient + { + protected ProjectVectorStoresClient() { } + } + public partial class PromptAgentDefinition : Azure.AI.Projects.OpenAI.AgentDefinition, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public PromptAgentDefinition(string model) { } + public string Instructions { get { throw null; } set { } } + public string Model { get { throw null; } set { } } + public OpenAI.Responses.ResponseReasoningOptions ReasoningOptions { get { throw null; } set { } } + public System.Collections.Generic.IDictionary StructuredInputs { get { throw null; } } + public float? Temperature { get { throw null; } set { } } + public OpenAI.Responses.ResponseTextOptions TextOptions { get { throw null; } set { } } + public System.Collections.Generic.IList Tools { get { throw null; } } + public float? TopP { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.PromptAgentDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.PromptAgentDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ProtocolVersionRecord : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ProtocolVersionRecord(Azure.AI.Projects.OpenAI.AgentCommunicationMethod protocol, string version) { } + public Azure.AI.Projects.OpenAI.AgentCommunicationMethod Protocol { get { throw null; } set { } } + public string Version { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.ProtocolVersionRecord JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.ProtocolVersionRecord PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.ProtocolVersionRecord System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.ProtocolVersionRecord System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public static partial class ResponseCreationOptionsExtensions + { + public static Azure.AI.Projects.OpenAI.AgentReference get_Agent(OpenAI.Responses.ResponseCreationOptions options) { throw null; } + public static string get_AgentConversationId(OpenAI.Responses.ResponseCreationOptions options) { throw null; } + public static string get_Model(OpenAI.Responses.ResponseCreationOptions options) { throw null; } + public static Azure.AI.Projects.OpenAI.ExtraDataDictionary get_StructuredInputs(OpenAI.Responses.ResponseCreationOptions options) { throw null; } + public static void set_Agent(OpenAI.Responses.ResponseCreationOptions options, Azure.AI.Projects.OpenAI.AgentReference value) { } + public static void set_AgentConversationId(OpenAI.Responses.ResponseCreationOptions options, string value) { } + public static void set_Model(OpenAI.Responses.ResponseCreationOptions options, string value) { } + public sealed partial class <>E__0 + { + internal <>E__0() { } + public Azure.AI.Projects.OpenAI.AgentReference Agent { get { throw null; } set { } } + public string AgentConversationId { get { throw null; } set { } } + public string Model { get { throw null; } set { } } + public Azure.AI.Projects.OpenAI.ExtraDataDictionary StructuredInputs { get { throw null; } } + } + } + public static partial class ResponseItemExtensions + { + public static Azure.AI.Projects.OpenAI.AgentResponseItem AsAgentResponseItem(this OpenAI.Responses.ResponseItem responseItem) { throw null; } + } + public static partial class ResponseToolExtensions + { + public static Azure.AI.Projects.OpenAI.AgentTool AsAgentTool(this OpenAI.Responses.ResponseTool responseTool) { throw null; } + } + public partial class SharepointAgentTool : Azure.AI.Projects.OpenAI.AgentTool, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public SharepointAgentTool(Azure.AI.Projects.OpenAI.SharePointGroundingToolOptions sharepointGroundingPreview) { } + public Azure.AI.Projects.OpenAI.SharePointGroundingToolOptions SharepointGroundingPreview { get { throw null; } set { } } + protected override Azure.AI.Projects.OpenAI.AgentTool JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentTool PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.SharepointAgentTool System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.SharepointAgentTool System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class SharePointGroundingToolOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public SharePointGroundingToolOptions() { } + public System.Collections.Generic.IList ProjectConnections { get { throw null; } } + protected virtual Azure.AI.Projects.OpenAI.SharePointGroundingToolOptions JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.SharePointGroundingToolOptions PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.SharePointGroundingToolOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.SharePointGroundingToolOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class StructuredInputDefinition : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public StructuredInputDefinition() { } + public System.BinaryData DefaultValue { get { throw null; } set { } } + public string Description { get { throw null; } set { } } + public bool? IsRequired { get { throw null; } set { } } + public System.BinaryData Schema { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.StructuredInputDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.StructuredInputDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.StructuredInputDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.StructuredInputDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class StructuredOutputDefinition : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public StructuredOutputDefinition(string name, string description, System.BinaryData schema, bool? strict) { } + public string Description { get { throw null; } set { } } + public string Name { get { throw null; } set { } } + public System.BinaryData Schema { get { throw null; } set { } } + public bool? Strict { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.StructuredOutputDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.StructuredOutputDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.StructuredOutputDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.StructuredOutputDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ToolProjectConnection : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ToolProjectConnection(string projectConnectionId) { } + public string ProjectConnectionId { get { throw null; } set { } } + protected virtual Azure.AI.Projects.OpenAI.ToolProjectConnection JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.OpenAI.ToolProjectConnection PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.ToolProjectConnection System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.ToolProjectConnection System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class WorkflowAgentDefinition : Azure.AI.Projects.OpenAI.AgentDefinition, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal WorkflowAgentDefinition() { } + public static Azure.AI.Projects.OpenAI.WorkflowAgentDefinition FromYaml(string workflowYamlDocument) { throw null; } + protected override Azure.AI.Projects.OpenAI.AgentDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.OpenAI.AgentDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OpenAI.WorkflowAgentDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OpenAI.WorkflowAgentDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/assets.json b/sdk/ai/Azure.AI.Projects.OpenAI/assets.json new file mode 100644 index 000000000000..c6c3de221018 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/assets.json @@ -0,0 +1,6 @@ +{ + "AssetsRepo": "Azure/azure-sdk-assets", + "AssetsRepoPrefixPath": "net", + "TagPrefix": "net/ai/Azure.AI.Projects.OpenAI", + "Tag": "net/ai/Azure.AI.Projects.OpenAI_ed5f3bf439" +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample10_ComputerUse.md b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample10_ComputerUse.md new file mode 100644 index 000000000000..b91fafb0e477 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample10_ComputerUse.md @@ -0,0 +1,259 @@ +# Sample for use of an Agent with Computer Use tool in Azure.AI.Projects.OpenAI. + +To enable your Agent to Computer Use tool, you need to use `ComputerTool` while creating `PromptAgentDefinition`. +1. First, we need to create project client and read the environment variables, which will be used in the next steps. + +```C# Snippet:Sample_CreateAgentClient_ComputerUse +var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); +var modelDeploymentName = System.Environment.GetEnvironmentVariable("COMPUTER_USE_DEPLOYMENT_NAME"); +AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); +``` + +2. To use the tool, we need to read image files using `ReadImageFile` method. + +Synchronous sample: +```C# Snippet:Sample_ReadImageFile_ComputerUse +private static BinaryData ReadImageFile(string name, [CallerFilePath] string pth = "") +{ + var dirName = Path.GetDirectoryName(pth) ?? ""; + return new BinaryData(File.ReadAllBytes(Path.Combine(dirName, name))); +} +``` + +3. In this example we will read in three example screenshots and place them into a dictionary. + +```C# Snippet:Sample_ReadImageFilesToDictionaries_ComputerUse +Dictionary screenshots = new() { + { "browser_search", ReadImageFile("Assets/cua_browser_search.png")}, + { "search_typed", ReadImageFile("Assets/cua_search_typed.png")}, + { "search_results", ReadImageFile("Assets/cua_search_results.png")}, +}; +``` + +4. Create a `PromptAgentDefinition` with `ComputerTool`. + +Synchronous sample: +```C# Snippet:Sample_CreateAgent_ComputerUse_Sync +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a computer automation assistant.\n\n" + + "Be direct and efficient. When you reach the search results page, read and describe the actual search result titles and descriptions you can see.", + Tools = { + ResponseTool.CreateComputerTool( + environment: new ComputerToolEnvironment("windows"), + displayWidth: 1026, + displayHeight: 769 + ), + } +}; +AgentVersion agentVersion = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent", + options: new(agentDefinition) +); +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateAgent_ComputerUse_Async +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a computer automation assistant.\n\n" + + "Be direct and efficient. When you reach the search results page, read and describe the actual search result titles and descriptions you can see.", + Tools = { + ResponseTool.CreateComputerTool( + environment: new ComputerToolEnvironment("windows"), + displayWidth: 1026, + displayHeight: 769 + ), + } +}; +AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent", + options: new(agentDefinition) +); +``` + +4. Create a helper method to parse the ComputerTool outputs and to respond to Agents queries with new screenshots. Please note that throughout this sample we set the media type for image. Agents support `image/jpeg`, `image/png`, `image/gif` and `image/webp` media types. + +```C# Snippet:Sample_ProcessComputerUseCall_ComputerUse +private static string ProcessComputerUseCall(ComputerCallResponseItem item, string oldScreenshot) +{ + string currentScreenshot = "browser_search"; + switch (item.Action.Kind) + { + case ComputerCallActionKind.Type: + Console.WriteLine($" Typing text \"{item.Action.TypeText}\" - Simulating keyboard input"); + currentScreenshot = "search_typed"; + break; + case ComputerCallActionKind.KeyPress: + HashSet codes = [.. item.Action.KeyPressKeyCodes]; + if (codes.Contains("Return") || codes.Contains("ENTER")) + { + // If we have typed the value to the search field, go to search results. + if (string.Equals(oldScreenshot, "search_typed")) + { + Console.WriteLine(" -> Detected ENTER key press, when search field was populated, displaying results."); + currentScreenshot = "search_results"; + } + else + { + Console.WriteLine(" -> Detected ENTER key press, on results or unpopulated search, do nothing."); + currentScreenshot = oldScreenshot; + } + } + else + { + Console.WriteLine($" Key press: {item.Action.KeyPressKeyCodes.Aggregate("", (agg, next) => agg + "+" + next)} - Simulating key combination"); + } + break; + case ComputerCallActionKind.Click: + Console.WriteLine($" Click at ({item.Action.ClickCoordinates.Value.X}, {item.Action.ClickCoordinates.Value.Y}) - Simulating click on UI element"); + if (string.Equals(oldScreenshot, "search_typed")) + { + Console.WriteLine(" -> Assuming click on Search button when search field was populated, displaying results."); + currentScreenshot = "search_results"; + } + else + { + Console.WriteLine(" -> Assuming click on Search on results or when search was not populated, do nothing."); + currentScreenshot = oldScreenshot; + } + break; + case ComputerCallActionKind.Drag: + string pathStr = item.Action.DragPath.ToArray().Select(p => $"{p.X}, {p.Y}").Aggregate("", (agg, next) => $"{agg} -> {next}"); + Console.WriteLine($" Drag path: {pathStr} - Simulating drag operation"); + break; + case ComputerCallActionKind.Scroll: + Console.WriteLine($" Scroll at ({item.Action.ScrollCoordinates.Value.X}, {item.Action.ScrollCoordinates.Value.Y}) - Simulating scroll action"); + break; + case ComputerCallActionKind.Screenshot: + Console.WriteLine(" Taking screenshot - Capturing current screen state"); + break; + default: + break; + } + Console.WriteLine($" -> Action processed: {item.Action.Kind}"); + + return currentScreenshot; +} +``` + +5. For brevity create the methods to get the response. + +Synchronous sample: +```C# Snippet:Sample_CreateNextResponse_ComputerUse_Sync +public static OpenAIResponse CreateResponse(OpenAIResponseClient responseClient, IEnumerable items, ResponseCreationOptions options) +{ + OpenAIResponse response = responseClient.CreateResponse( + inputItems: items, + options: options); + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + return response; +} +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateNextResponse_ComputerUse_Async +public static async Task CreateResponseAsync(OpenAIResponseClient responseClient, IEnumerable items, ResponseCreationOptions options) +{ + OpenAIResponse response = await responseClient.CreateResponseAsync( + inputItems: items, + options: options); + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + return response; +} +``` + +6. Create an `OpenAIResponse` using `ResponseItem`, containing two `ResponseContentPart`: one with the image and another with the text. In the loop we will request Agent while it is continuing to browse web. Finally, print the tool output message. + +Synchronous sample: +```C# Snippet:Sample_CreateResponse_ComputerUse_Sync +ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name); +ResponseCreationOptions responseOptions = new(); +responseOptions.TruncationMode = ResponseTruncationMode.Auto; +string currentScreenshot = "browser_search"; +ResponseItem request = ResponseItem.CreateUserMessageItem( + [ + ResponseContentPart.CreateInputTextPart("I need you to help me search for 'OpenAI news'. Please type 'OpenAI news' and submit the search. Once you see search results, the task is complete."), + ResponseContentPart.CreateInputImagePart(imageBytes: screenshots["browser_search"], imageBytesMediaType: "image/png", imageDetailLevel: ResponseImageDetailLevel.High) + ] +); +List inputItems = [request]; +bool computerUseCalled = false; +int limitIteration = 10; +OpenAIResponse response; +do +{ + response = CreateResponse( + responseClient, + inputItems, + responseOptions); + computerUseCalled = false; + inputItems.Clear(); + responseOptions.PreviousResponseId = response.Id; + foreach (ResponseItem responseItem in response.OutputItems) + { + inputItems.Add(responseItem); + if (responseItem is ComputerCallResponseItem computerCall) + { + currentScreenshot = ProcessComputerUseCall(computerCall, currentScreenshot); + inputItems.Add(ResponseItem.CreateComputerCallOutputItem(callId: computerCall.CallId, output: ComputerCallOutput.CreateScreenshotOutput(screenshotImageBytes: screenshots[currentScreenshot], screenshotImageBytesMediaType: "image/png"))); + computerUseCalled = true; + } + } + limitIteration--; +} while (computerUseCalled && limitIteration > 0); +Console.WriteLine(response.GetOutputText()); +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateResponse_ComputerUse_Async +ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name); +ResponseCreationOptions responseOptions = new(); +responseOptions.TruncationMode = ResponseTruncationMode.Auto; +ResponseItem request = ResponseItem.CreateUserMessageItem( + [ + ResponseContentPart.CreateInputTextPart("I need you to help me search for 'OpenAI news'. Please type 'OpenAI news' and submit the search. Once you see search results, the task is complete."), + ResponseContentPart.CreateInputImagePart(imageBytes: screenshots["browser_search"], imageBytesMediaType: "image/png", imageDetailLevel: ResponseImageDetailLevel.High) + ] +); +List inputItems = [request]; +bool computerUseCalled = false; +string currentScreenshot = "browser_search"; +int limitIteration = 10; +OpenAIResponse response; +do +{ + response = await CreateResponseAsync( + responseClient, + inputItems, + responseOptions + ); + computerUseCalled = false; + responseOptions.PreviousResponseId = response.Id; + inputItems.Clear(); + foreach (ResponseItem responseItem in response.OutputItems) + { + inputItems.Add(responseItem); + if (responseItem is ComputerCallResponseItem computerCall) + { + currentScreenshot = ProcessComputerUseCall(computerCall, currentScreenshot); + inputItems.Add(ResponseItem.CreateComputerCallOutputItem(callId: computerCall.CallId, output: ComputerCallOutput.CreateScreenshotOutput(screenshotImageBytes: screenshots[currentScreenshot], screenshotImageBytesMediaType: "image/png"))); + computerUseCalled = true; + } + } + limitIteration--; +} while (computerUseCalled && limitIteration > 0); +Console.WriteLine(response.GetOutputText()); +``` + +7. Clean up resources by deleting Agent. + +Synchronous sample: +```C# Snippet:Sample_Cleanup_ComputerUse_Sync +projectClient.Agents.DeleteAgentVersion(agentName: agentVersion.Name, agentVersion: agentVersion.Version); +``` + +Asynchronous sample: +```C# Snippet:Sample_Cleanup_ComputerUse_Async +await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion.Name, agentVersion: agentVersion.Version); +``` diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample11_FileSearch_Streaming.md b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample11_FileSearch_Streaming.md new file mode 100644 index 000000000000..8fee14efc855 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample11_FileSearch_Streaming.md @@ -0,0 +1,201 @@ +# Sample file search with Agent in Azure.AI.Projects.OpenAI in streaming scenarios. + +In this example we will create the local file, upload it to Azure and will use it in the newly created `VectorStore` for file search. + +1. First, we need to create project client and read the environment variables, which will be used in the next steps. + +```C# Snippet:Sample_CreateAgentClient_FileSearch_Streaming +var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); +var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); +``` + +2. We will create a toy example file and upload it using OpenAI mechanism. + +Synchronous sample: +```C# Snippet:Sample_UploadFile_FileSearch_Streaming_Sync +string filePath = "sample_file_for_upload.txt"; +File.WriteAllText( + path: filePath, + contents: "The word 'apple' uses the code 442345, while the word 'banana' uses the code 673457."); +OpenAIFile uploadedFile = projectClient.OpenAI.Files.UploadFile(filePath: filePath, purpose: FileUploadPurpose.Assistants); +File.Delete(filePath); +``` + +Asynchronous sample: +```C# Snippet:Sample_UploadFile_FileSearch_Streaming_Async +string filePath = "sample_file_for_upload.txt"; +File.WriteAllText( + path: filePath, + contents: "The word 'apple' uses the code 442345, while the word 'banana' uses the code 673457."); +OpenAIFile uploadedFile = await projectClient.OpenAI.Files.UploadFileAsync(filePath: filePath, purpose: FileUploadPurpose.Assistants); +File.Delete(filePath); +``` + +3. Create the `VectorStore` and provide it with uploaded file ID. + +Synchronous sample: +```C# Snippet:Sample_CreateVectorStore_FileSearch_Streaming_Sync +VectorStoreCreationOptions options = new() +{ + Name = "MySampleStore", + FileIds = { uploadedFile.Id } +}; +VectorStore vectorStore = projectClient.OpenAI.VectorStores.CreateVectorStore(options); +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateVectorStore_FileSearch_Streaming_Async +VectorStoreCreationOptions options = new() +{ + Name = "MySampleStore", + FileIds = { uploadedFile.Id } +}; +VectorStore vectorStore = await projectClient.OpenAI.VectorStores.CreateVectorStoreAsync(options); +``` + +2. Now we can create an agent capable of using File search. + +Synchronous sample: +```C# Snippet:Sample_CreateAgent_FileSearch_Streaming_Sync +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a helpful agent that can help fetch data from files you know about.", + Tools = { ResponseTool.CreateFileSearchTool(vectorStoreIds: [vectorStore.Id]), } +}; +AgentVersion agentVersion = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent", + options: new(agentDefinition) +); +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateAgent_FileSearch_Streaming_Async +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a helpful agent that can help fetch data from files you know about.", + Tools = { ResponseTool.CreateFileSearchTool(vectorStoreIds: [vectorStore.Id]), } +}; +AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent", + options: new(agentDefinition) +); +``` + +3. Create the conversation to store respones. + +Synchronous sample: +```C# Snippet:Sample_CreateResponse_FileSearch_Streaming_Sync +ProjectConversation conversation = projectClient.OpenAI.Conversations.CreateProjectConversation(); +ResponseCreationOptions responseOptions = new() +{ + Agent = agentVersion, + AgentConversationId = conversation.Id, +}; +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateResponse_FileSearch_Streaming_Async +ProjectConversation conversation = await projectClient.OpenAI.Conversations.CreateProjectConversationAsync(); +ResponseCreationOptions responseOptions = new() +{ + Agent = agentVersion, + AgentConversationId = conversation.Id, +}; +``` + +4. To format streaming response output we will create a helper method `ParseResponse`. If the stream ends up in error state, it will throw an error. + +```C# Snippet:Sample_ParseResponse_FileSearch_Streaming +private static void ParseResponse(StreamingResponseUpdate streamResponse) +{ + if (streamResponse is StreamingResponseCreatedUpdate createUpdate) + { + Console.WriteLine($"Stream response created with ID: {createUpdate.Response.Id}"); + } + else if (streamResponse is StreamingResponseOutputTextDeltaUpdate textDelta) + { + Console.WriteLine($"Delta: {textDelta.Delta}"); + } + else if (streamResponse is StreamingResponseOutputTextDoneUpdate textDoneUpdate) + { + Console.WriteLine($"Response done with full message: {textDoneUpdate.Text}"); + } + else if (streamResponse is StreamingResponseOutputItemDoneUpdate itemDoneUpdate) + { + if (itemDoneUpdate.Item is MessageResponseItem messageItem) + { + foreach (ResponseContentPart part in messageItem.Content) + { + foreach (ResponseMessageAnnotation annotation in part.OutputTextAnnotations) + { + if (annotation is FileCitationMessageAnnotation fileAnnotation) + { + // Note fileAnnotation.Filename will be available in OpenAI package versions + // greater then 2.6.0. + Console.WriteLine($"File Citation - File ID: {fileAnnotation.FileId}"); + } + } + } + } + } + else if (streamResponse is StreamingResponseErrorUpdate errorUpdate) + { + throw new InvalidOperationException($"The stream has failed with the error: {errorUpdate.Message}"); + } +} +``` + +5. Wait for the stream to complete. + +Synchronous sample: +```C# Snippet:Sample_StreamingResponse_FileSearch_Streaming_Sync +foreach (StreamingResponseUpdate streamResponse in projectClient.OpenAI.Responses.CreateResponseStreaming("Can you give me the documented codes for 'banana' and 'orange'?", responseOptions)) +{ + ParseResponse(streamResponse); +} +``` + +Asynchronous sample: +```C# Snippet:Sample_StreamingResponse_FileSearch_Streaming_Async +await foreach (StreamingResponseUpdate streamResponse in projectClient.OpenAI.Responses.CreateResponseStreamingAsync("Can you give me the documented codes for 'banana' and 'orange'?", responseOptions)) +{ + ParseResponse(streamResponse); +} +``` + +6. Ask follow up question and start a new stream. + +Synchronous sample: +```C# Snippet:Sample_FollowUp_FileSearch_Streaming_Sync +Console.WriteLine("Demonstrating follow-up query with streaming..."); +foreach (StreamingResponseUpdate streamResponse in projectClient.OpenAI.Responses.CreateResponseStreaming("What was my previous question about?", responseOptions)) +{ + ParseResponse(streamResponse); +} +``` + +Asynchronous sample: +```C# Snippet:Sample_FollowUp_FileSearch_Streaming_Async +Console.WriteLine("Demonstrating follow-up query with streaming..."); +await foreach (StreamingResponseUpdate streamResponse in projectClient.OpenAI.Responses.CreateResponseStreamingAsync("What was my previous question about?", responseOptions)) +{ + ParseResponse(streamResponse); +} +``` + +5. Finally, delete all the resources, we have created in this sample. + +Synchronous sample: +```C# Snippet:Sample_Cleanup_FileSearch_Streaming_Sync +projectClient.Agents.DeleteAgentVersion(agentName: agentVersion.Name, agentVersion: agentVersion.Version); +projectClient.OpenAI.VectorStores.DeleteVectorStore(vectorStoreId: vectorStore.Id); +projectClient.OpenAI.Files.DeleteFile(uploadedFile.Id); +``` + +Asynchronous sample: +```C# Snippet:Sample_Cleanup_FileSearch_Streaming_Async +await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion.Name, agentVersion: agentVersion.Version); +await projectClient.OpenAI.VectorStores.DeleteVectorStoreAsync(vectorStoreId: vectorStore.Id); +await projectClient.OpenAI.Files.DeleteFileAsync(uploadedFile.Id); +``` diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample12_ResponseStreaming.md b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample12_ResponseStreaming.md new file mode 100644 index 000000000000..713f60cdd2f1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample12_ResponseStreaming.md @@ -0,0 +1,66 @@ +# Sample on getting the responses in Azure.AI.Projects.OpenAI in streaming scenarios. + +In this example we will demonstrate how to get a response in streaming scenarios. + +1. First, we need to create project client and read the environment variables, which will be used in the next steps. + +```C# Snippet:Sample_CreateAgentClient_ResponseStreaming +var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); +var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); +``` + +2. Use the client to create a `ProjectOpenAIResponseClient`, which will be used to create stream. + +Synchronous sample: +```C# Snippet:Sample_CreateResponseStreaming +ProjectResponsesClient responsesClient = projectClient.OpenAI.GetProjectResponsesClientForModel(modelDeploymentName); +``` + +3. Stream the results; raise the error if the request was not successful. + +Synchronous sample: +```C# Snippet:Sample_WriteOutput_ResponseStreaming_Sync +foreach (StreamingResponseUpdate streamResponse in responsesClient.CreateResponseStreaming("What is the size of France in square miles?")) +{ + if (streamResponse is StreamingResponseCreatedUpdate createUpdate) + { + Console.WriteLine($"Stream response created with ID: {createUpdate.Response.Id}"); + } + else if (streamResponse is StreamingResponseOutputTextDeltaUpdate textDelta) + { + Console.WriteLine($"Delta: {textDelta.Delta}"); + } + else if (streamResponse is StreamingResponseOutputTextDoneUpdate textDoneUpdate) + { + Console.WriteLine($"Response done with full message: {textDoneUpdate.Text}"); + } + else if (streamResponse is StreamingResponseErrorUpdate errorUpdate) + { + throw new InvalidOperationException($"The stream has failed with the error: {errorUpdate.Message}"); + } +} +``` + +Asynchronous sample: +```C# Snippet:Sample_WriteOutput_ResponseStreaming_Async +await foreach (StreamingResponseUpdate streamResponse in responsesClient.CreateResponseStreamingAsync("What is the size of France in square miles?")) +{ + if (streamResponse is StreamingResponseCreatedUpdate createUpdate) + { + Console.WriteLine($"Stream response created with ID: {createUpdate.Response.Id}"); + } + else if (streamResponse is StreamingResponseOutputTextDeltaUpdate textDelta) + { + Console.WriteLine($"Delta: {textDelta.Delta}"); + } + else if (streamResponse is StreamingResponseOutputTextDoneUpdate textDoneUpdate) + { + Console.WriteLine($"Response done with full message: {textDoneUpdate.Text}"); + } + else if (streamResponse is StreamingResponseErrorUpdate errorUpdate) + { + throw new InvalidOperationException($"The stream has failed with the error: {errorUpdate.Message}"); + } +} +``` diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample13_WebSearch.md b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample13_WebSearch.md new file mode 100644 index 000000000000..6a9b185ab072 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample13_WebSearch.md @@ -0,0 +1,72 @@ +# Sample web search with agent in Azure.AI.Projects.OpenAI. + +In this example we will use the Agent to perform the web search in given location. + +1. First, we need to create project client and read the environment variables, which will be used in the next steps. + +```C# Snippet:Sample_CreateAgentClient_WebSearch +var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); +var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); +``` + +2. Create an Agent capable of using Web search. In the `WebSearchToolLocation` we will set the location to be London. + +Synchronous sample: +```C# Snippet:Sample_CreateAgent_WebSearch_Sync +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a helpful assistant that can search the web", + Tools = { ResponseTool.CreateWebSearchTool(userLocation: WebSearchToolLocation.CreateApproximateLocation(country: "GB", city: "London", region: "London")), } +}; +AgentVersion agentVersion = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent", + options: new(agentDefinition)); +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateAgent_WebSearch_Async +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a helpful assistant that can search the web", + Tools = { ResponseTool.CreateWebSearchTool(userLocation: WebSearchToolLocation.CreateApproximateLocation(country: "GB", city: "London", region: "London")), } +}; +AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent", + options: new(agentDefinition)); +``` + +3. Ask the question related to London. + +Synchronous sample: +```C# Snippet:Sample_CreateResponse_WebSearch_Sync +ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name); + +OpenAIResponse response = responseClient.CreateResponse("Show me the latest London Underground service updates"); +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateResponse_WebSearch_Async +ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name); + +OpenAIResponse response = await responseClient.CreateResponseAsync("Show me the latest London Underground service updates"); +``` + +4. Create the response and throw an exception if the response contains the error. + +```C# Snippet:Sample_WaitForResponse_WebSearch +Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); +Console.WriteLine(response.GetOutputText()); +``` + +5. Finally, delete all the resources we have created in this sample. + +Synchronous sample: +```C# Snippet:Sample_Cleanup_WebSearch_Sync +projectClient.Agents.DeleteAgentVersion(agentName: agentVersion.Name, agentVersion: agentVersion.Version); +``` + +Asynchronous sample: +```C# Snippet:Sample_Cleanup_WebSearch_Async +await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion.Name, agentVersion: agentVersion.Version); +``` diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample1_Agent_Versions.md b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample1_Agent_Versions.md new file mode 100644 index 000000000000..f6d455e1e026 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample1_Agent_Versions.md @@ -0,0 +1,113 @@ +# Sample for basic use of a versioned agent in Azure.AI.Projects.OpenAI. + +In this example we will demonstrate creation and basic use of an agent step by step. + +1. First, we need to create project client and read the environment variables, which will be used in the next steps. + +```C# Snippet:Sample_CreateAgentClient +var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); +var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); +``` + +2. Use the client to create the versioned agent object. + +Synchronous sample: +```C# Snippet:Sample_CreateAgentVersion_Sync +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a prompt agent." +}; +AgentVersion agentVersion = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent", + options: new(agentDefinition)); +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateAgentVersion_Async +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a prompt agent." +}; +AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent", + options: new(agentDefinition)); +``` + +3. List all agents named "myAgent". + +Synchronous sample: +```C# Snippet:Sample_ListAgentVersions_Sync +var agentVersions = projectClient.Agents.GetAgentVersions(agentName: "myAgent"); +foreach (AgentVersion oneAgentVersion in agentVersions) +{ + Console.WriteLine($"Agent: {oneAgentVersion.Id}, Name: {oneAgentVersion.Name}, Version: {oneAgentVersion.Version}"); +} +``` + +Asynchronous sample: +```C# Snippet:Sample_ListAgentVersions_Async +var agentVersions = projectClient.Agents.GetAgentVersionsAsync(agentName: "myAgent"); +await foreach (AgentVersion oneAgentVersion in agentVersions) +{ + Console.WriteLine($"Agent: {oneAgentVersion.Id}, Name: {oneAgentVersion.Name}, Version: {oneAgentVersion.Version}"); +} +``` + +4. To automatically store history, we can optionally create a conversation to use with the agent: + +Synchronous sample: +```C# Snippet:Sample_CreateConversation_Sync +ProjectConversation conversation + = projectClient.OpenAI.Conversations.CreateProjectConversation(); +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateConversation_Async +ProjectConversation conversation + = await projectClient.OpenAI.Conversations.CreateProjectConversationAsync(); +``` + +5. Ask question for an agent. + +Synchronous sample: +```C# Snippet:Sample_CreateSimpleResponse_Sync +OpenAIResponseClient responseClient + = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion, conversation.Id); + +OpenAIResponse response = responseClient.CreateResponse("Hello, tell me a joke."); +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateSimpleResponse_Async +OpenAIResponseClient responseClient + = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion, conversation.Id); + +OpenAIResponse response = await responseClient.CreateResponseAsync("Hello, tell me a joke."); +``` + +6. Print the output; raise the error if the request was not successful. + +Synchronous sample: +```C# Snippet:Sample_WriteOutput_Sync +Console.WriteLine(response.GetOutputText()); +``` + +Asynchronous sample: +```C# Snippet:Sample_WriteOutput_Async +Console.WriteLine(response.GetOutputText()); +``` + +7. Clean up resources by deleting conversation and agent. + +Synchronous sample: +```C# Snippet:Sample_Cleanup_Sync +projectClient.OpenAI.Conversations.DeleteConversation(conversationId: conversation.Id); +projectClient.Agents.DeleteAgentVersion(agentName: agentVersion.Name, agentVersion: agentVersion.Version); +``` + +Asynchronous sample: +```C# Snippet:Sample_Cleanup_Async +await projectClient.OpenAI.Conversations.DeleteConversationAsync(conversationId: conversation.Id); +await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion.Name, agentVersion: agentVersion.Version); +``` diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample2_Image_Generation.md b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample2_Image_Generation.md new file mode 100644 index 000000000000..786f1bc334cb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample2_Image_Generation.md @@ -0,0 +1,123 @@ +# Sample for image generation in Azure.AI.Projects.OpenAI. + +In this example we will demonstrate how to generate an image based on prompt. + +1. First, we need to create project client and read the environment variables, which will be used in the next steps. + +```C# Snippet:Sample_CreateClient_ImageGeneration +var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); +var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +var imageGenerationModelName = System.Environment.GetEnvironmentVariable("IMAGE_GENERATION_DEPLOYMENT_NAME"); +AIProjectClientOptions projectOptions = new(); +projectOptions.AddPolicy(new HeaderPolicy(imageGenerationModelName), PipelinePosition.PerCall); +AIProjectClient projectClient = new( + endpoint: new Uri(projectEndpoint), + tokenProvider: new DefaultAzureCredential(), + options: projectOptions +); +``` + +2. Use the client to create the versioned agent object. To generate images, we need to provide agent with the `ImageGenerationTool` when we are creating this tool. The `ImageGenerationTool` parameters include the image generation model, image quality and resolution. Supported image generation models are `gpt-image-1` and `gpt-image-1-mini`. + +Synchronous sample: +```C# Snippet:Sample_CreateAgent_ImageGeneration_Sync +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "Generate images based on user prompts.", + Tools = { + ResponseTool.CreateImageGenerationTool( + model: imageGenerationModelName, + quality: ImageGenerationToolQuality.Low, + size:ImageGenerationToolSize.W1024xH1024 + ) + } +}; +AgentVersion agentVersion = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent", + options: new(agentDefinition)); +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateAgent_ImageGeneration_Async +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "Generate images based on user prompts.", + Tools = { + ResponseTool.CreateImageGenerationTool( + model: imageGenerationModelName, + quality: ImageGenerationToolQuality.Low, + size:ImageGenerationToolSize.W1024xH1024 + ) + } +}; +AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent", + options: new(agentDefinition)); +``` + +3. To use image generation, we will need to provide the custom header to web requests, containing model deployment name, for example `x-ms-oai-image-generation-deployment: gpt-image-1`. To implement it we need to create custom header policy. + +```C# Snippet:Sample_CustomHeader_ImageGeneration +internal class HeaderPolicy(string image_deployment) : PipelinePolicy +{ + private const string image_deployment_header = "x-ms-oai-image-generation-deployment"; + + public override void Process(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) + { + message.Request.Headers.Add(image_deployment_header, image_deployment); + ProcessNext(message, pipeline, currentIndex); + } + + public override async ValueTask ProcessAsync(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) + { + // Add your desired header name and value + message.Request.Headers.Add(image_deployment_header, image_deployment); + await ProcessNextAsync(message, pipeline, currentIndex); + } +} +``` + +4. Use the policy to create the `OpenAIClient` object and create the `OpenAIResponseClient` by asking the Agent to generate the image. + +Synchronous sample: +```C# Snippet:Sample_GetResponse_ImageGeneration_Sync +ProjectOpenAIClientOptions options = new(); +ProjectOpenAIClient openAIClient = projectClient.GetProjectOpenAIClient(); +ProjectResponsesClient responseClient = openAIClient.GetProjectResponsesClientForAgent(new AgentReference(name: agentVersion.Name)); + +OpenAIResponse response = responseClient.CreateResponse("Generate parody of Newton with apple."); +``` + +Asynchronous sample: +```C# Snippet:Sample_GetResponse_ImageGeneration_Async +ProjectOpenAIClientOptions options = new(); +ProjectOpenAIClient openAIClient = projectClient.GetProjectOpenAIClient(options: options); +ProjectResponsesClient responseClient = openAIClient.GetProjectResponsesClientForAgent(new AgentReference(name: agentVersion.Name)); + +OpenAIResponse response = await responseClient.CreateResponseAsync("Generate parody of Newton with apple."); +``` + +5. Parse the `OpenAIResponse` object and save the generated image. + +```C# Snippet:Sample_SaveImage_ImageGeneration +foreach (ResponseItem item in response.OutputItems) +{ + if (item is ImageGenerationCallResponseItem imageItem) + { + File.WriteAllBytes("newton.png", imageItem.ImageResultBytes.ToArray()); + Console.WriteLine($"Image downloaded and saved to: {Path.GetFullPath("newton.png")}"); + } +} +``` + +6. Clean up resources by deleting the Agent. + +Synchronous sample: +```C# Snippet:Sample_Cleanup_ImageGeneration_Sync +projectClient.Agents.DeleteAgentVersion(agentName: agentVersion.Name, agentVersion: agentVersion.Version); +``` + +Asynchronous sample: +```C# Snippet:Sample_Cleanup_ImageGeneration_Async +await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion.Name, agentVersion: agentVersion.Version); +``` diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample3_Conversations_CRUD.md b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample3_Conversations_CRUD.md new file mode 100644 index 000000000000..e0eafe5c0cab --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample3_Conversations_CRUD.md @@ -0,0 +1,103 @@ +# Sample for Create, Read, Update and Delete (CRUD) conversations in Azure.AI.Projects.OpenAI. + +In this example we will demonstrate creation and basic use of an `ConversationResource` objects step by step. + +1. First, we need to create project client and read the environment variables, which will be used in the next steps. + +```C# Snippet:Sample_CreateAgentClient_ConversationCRUD +var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); +AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); +``` + +2. Use the client to create a `ConversationClient`, which will be used to create two `ProjectConversation` objects. + +Synchronous sample: +```C# Snippet:Sample_CreateConversations_ConversationCRUD_Sync +ProjectConversation conversation1 = projectClient.OpenAI.Conversations.CreateProjectConversation(); +Console.WriteLine($"Created conversation (id: {conversation1.Id})"); + +ProjectConversation conversation2 = projectClient.OpenAI.Conversations.CreateProjectConversation(); +Console.WriteLine($"Created conversation (id: {conversation2.Id})"); +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateConversations_ConversationCRUD_Async +ProjectConversation conversation1 = await projectClient.OpenAI.Conversations.CreateProjectConversationAsync(); +Console.WriteLine($"Created conversation (id: {conversation1.Id})"); + +ProjectConversation conversation2 = await projectClient.OpenAI.Conversations.CreateProjectConversationAsync(); +Console.WriteLine($"Created conversation (id: {conversation2.Id})"); +``` + +3. Retrieve the `ProjectConversation` object. + +Synchronous sample: +```C# Snippet:Sample_GetConversation_ConversationCRUD_Sync +ProjectConversation conversation = projectClient.OpenAI.Conversations.GetProjectConversation(conversationId: conversation1.Id); +Console.WriteLine($"Got conversation (id: {conversation.Id}, metadata: {conversation.Metadata})"); +``` + +Asynchronous sample: +```C# Snippet:Sample_GetConversation_ConversationCRUD_Async +ProjectConversation conversation = await projectClient.OpenAI.Conversations.GetProjectConversationAsync(conversationId: conversation1.Id); +Console.WriteLine($"Got conversation (id: {conversation.Id}, metadata: {conversation.Metadata})"); +``` + +4. List all `ProjectConversation` objects. + +Synchronous sample: +```C# Snippet:Sample_ListConversations_ConversationCRUD_Sync +foreach (ProjectConversation res in projectClient.OpenAI.Conversations.GetProjectConversations()) +{ + Console.WriteLine($"Listed conversation (id: {res.Id})"); +} +``` + +Asynchronous sample: +```C# Snippet:Sample_ListConversations_ConversationCRUD_Async +await foreach (ProjectConversation res in projectClient.OpenAI.Conversations.GetProjectConversationsAsync()){ + Console.WriteLine($"Listed conversation (id: {res.Id})"); +} +``` + +5. Update the `ProjectConversation` object metadata and retrieve it again. + +Synchronous sample: +```C# Snippet:Sample_UpdateConversations_ConversationCRUD_Sync +ProjectConversationUpdateOptions updateOptions = new() +{ + Metadata = { ["key"] = "value" }, +}; +projectClient.OpenAI.Conversations.UpdateProjectConversation(conversation1.Id, updateOptions); + +// Get the updated conversation. +conversation = projectClient.OpenAI.Conversations.GetProjectConversation(conversationId: conversation1.Id); +Console.WriteLine($"Got conversation (id: {conversation.Id}, metadata: {conversation.Metadata})"); +``` + +Asynchronous sample: +```C# Snippet:Sample_UpdateConversations_ConversationCRUD_Async +ProjectConversationUpdateOptions updateOptions = new() +{ + Metadata = { ["key"] = "value" }, +}; +await projectClient.OpenAI.Conversations.UpdateProjectConversationAsync(conversation.Id, updateOptions); + +// Get the updated conversation. +conversation = await projectClient.OpenAI.Conversations.GetProjectConversationAsync(conversation1.Id); +Console.WriteLine($"Got conversation (id: {conversation.Id}, metadata: {conversation.Metadata})"); +``` + +6. Finally, remove `ProjectConversation` objects we have created. + +Synchronous sample: +```C# Snippet:Sample_DeleteConversations_ConversationCRUD_Sync +projectClient.OpenAI.Conversations.DeleteConversation(conversationId: conversation1.Id); +projectClient.OpenAI.Conversations.DeleteConversation(conversationId: conversation2.Id); +``` + +Asynchronous sample: +```C# Snippet:Sample_DeleteConversations_ConversationCRUD_Async +await projectClient.OpenAI.Conversations.DeleteConversationAsync(conversationId: conversation1.Id); +await projectClient.OpenAI.Conversations.DeleteConversationAsync(conversationId: conversation2.Id); +``` diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample4_ResponseBasic.md b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample4_ResponseBasic.md new file mode 100644 index 000000000000..2eea49ba2ed2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample4_ResponseBasic.md @@ -0,0 +1,37 @@ +# Sample on getting the responses without involving Agent in Azure.AI.Projects.OpenAI. + +In this example we will demonstrate how to get a response without an Agent. + +1. First, we need to project client and read the environment variables, which will be used in the next steps. + +```C# Snippet:Sample_CreateAgentClient_ResponseBasic +var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); +var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); +``` + +2. Use the client to create a `Responses`, which will be used to create `OpenAIResponse` object. + +Synchronous sample: +```C# Snippet:Sample_CreateResponse_Sync +ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForModel(modelDeploymentName); +OpenAIResponse response = responseClient.CreateResponse("What is the size of France in square miles?"); +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateResponse_Async +ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForModel(modelDeploymentName); +OpenAIResponse response = await responseClient.CreateResponseAsync("What is the size of France in square miles?"); +``` + +3. Write the response output, raise the error if the request was not successful. + +Synchronous sample: +```C# Snippet:Sample_WriteOutput_ResponseBasic_Sync +Console.WriteLine(response.GetOutputText()); +``` + +Asynchronous sample: +```C# Snippet:Sample_WriteOutput_ResponseBasic_Async +Console.WriteLine(response.GetOutputText()); +``` diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample5_MemorySearchTool.md b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample5_MemorySearchTool.md new file mode 100644 index 000000000000..c0c21090e28a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample5_MemorySearchTool.md @@ -0,0 +1,229 @@ +# Sample of using `MemorySearchTool` with Agent in Azure.AI.Projects.OpenAI. + +In this example we will demonstrate how to use `MemorySearchTool`. We will create `MemoryStoreObject` and store the conversaton there. Then we will create another Agent, capable to read it. + +1. First, we need to create project client and read the environment variables, which will be used in the next steps. + +```C# Snippet:Sample_MemoryTool +var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); +var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +var embeddingDeploymentName = System.Environment.GetEnvironmentVariable("EMBEDDING_MODEL_DEPLOYMENT_NAME"); +AIProjectClient projectClient = new(new Uri(projectEndpoint), new DefaultAzureCredential()); +``` + +2. Use the client to create the versioned agent object. + +Synchronous sample: +```C# Snippet:Sample_CreateAgent_MemoryTool_Sync +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a prompt agent." +}; +AgentVersion agentVersion = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent", + options: new(agentDefinition)); +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateAgent_MemoryTool_Async +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a prompt agent." +}; +AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent", + options: new(agentDefinition)); +``` + +4. Create a conversation and get the `OpenAIResponse` object. + +Synchronous sample: +```C# Snippet:Sample_CreateConversation_MemoryTool_Sync +ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name); + +ResponseItem request = ResponseItem.CreateUserMessageItem("Hello, tell me a joke."); +OpenAIResponse response = responseClient.CreateResponse([request]); +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateConversation_MemoryTool_Async +ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name); + +ResponseItem request = ResponseItem.CreateUserMessageItem("Hello, tell me a joke."); +OpenAIResponse response = await responseClient.CreateResponseAsync([request]); +``` + +5. Make sure the repone has completed and record the response items to `MemoryUpdateOptions` object. + +Synchronous sample: +```C# Snippet:Sample_WriteOutput_MemoryTool_Sync +string scope = "Joke from conversation"; +MemoryUpdateOptions memoryOptions = new(scope); +memoryOptions.Items.Add(request); +Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); +foreach (ResponseItem item in response.OutputItems) +{ + memoryOptions.Items.Add(item); +} +Console.WriteLine(response.GetOutputText()); +``` + +Asynchronous sample: +```C# Snippet:Sample_WriteOutput_MemoryTool_Async +string scope = "Joke from conversation"; +MemoryUpdateOptions memoryOptions = new(scope); +memoryOptions.Items.Add(request); +while (response.Status != ResponseStatus.Incomplete && response.Status != ResponseStatus.Failed && response.Status != ResponseStatus.Completed){ + await Task.Delay(TimeSpan.FromMilliseconds(500)); + response = await responseClient.GetResponseAsync(responseId: response.Id); +} +Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + +foreach (ResponseItem item in response.OutputItems) +{ + memoryOptions.Items.Add(item); +} +Console.WriteLine(response.GetOutputText()); +``` + +6. Create `MemoryStoreObject` and add the memory related to previous conversation, stored in `MemoryUpdateOptions`. + +Synchronous sample: +```C# Snippet:CreateMemoryStore_MemoryTool_Sync +MemoryStoreDefaultDefinition memoryStoreDefinition = new( + chatModel: modelDeploymentName, + embeddingModel: embeddingDeploymentName +); +MemoryStore memoryStore = projectClient.MemoryStores.CreateMemoryStore( + name: "jokeMemory", + definition: memoryStoreDefinition, + description: "Memory store for conversation." +); +MemoryUpdateResult updateResult = projectClient.MemoryStores.UpdateMemories(memoryStoreName: memoryStore.Name, options: memoryOptions); +while (updateResult.Status != MemoryStoreUpdateStatus.Failed && updateResult.Status != MemoryStoreUpdateStatus.Completed) +{ + Thread.Sleep(TimeSpan.FromMilliseconds(500)); + updateResult = await projectClient.MemoryStores.GetUpdateResultAsync(memoryStore.Name, updateResult.UpdateId); +} +``` + +Asynchronous sample: +```C# Snippet:CreateMemoryStore_MemoryTool_Async +MemoryStoreDefaultDefinition memoryStoreDefinition = new( + chatModel: modelDeploymentName, + embeddingModel: embeddingDeploymentName +); +MemoryStore memoryStore = await projectClient.MemoryStores.CreateMemoryStoreAsync( + name: "jokeMemory", + definition: memoryStoreDefinition, + description: "Memory store for conversation." +); +MemoryUpdateResult updateResult = await projectClient.MemoryStores.UpdateMemoriesAsync(memoryStoreName: memoryStore.Name, options: memoryOptions); +while (updateResult.Status != MemoryStoreUpdateStatus.Failed && updateResult.Status != MemoryStoreUpdateStatus.Completed) +{ + await Task.Delay(TimeSpan.FromMilliseconds(500)); + updateResult = await projectClient.MemoryStores.GetUpdateResultAsync(memoryStore.Name, updateResult.UpdateId); +} +``` + +7. Check that the memory store contain the relevant memories. + +Synchronous sample: +```C# Snippet:Sample_CheckMemorySearch_Sync +MemorySearchOptions searchOptions = new(scope) +{ + Items = { ResponseItem.CreateUserMessageItem("What was the joke?") }, +}; +MemoryStoreSearchResponse resp = projectClient.MemoryStores.SearchMemories( + memoryStoreName: memoryStore.Id, + options: searchOptions +); +Console.WriteLine("==The output from memory search tool.=="); +foreach (Azure.AI.Projects.MemorySearchItem item in resp.Memories) +{ + Console.WriteLine(item.MemoryItem.Content); +} +Console.WriteLine("==End of memory search tool output.=="); +``` + +Asynchronous sample: +```C# Snippet:Sample_CheckMemorySearch_Async +MemorySearchOptions opts = new(scope) +{ + Items = { ResponseItem.CreateUserMessageItem("What was the joke?") }, +}; +MemoryStoreSearchResponse resp = await projectClient.MemoryStores.SearchMemoriesAsync( + memoryStoreName: memoryStore.Name, + options: new(scope) +); +Console.WriteLine("==The output from memory tool.=="); +foreach (Azure.AI.Projects.MemorySearchItem item in resp.Memories) +{ + Console.WriteLine(item.MemoryItem.Content); +} +Console.WriteLine("==End of memory tool output.=="); +``` + +8. Create another Agent capable to use `MemorySearchTool`. + +Synchronous sample: +```C# Snippet:Sample_CreateAgentWithTool_MemoryTool_Sync +agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a prompt agent capable to access memorized conversation.", +}; +agentDefinition.Tools.Add(new MemorySearchTool(memoryStoreName: memoryStore.Name, scope: scope)); +AgentVersion agentVersion2 = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent2", + options: new(agentDefinition)); +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateAgentWithTool_MemoryTool_Async +agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a prompt agent capable to access memorized conversation.", +}; +agentDefinition.Tools.Add(new MemorySearchTool(memoryStoreName: memoryStore.Name, scope: scope)); +AgentVersion agentVersion2 = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent2", + options: new(agentDefinition)); +``` + +9. Create a new conversation and get the response about memorized answers. + +Synchronous sample: +```C# Snippet:Sample_AnotherConversation_MemoryTool_Sync +responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion2.Name); + +response = responseClient.CreateResponse( + [ResponseItem.CreateUserMessageItem("Please explain me the meaning of the joke from the previous conversation.")]); +Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); +Console.WriteLine(response.GetOutputText()); +``` + +Asynchronous sample: +```C# Snippet:Sample_AnotherConversation_MemoryTool_Async +responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion2.Name); + +response = await responseClient.CreateResponseAsync( + "Please explain me the meaning of the joke from the previous conversation."); +Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); +Console.WriteLine(response.GetOutputText()); +``` + +10. Clean up resources by deleting conversations and Agent. + +Synchronous sample: +```C# Snippet:Sample_Cleanup_MemoryTool_Sync +projectClient.MemoryStores.DeleteMemoryStore(name: memoryStore.Name); +projectClient.Agents.DeleteAgentVersion(agentName: agentVersion.Name, agentVersion: agentVersion.Version); +projectClient.Agents.DeleteAgentVersion(agentName: agentVersion2.Name, agentVersion: agentVersion2.Version); +``` + +Asynchronous sample: +```C# Snippet:Sample_Cleanup_MemoryTool_Async +await projectClient.MemoryStores.DeleteMemoryStoreAsync(name: memoryStore.Name); +await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion.Name, agentVersion: agentVersion.Version); +await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion2.Name, agentVersion: agentVersion2.Version); +``` diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample6_AgentContainerApp.md b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample6_AgentContainerApp.md new file mode 100644 index 000000000000..34d421b797af --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample6_AgentContainerApp.md @@ -0,0 +1,105 @@ +# Sample of using Azure Container App with Agent in Azure.AI.Projects.OpenAI. + +In this example we will demonstrate how to use [Azure Container App](https://learn.microsoft.com/azure/container-apps/ai-integration) in Azure.AI.Agents + +1. First, we need to create project client and read the environment variables, which will be used in the next steps. + +```C# Snippet:Sample_Create_client_ContainerApp +var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); +var containerAppResourceId = System.Environment.GetEnvironmentVariable("CONTAINER_APP_RESOURCE_ID"); +var ingressSubdomainSuffix = System.Environment.GetEnvironmentVariable("INGRESS_SUBDOMAIN_SUFFIX"); +var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); +``` + +2. Create the `ContainerAppAgentDefinition` object, holding information about the Azure Container App and use it to create the versioned agent object. + +Synchronous sample: +```C# Snippet:Sample_CreateContainerApp_ContainerApp_Sync +AgentVersion containerAgentVersion = projectClient.Agents.CreateAgentVersion( + agentName: "containerAgent", + options: new(new ContainerApplicationAgentDefinition( + containerProtocolVersions: [new ProtocolVersionRecord(protocol: AgentCommunicationMethod.Responses, version: "1")], + containerAppResourceId: containerAppResourceId, + ingressSubdomainSuffix: ingressSubdomainSuffix))); +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateContainerApp_ContainerApp_Async +AgentVersion containerAgentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "containerAgent", + options: new(new ContainerApplicationAgentDefinition( + containerProtocolVersions: [new ProtocolVersionRecord(protocol: AgentCommunicationMethod.Responses, version: "1")], + containerAppResourceId: containerAppResourceId, + ingressSubdomainSuffix: ingressSubdomainSuffix))); +``` + +4. Create an `ProjectConversation` conversation object, containing the first question. + +Synchronous sample: +```C# Snippet:Sample_CreateConversation_ContainerApp_Sync +ProjectConversationCreationOptions conversationOptions = new(); +conversationOptions.Items.Add( + ResponseItem.CreateUserMessageItem("What is the size of France in square miles?") +); +ProjectConversation conversation = projectClient.OpenAI.Conversations.CreateProjectConversation(options: conversationOptions); +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateConversation_ContainerApp_Async +ProjectConversationCreationOptions conversationOptions = new(); +conversationOptions.Items.Add( + ResponseItem.CreateUserMessageItem("What is the size of France in square miles?") +); +ProjectConversation conversation = await projectClient.OpenAI.Conversations.CreateProjectConversationAsync(conversationOptions); +``` + +5. Create a response for the first question; add another question to conversation and get the next response. + +Synchronous sample: +```C# Snippet:Sample_CommunicateWithTheAgent_ContainerApp_Sync +ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(containerAgentVersion, conversation); +OpenAIResponse response = responseClient.CreateResponse([]); +Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); +Console.WriteLine(response.GetOutputText()); + +projectClient.OpenAI.Conversations.CreateProjectConversationItems( + conversationId: conversation.Id, + items: [ResponseItem.CreateUserMessageItem("And what is the capital city?")]); +response = projectClient.OpenAI.Responses.CreateResponse([]); +Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); +Console.WriteLine(response.GetOutputText()); +``` + +Asynchronous sample: +```C# Snippet:Sample_CommunicateWithTheAgent_ContainerApp_Async +ResponseCreationOptions responseOptions = new() +{ + Agent = containerAgentVersion, + AgentConversationId = conversation.Id, +}; +OpenAIResponse response = await projectClient.OpenAI.Responses.CreateResponseAsync([], responseOptions); +Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); +Console.WriteLine(response.GetOutputText()); + +await projectClient.OpenAI.Conversations.CreateProjectConversationItemsAsync( + conversationId: conversation.Id, + items: [ResponseItem.CreateUserMessageItem("And what is the capital city?")]); +response = await projectClient.OpenAI.Responses.CreateResponseAsync([], responseOptions); +Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); +Console.WriteLine(response.GetOutputText()); +``` + +6. Clean up resources by deleting conversations and Agent. + +Synchronous sample: +```C# Snippet:Sample_Cleanup_ContainerApp_Sync +projectClient.OpenAI.Conversations.DeleteConversation(conversationId: conversation.Id); +projectClient.Agents.DeleteAgentVersion(agentName: containerAgentVersion.Name, agentVersion: containerAgentVersion.Version); +``` + +Asynchronous sample: +```C# Snippet:Sample_Cleanup_ContainerApp_Async +await projectClient.OpenAI.Conversations.DeleteConversationAsync(conversationId:conversation.Id); +await projectClient.Agents.DeleteAgentVersionAsync(agentName: containerAgentVersion.Name, agentVersion: containerAgentVersion.Version); +``` diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample7_CodeInterpreter.md b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample7_CodeInterpreter.md new file mode 100644 index 000000000000..5bc865a8debe --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample7_CodeInterpreter.md @@ -0,0 +1,95 @@ +# Sample of using Agent with code interpreter and file attachment in Azure.AI.Projects.OpenAI. + +In this example we will demonstrate how to use Code interpreter to solve the equation. + +1. First, we need to create project client and read the environment variables, which will be used in the next steps. + +```C# Snippet:Sample_CreateAgentClient_CodeInterpreter +var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); +var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); +``` + +2. Create Agent, capable to use Code Interpreter to answer questions. + +Synchronous sample: +```C# Snippet:Sample_CreateAgent_CodeInterpreter_Sync +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a helpful agent that can help fetch data from files you know about.", + Tools = { + ResponseTool.CreateCodeInterpreterTool( + new CodeInterpreterToolContainer( + CodeInterpreterToolContainerConfiguration.CreateAutomaticContainerConfiguration( + fileIds: [] + ) + ) + ), + } +}; +AgentVersion agentVersion = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent", + options: new(agentDefinition)); +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateAgent_CodeInterpreter_Async +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a personal math tutor. When asked a math question, write and run code using the python tool to answer the question.", + Tools = { + ResponseTool.CreateCodeInterpreterTool( + new CodeInterpreterToolContainer( + CodeInterpreterToolContainerConfiguration.CreateAutomaticContainerConfiguration([]) + ) + ), + } +}; +AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent", + options: new(agentDefinition)); +``` + +3. Now we can ask the agent a question, which requires running python code in the container. + +Synchronous sample: +```C# Snippet:Sample_CreateResponse_CodeInterpreter_Sync +AgentReference agentReference = new(name: agentVersion.Name, version: agentVersion.Version); +ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentReference); + +OpenAIResponse response = responseClient.CreateResponse("I need to solve the equation sin(x) + x^2 = 42"); +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateResponse_CodeInterpreter_Async +AgentReference agentReference = new(name: agentVersion.Name, version: agentVersion.Version); +ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentReference); + +OpenAIResponse response = await responseClient.CreateResponseAsync("I need to solve the equation sin(x) + x^2 = 42"); +``` + +5 Write out the output of a response, raise the exception if the request was not successful. + +Synchronous sample: +```C# Snippet:Sample_WaitForResponse_CodeInterpreter_Sync +Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); +Console.WriteLine(response.GetOutputText()); +``` + +Asynchronous sample: +```C# Snippet:Sample_WaitForResponse_CodeInterpreter_Async +Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); +Console.WriteLine(response.GetOutputText()); +``` + +6. Clean up resources by deleting conversations and the Agent. + +Synchronous sample: +```C# Snippet:Sample_Cleanup_CodeInterpreter_Sync +projectClient.Agents.DeleteAgentVersion(agentName: agentVersion.Name, agentVersion: agentVersion.Version); +``` + +Asynchronous sample: +```C# Snippet:Sample_Cleanup_CodeInterpreter_Async +await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion.Name, agentVersion: agentVersion.Version); +``` diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample8_FileSearch.md b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample8_FileSearch.md new file mode 100644 index 000000000000..d8d3fbdbd0a0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample8_FileSearch.md @@ -0,0 +1,131 @@ +# Sample file search with agent in Azure.AI.Projects.OpenAI. + +In this example we will create the local file, upload it to Azure and will use it in the newly created `VectorStore` for file search. + +1. First, we need to create project client and read the environment variables, which will be used in the next steps. + +```C# Snippet:Sample_CreateAgentClient_FileSearch +var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); +var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); +``` + +2. We will create a toy example file and upload it using OpenAI mechanism. + +Synchronous sample: +```C# Snippet:Sample_UploadFile_FileSearch_Sync +string filePath = "sample_file_for_upload.txt"; +File.WriteAllText( + path: filePath, + contents: "The word 'apple' uses the code 442345, while the word 'banana' uses the code 673457."); +OpenAIFileClient fileClient = projectClient.OpenAI.GetOpenAIFileClient(); +OpenAIFile uploadedFile = fileClient.UploadFile(filePath: filePath, purpose: FileUploadPurpose.Assistants); +File.Delete(filePath); +``` + +Asynchronous sample: +```C# Snippet:Sample_UploadFile_FileSearch_Async +string filePath = "sample_file_for_upload.txt"; +File.WriteAllText( + path: filePath, + contents: "The word 'apple' uses the code 442345, while the word 'banana' uses the code 673457."); +OpenAIFileClient fileClient = projectClient.OpenAI.GetOpenAIFileClient(); +OpenAIFile uploadedFile = await fileClient.UploadFileAsync(filePath: filePath, purpose: FileUploadPurpose.Assistants); +File.Delete(filePath); +``` + +3. Create the `VectorStore` and provide it with uploaded file ID. + +Synchronous sample: +```C# Snippet:Sample_CreateVectorStore_FileSearch_Sync +VectorStoreClient vctStoreClient = projectClient.OpenAI.GetVectorStoreClient(); +VectorStoreCreationOptions options = new() +{ + Name = "MySampleStore", + FileIds = { uploadedFile.Id } +}; +VectorStore vectorStore = vctStoreClient.CreateVectorStore(options: options); +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateVectorStore_FileSearch_Async +VectorStoreClient vctStoreClient = projectClient.OpenAI.GetVectorStoreClient(); +VectorStoreCreationOptions options = new() +{ + Name = "MySampleStore", + FileIds = { uploadedFile.Id } +}; +VectorStore vectorStore = await vctStoreClient.CreateVectorStoreAsync(options); +``` + +2. Now we can create an Agent capable of using File search. + +Synchronous sample: +```C# Snippet:Sample_CreateAgent_FileSearch_Sync +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a helpful agent that can help fetch data from files you know about.", + Tools = { ResponseTool.CreateFileSearchTool(vectorStoreIds: [vectorStore.Id]), } +}; +AgentVersion agentVersion = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent", + options: new(agentDefinition)); +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateAgent_FileSearch_Async +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a helpful agent that can help fetch data from files you know about.", + Tools = { ResponseTool.CreateFileSearchTool(vectorStoreIds: [vectorStore.Id]), } +}; +AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent", + options: new(agentDefinition)); +``` + +3. In this example we will ask a question to the file contents. + +Synchronous sample: +```C# Snippet:Sample_CreateResponse_FileSearch_Sync +ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name); + +OpenAIResponse response = responseClient.CreateResponse("Can you give me the documented codes for 'banana' and 'orange'?"); +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateResponse_FileSearch_Async +ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name); + +OpenAIResponse response = await responseClient.CreateResponseAsync("Can you give me the documented codes for 'banana' and 'orange'?"); +``` + +4. Create the response and throw an exception if the response contains the error. + +Synchronous sample: +```C# Snippet:Sample_WaitForResponse_FileSearch_Sync +Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); +Console.WriteLine(response.GetOutputText()); +``` + +Asynchronous sample: +```C# Snippet:Sample_WaitForResponse_FileSearch_Async +Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); +Console.WriteLine(response.GetOutputText()); +``` + +5. Finally, delete all the resources, we have created in this sample. + +Synchronous sample: +```C# Snippet:Sample_Cleanup_FileSearch_Sync +projectClient.Agents.DeleteAgentVersion(agentName: agentVersion.Name, agentVersion: agentVersion.Version); +vctStoreClient.DeleteVectorStore(vectorStoreId: vectorStore.Id); +fileClient.DeleteFile(uploadedFile.Id); +``` + +Asynchronous sample: +```C# Snippet:Sample_Cleanup_FileSearch_Async +await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion.Name, agentVersion: agentVersion.Version); +await vctStoreClient.DeleteVectorStoreAsync(vectorStoreId: vectorStore.Id); +await fileClient.DeleteFileAsync(uploadedFile.Id); +``` diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample9_Function.md b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample9_Function.md new file mode 100644 index 000000000000..4a9fd05e7cb2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/samples/Sample9_Function.md @@ -0,0 +1,253 @@ +# Sample using Agents with functions in Azure.AI.Projects.OpenAI. + +In this example we are demonstrating how to use the local functions with the Agents. The functions can be used to provide the Agent with specific information in response to a user question. + +1. First, we need to create project client and read in the environment variables that will be used in the next steps. +```C# Snippet:Sample_CreateAgentClient_Function +var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); +var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); +``` + +2 Define three toy functions: `GetUserFavoriteCity` that always returns "Seattle, WA" and `GetCityNickname`, which will handle only "Seattle, WA" and will throw exception in response to other city names. The last function `GetWeatherAtLocation` returns the weather in Seattle, WA. +```C# Snippet:Sample_Functions_Function +/// Example of a function that defines no parameters +/// returns user favorite city. +private static string GetUserFavoriteCity() => "Seattle, WA"; + +/// +/// Example of a function with a single required parameter +/// +/// The location to get nickname for. +/// The city nickname. +/// +private static string GetCityNickname(string location) => location switch +{ + "Seattle, WA" => "The Emerald City", + _ => throw new NotImplementedException(), +}; + +/// +/// Example of a function with one required and one optional, enum parameter +/// +/// Get weather for location. +/// "c" or "f" +/// The weather in selected location. +/// +public static string GetWeatherAtLocation(string location, string temperatureUnit = "f") => location switch +{ + "Seattle, WA" => temperatureUnit == "f" ? "70f" : "21c", + _ => throw new NotImplementedException() +}; +``` + +3. For each function we need to create `FunctionTool`, which defines function name, description and parameters. +```C# Snippet:Sample_FunctionTools_Function +public static readonly FunctionTool getUserFavoriteCityTool = ResponseTool.CreateFunctionTool( + functionName: "getUserFavoriteCity", + functionDescription: "Gets the user's favorite city.", + functionParameters: BinaryData.FromString("{}"), + strictModeEnabled: false +); + +public static readonly FunctionTool getCityNicknameTool = ResponseTool.CreateFunctionTool( + functionName: "getCityNickname", + functionDescription: "Gets the nickname of a city, e.g. 'LA' for 'Los Angeles, CA'.", + functionParameters: BinaryData.FromObjectAsJson( + new + { + Type = "object", + Properties = new + { + Location = new + { + Type = "string", + Description = "The city and state, e.g. San Francisco, CA", + }, + }, + Required = new[] { "location" }, + }, + new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase } + ), + strictModeEnabled: false +); + +private static readonly FunctionTool getCurrentWeatherAtLocationTool = ResponseTool.CreateFunctionTool( + functionName: "getCurrentWeatherAtLocation", + functionDescription: "Gets the current weather at a provided location.", + functionParameters: BinaryData.FromObjectAsJson( + new + { + Type = "object", + Properties = new + { + Location = new + { + Type = "string", + Description = "The city and state, e.g. San Francisco, CA", + }, + Unit = new + { + Type = "string", + Enum = new[] { "c", "f" }, + }, + }, + Required = new[] { "location" }, + }, + new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase } + ), + strictModeEnabled: false +); +``` + +4. We will create the method `GetResolvedToolOutput`. It runs the abovementioned functions and wraps their outputs in `ResponseItem` object. +```C# Snippet:Sample_Resolver_Function +private static FunctionCallOutputResponseItem GetResolvedToolOutput(FunctionCallResponseItem item) +{ + if (item.FunctionName == getUserFavoriteCityTool.FunctionName) + { + return ResponseItem.CreateFunctionCallOutputItem(item.CallId, GetUserFavoriteCity()); + } + using JsonDocument argumentsJson = JsonDocument.Parse(item.FunctionArguments); + if (item.FunctionName == getCityNicknameTool.FunctionName) + { + string locationArgument = argumentsJson.RootElement.GetProperty("location").GetString(); + return ResponseItem.CreateFunctionCallOutputItem(item.CallId, GetCityNickname(locationArgument)); + } + if (item.FunctionName == getCurrentWeatherAtLocationTool.FunctionName) + { + string locationArgument = argumentsJson.RootElement.GetProperty("location").GetString(); + if (argumentsJson.RootElement.TryGetProperty("unit", out JsonElement unitElement)) + { + string unitArgument = unitElement.GetString(); + return ResponseItem.CreateFunctionCallOutputItem(item.CallId, GetWeatherAtLocation(locationArgument, unitArgument)); + } + return ResponseItem.CreateFunctionCallOutputItem(item.CallId, GetWeatherAtLocation(locationArgument)); + } + return null; +} +``` + +4. Create Agent with the `FunctionTool` we have created in step 3. + +Synchronous sample: +```C# Snippet:Sample_CreateAgent_Function_Sync +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a weather bot. Use the provided functions to help answer questions. " + + "Customize your responses to the user's preferences as much as possible and use friendly " + + "nicknames for cities whenever possible.", + Tools = { getUserFavoriteCityTool, getCityNicknameTool, getCurrentWeatherAtLocationTool } +}; +AgentVersion agentVersion = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent", + options: new(agentDefinition)); +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateAgent_Function_Async +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a weather bot. Use the provided functions to help answer questions. " + + "Customize your responses to the user's preferences as much as possible and use friendly " + + "nicknames for cities whenever possible.", + Tools = { getUserFavoriteCityTool, getCityNicknameTool, getCurrentWeatherAtLocationTool } +}; +AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent", + options: new(agentDefinition)); +``` + +5. To supply functions outputs, we will need to obtain responses multiple times. We will define methods `CreateAndCheckResponse` and `CreateAndCheckResponseAsync` for brevity. + +Synchronous sample: +```C# Snippet:Sample_CheckResponse_Function_Sync +public static OpenAIResponse CreateAndCheckResponse(OpenAIResponseClient responseClient, IEnumerable items) +{ + OpenAIResponse response = responseClient.CreateResponse( + inputItems: items); + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + return response; +} +``` + +Asynchronous sample: +```C# Snippet:Sample_CheckResponse_Function_Async +public static async Task CreateAndCheckResponseAsync(OpenAIResponseClient responseClient, IEnumerable items) +{ + OpenAIResponse response = await responseClient.CreateResponseAsync( + inputItems: items); + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + return response; +} +``` + +6. If the local function call is required, the response item will be of `FunctionCallResponseItem` type and will contain the function name needed by the Agent. In this case we will use our helper method `GetResolvedToolOutput` to get the `FunctionCallOutputResponseItem` with function call result. To provide the right answer, we need to supply all the response items to `CreateResponse` or `CreateResponseAsync` call. At the end we will print out the function response. + +Synchronous sample: +```C# Snippet:Sample_CreateResponse_Function_Sync +OpenAIResponseClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name); + +ResponseItem request = ResponseItem.CreateUserMessageItem("What's the weather like in my favorite city?"); +List inputItems = [request]; +bool funcionCalled = false; +OpenAIResponse response; +do +{ + response = CreateAndCheckResponse( + responseClient, + inputItems); + funcionCalled = false; + foreach (ResponseItem responseItem in response.OutputItems) + { + inputItems.Add(responseItem); + if (responseItem is FunctionCallResponseItem functionToolCall) + { + Console.WriteLine($"Calling {functionToolCall.FunctionName}..."); + inputItems.Add(GetResolvedToolOutput(functionToolCall)); + funcionCalled = true; + } + } +} while (funcionCalled); +Console.WriteLine(response.GetOutputText()); +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateResponse_Function_Async +ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name); + +ResponseItem request = ResponseItem.CreateUserMessageItem("What's the weather like in my favorite city?"); +List inputItems = [request]; +bool funcionCalled = false; +OpenAIResponse response; +do +{ + response = await CreateAndCheckResponseAsync( + responseClient, + inputItems); + funcionCalled = false; + foreach (ResponseItem responseItem in response.OutputItems) + { + inputItems.Add(responseItem); + if (responseItem is FunctionCallResponseItem functionToolCall) + { + Console.WriteLine($"Calling {functionToolCall.FunctionName}..."); + inputItems.Add(GetResolvedToolOutput(functionToolCall)); + funcionCalled = true; + } + } +} while (funcionCalled); +Console.WriteLine(response.GetOutputText()); +``` + +7. Finally, we delete all the resources we have created in this sample. + +Synchronous sample: +```C# Snippet:Sample_Cleanup_Function_Sync +projectClient.Agents.DeleteAgentVersion(agentName: agentVersion.Name, agentVersion: agentVersion.Version); +``` + +Asynchronous sample: +```C# Snippet:Sample_Cleanup_Function_Async +await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion.Name, agentVersion: agentVersion.Version); +``` diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Azure.AI.Projects.OpenAI.csproj b/sdk/ai/Azure.AI.Projects.OpenAI/src/Azure.AI.Projects.OpenAI.csproj new file mode 100644 index 000000000000..fb0b9af34fb5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Azure.AI.Projects.OpenAI.csproj @@ -0,0 +1,38 @@ + + + + The official .NET library for extended OpenAI API capabilities in Microsoft Foundry, including those used by the Foundry Agents Service. + + This library features derived clients, new compatible types, and a variety of extension elements that facilitate easier use of new Microsoft + Foundry API surfaces. It depends on and builds from the official OpenAI library for .NET to maintain rapid upstream feature propagation and + ongoing forward compatibility. + + Microsoft Foundry OpenAI .NET Extensions + 1.0.0-beta.4 + Azure.AI.Projects.OpenAI + $(RequiredTargetFrameworks) + + + + + $(NoWarn);OPENAI001 + + $(NoWarn);CS1591 + + $(NoWarn);AZC0007 + + $(NoWarn);AZC0015 + + $(NoWarn);AZC0035 + + + + + preview + true + + + + + + diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/A2ATool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/A2ATool.cs new file mode 100644 index 000000000000..23f2b864c349 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/A2ATool.cs @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using OpenAI; + +#pragma warning disable OPENAI001 + +namespace Azure.AI.Projects.OpenAI; + +[CodeGenType("A2ATool")] +public partial class A2ATool +{ + /// Base URL of the agent. + [CodeGenMember("BaseUrl")] + public Uri BaseUri { get; set; } + + /// Initializes a new instance of . + internal A2ATool() : base(ToolType.A2aPreview) + { + } + + /// + /// Initializes a new instance of . + /// + /// + public A2ATool(Uri baseUri) : this() + { + BaseUri = baseUri; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AgentDefinition.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AgentDefinition.cs new file mode 100644 index 000000000000..d86774bb22bd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AgentDefinition.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI; + +[CodeGenType("AgentDefinition")] +public abstract partial class AgentDefinition +{ + /// Configuration for Responsible AI (RAI) content filtering and safety features. + [CodeGenMember("RaiConfig")] + public ContentFilterConfiguration ContentFilterConfiguration { get; set; } + + public static PromptAgentDefinition CreatePromptAgentDefinition(string model) + => new PromptAgentDefinition(model); + public static WorkflowAgentDefinition CreateWorkflowAgentDefinitionFromYaml(string workflowYamlDocument) + => WorkflowAgentDefinition.FromYaml(workflowYamlDocument); + public static ContainerApplicationAgentDefinition CreateContainerApplicationAgentDefinition(IEnumerable containerProtocolVersions, string containerAppResourceId, string ingressSubdomainSuffix) + => new ContainerApplicationAgentDefinition(containerProtocolVersions, containerAppResourceId, ingressSubdomainSuffix); + public static HostedAgentDefinition CreateHostedAgentDefinition(IEnumerable containerProtocolVersions, string cpuConfiguration, string memoryConfiguration) + => new HostedAgentDefinition(containerProtocolVersions, cpuConfiguration, memoryConfiguration); +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AgentReference.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AgentReference.cs new file mode 100644 index 000000000000..29f7af0b3dc0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AgentReference.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; + +namespace Azure.AI.Projects.OpenAI; + +[CodeGenType("AgentReference")] +[CodeGenSuppress(nameof(AgentReference), typeof(string))] +public partial class AgentReference +{ + /// The version identifier of the agent. + [CodeGenMember("Version")] + public string Version { get; } + + public AgentReference(string name, string version = null) + { + Name = name; + Version = version; + _additionalBinaryDataProperties = new ChangeTrackingDictionary(); + } + +public static implicit operator AgentReference(string agentName) => new(agentName); +public static implicit operator AgentReference(AgentVersion agentVersion) => new(agentVersion.Name, agentVersion.Version); +public static implicit operator AgentReference(AgentRecord agentRecord) => new(agentRecord.Name); +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AgentResponseItem.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AgentResponseItem.cs new file mode 100644 index 000000000000..81c276e1e90d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AgentResponseItem.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using OpenAI; +using OpenAI.Responses; + +namespace Azure.AI.Projects.OpenAI; + +[CodeGenType("ItemResource")] +public partial class AgentResponseItem +{ + public static AgentResponseItem CreateStructuredOutputsItem(BinaryData output = null) + => new AgentStructuredOutputsResponseItem(output); + + public static AgentResponseItem CreateWorkflowActionItem(string actionKind, string actionId) + => new AgentWorkflowActionResponseItem(id: null, actionKind, actionKind, status: null); + + public ResponseItem AsOpenAIResponseItem() + { + BinaryData serializedAgentResponseItem = ModelReaderWriter.Write( + this, + ModelReaderWriterOptions.Json, + AzureAIProjectsOpenAIContext.Default); + return ModelReaderWriter.Read( + serializedAgentResponseItem, + ModelReaderWriterOptions.Json, + OpenAIContext.Default); + } + + public static implicit operator ResponseItem(AgentResponseItem agentResponseItem) => agentResponseItem.AsOpenAIResponseItem(); + + public static implicit operator AgentResponseItem(ResponseItem responseItem) => responseItem.AsAgentResponseItem(); +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AgentStructuredOutputsResponseItem.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AgentStructuredOutputsResponseItem.cs new file mode 100644 index 000000000000..29ec57ee2f17 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AgentStructuredOutputsResponseItem.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI; + +[CodeGenType("StructuredOutputsItemResource")] +public partial class AgentStructuredOutputsResponseItem +{ + public AgentStructuredOutputsResponseItem(BinaryData output) + : this(AgentResponseItemKind.StructuredOutputs, createdBy: new(), id: null, additionalBinaryDataProperties: null, output: output) + { } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AgentTool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AgentTool.cs new file mode 100644 index 000000000000..a8afc6220cc9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AgentTool.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using OpenAI; +using OpenAI.Responses; + +#pragma warning disable OPENAI001 + +namespace Azure.AI.Projects.OpenAI; + +[CodeGenType("Tool")] +public abstract partial class AgentTool +{ + public static BingGroundingAgentTool CreateBingGroundingTool(BingGroundingSearchToolOptions options) => new BingGroundingAgentTool(options); + public static MicrosoftFabricAgentTool CreateMicrosoftFabricTool(FabricDataAgentToolOptions options) => new MicrosoftFabricAgentTool(options); + public static SharepointAgentTool CreateSharepointTool(SharePointGroundingToolOptions options) => new SharepointAgentTool(options); + public static AzureAISearchAgentTool CreateAzureAISearchTool(AzureAISearchToolOptions options = null) => new AzureAISearchAgentTool(options ?? new()); + public static OpenAPIAgentTool CreateOpenApiTool(OpenAPIFunctionDefinition definition) => new OpenAPIAgentTool(definition); + public static BingCustomSearchAgentTool CreateBingCustomSearchTool(BingCustomSearchToolParameters parameters) => new BingCustomSearchAgentTool(parameters); + public static BrowserAutomationAgentTool CreateBrowserAutomationTool(BrowserAutomationToolParameters parameters) => new BrowserAutomationAgentTool(parameters); + public static CaptureStructuredOutputsTool CreateStructuredOutputsTool(StructuredOutputDefinition outputs) => new CaptureStructuredOutputsTool(outputs); + public static ResponseTool CreateA2ATool(Uri baseUri, string agentCardPath = null) => new A2ATool(baseUri) + { + AgentCardPath = agentCardPath, + }; + + public static LocalShellAgentTool CreateLocalShellTool() => new LocalShellAgentTool(); + + public static implicit operator ResponseTool(AgentTool agentTool) + { + return ModelReaderWriter.Read( + ModelReaderWriter.Write( + agentTool, + ModelSerializationExtensions.WireOptions, + AzureAIProjectsOpenAIContext.Default), + ModelSerializationExtensions.WireOptions, + OpenAIContext.Default); + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AgentVersion.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AgentVersion.cs new file mode 100644 index 000000000000..5808dccdfb5b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AgentVersion.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Azure.AI.Projects.OpenAI; + +[CodeGenType("AgentVersionObject")] +public partial class AgentVersion +{ + /// The object type, which is always 'agent.version'. + [CodeGenMember("Object")] + internal string Object { get; } = "agent.version"; +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AgentWorkflowActionResponseItem.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AgentWorkflowActionResponseItem.cs new file mode 100644 index 000000000000..95a70deebd89 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AgentWorkflowActionResponseItem.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +namespace Azure.AI.Projects.OpenAI; + +[CodeGenType("WorkflowActionOutputItemResource")] +public partial class AgentWorkflowActionResponseItem +{ + [CodeGenMember("Status")] + public AgentWorkflowActionStatus? Status { get; } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AzureAIAgentsModelFactory.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AzureAIAgentsModelFactory.cs new file mode 100644 index 000000000000..8cc5c2ac4dc6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AzureAIAgentsModelFactory.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects.OpenAI; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI; + +public static partial class AzureAIAgentsModelFactory +{ +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AzureAISearchAgentTool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AzureAISearchAgentTool.cs new file mode 100644 index 000000000000..7ba0fad7cfa7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AzureAISearchAgentTool.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +#pragma warning disable OPENAI001 + +using System; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI; + +[CodeGenType("AzureAISearchAgentTool")] +public partial class AzureAISearchAgentTool +{ + /// Options applied to the instance. + [CodeGenMember("AzureAiSearch")] + public AzureAISearchToolOptions Options { get; set; } + + /// The azure ai search index resource. + /// is null. + public AzureAISearchAgentTool(AzureAISearchToolOptions options) : base(ToolType.AzureAiSearch) + { + Argument.AssertNotNull(options, nameof(options)); + + Options = options; + } + + internal AzureAISearchAgentTool() + { } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AzureAISearchToolIndex.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AzureAISearchToolIndex.cs new file mode 100644 index 000000000000..e246c3d5a68f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AzureAISearchToolIndex.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +#pragma warning disable OPENAI001 + +namespace Azure.AI.Projects.OpenAI; + +[CodeGenType("AISearchIndexResource")] +public partial class AzureAISearchToolIndex +{ +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AzureAISearchToolOptions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AzureAISearchToolOptions.cs new file mode 100644 index 000000000000..9c9fb3b79feb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/AzureAISearchToolOptions.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System.Collections.Generic; + +#pragma warning disable OPENAI001 + +namespace Azure.AI.Projects.OpenAI; + +[CodeGenType("AzureAISearchToolResource")] +public partial class AzureAISearchToolOptions +{ + /// + /// The indices attached to this agent. There can be a maximum of 1 index + /// resource attached to the agent. + /// + [CodeGenMember("IndexList")] + public IList Indexes { get; } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/CodeGenStubs.OpenAI.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/CodeGenStubs.OpenAI.cs new file mode 100644 index 000000000000..a98ea7ba1320 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/CodeGenStubs.OpenAI.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.AI.Projects.OpenAI; + +namespace OpenAI; + +// Internal types + +[CodeGenType("Annotation")] internal partial class InternalAnnotation { } +[CodeGenType("AnnotationFileCitation")] internal partial class InternalAnnotationFileCitation { } +[CodeGenType("AnnotationFilePath")] internal partial class InternalAnnotationFilePath { } +[CodeGenType("AnnotationUrlCitation")] internal partial class InternalAnnotationUrlCitation { } +[CodeGenType("ApproximateLocation")] internal partial class InternalApproximateLocation { } +[CodeGenType("CodeInterpreterOutput")] internal partial class InternalCodeInterpreterOutput { } +[CodeGenType("CodeInterpreterOutputImage")] internal partial class InternalCodeInterpreterOutputImage { } +[CodeGenType("CodeInterpreterOutputLogs")] internal partial class InternalCodeInterpreterOutputLogs { } +[CodeGenType("CodeInterpreterTool")] internal partial class InternalCodeInterpreterTool { } +[CodeGenType("CodeInterpreterToolAuto")] internal partial class InternalCodeInterpreterToolAuto { } +[CodeGenType("CodeInterpreterToolCallItemParam")] internal partial class InternalCodeInterpreterToolCallItemParam { } +[CodeGenType("CodeInterpreterToolCallItemResource")] internal partial class InternalCodeInterpreterToolCallItemResource { } +[CodeGenType("CodeInterpreterToolCallItemResourceStatus")] internal readonly partial struct CodeInterpreterToolCallItemResourceStatus { } +[CodeGenType("ComparisonFilter")] internal partial class InternalComparisonFilter { } +[CodeGenType("ComparisonFilterType")] internal readonly partial struct ComparisonFilterType { } +[CodeGenType("CompoundFilter")] internal partial class InternalCompoundFilter { } +[CodeGenType("CompoundFilterType")] internal readonly partial struct CompoundFilterType { } +[CodeGenType("ComputerAction")] internal partial class InternalComputerAction { } +[CodeGenType("ComputerActionClick")] internal partial class InternalComputerActionClick { } +[CodeGenType("ComputerActionClickButton")] internal readonly partial struct ComputerActionClickButton { } +[CodeGenType("ComputerActionDoubleClick")] internal partial class InternalComputerActionDoubleClick { } +[CodeGenType("ComputerActionDrag")] internal partial class InternalComputerActionDrag { } +[CodeGenType("ComputerActionKeyPress")] internal partial class InternalComputerActionKeyPress { } +[CodeGenType("ComputerActionMove")] internal partial class InternalComputerActionMove { } +[CodeGenType("ComputerActionScreenshot")] internal partial class InternalComputerActionScreenshot { } +[CodeGenType("ComputerActionScroll")] internal partial class InternalComputerActionScroll { } +[CodeGenType("ComputerActionTypeKeys")] internal partial class InternalComputerActionTypeKeys { } +[CodeGenType("ComputerActionWait")] internal partial class InternalComputerActionWait { } +[CodeGenType("ComputerToolCallItemParam")] internal partial class InternalComputerToolCallItemParam { } +[CodeGenType("ComputerToolCallItemResource")] internal partial class InternalComputerToolCallItemResource { } +[CodeGenType("ComputerToolCallItemResourceStatus")] internal readonly partial struct ComputerToolCallItemResourceStatus { } +[CodeGenType("ComputerToolCallOutputItemOutput")] internal partial class InternalComputerToolCallOutputItemOutput { } +[CodeGenType("ComputerToolCallOutputItemOutputComputerScreenshot")] internal partial class InternalComputerToolCallOutputItemOutputComputerScreenshot { } +[CodeGenType("ComputerToolCallOutputItemParam")] internal partial class InternalComputerToolCallOutputItemParam { } +[CodeGenType("ComputerToolCallOutputItemResource")] internal partial class InternalComputerToolCallOutputItemResource { } +[CodeGenType("ComputerToolCallOutputItemResourceStatus")] internal readonly partial struct ComputerToolCallOutputItemResourceStatus { } +[CodeGenType("ComputerToolCallSafetyCheck")] internal partial class InternalComputerToolCallSafetyCheck { } +[CodeGenType("ComputerUsePreviewTool")] internal partial class InternalComputerUsePreviewTool { } +[CodeGenType("ComputerUsePreviewToolEnvironment")] internal readonly partial struct ComputerUsePreviewToolEnvironment { } +[CodeGenType("Coordinate")] internal partial class InternalCoordinate { } +[CodeGenType("EasyInputMessage")] internal partial class InternalEasyInputMessage { } +[CodeGenType("FileSearchTool")] internal partial class InternalFileSearchTool { } +[CodeGenType("FileSearchToolCallItemParam")] internal partial class InternalFileSearchToolCallItemParam { } +[CodeGenType("FileSearchToolCallItemParamResult")] internal partial class InternalFileSearchToolCallItemParamResult { } +[CodeGenType("FileSearchToolCallItemResource")] internal partial class InternalFileSearchToolCallItemResource { } +[CodeGenType("FileSearchToolCallItemResourceStatus")] internal readonly partial struct FileSearchToolCallItemResourceStatus { } +[CodeGenType("FunctionTool")] internal partial class InternalFunctionTool { } +[CodeGenType("FunctionToolCallItemParam")] internal partial class InternalFunctionToolCallItemParam { } +[CodeGenType("FunctionToolCallItemResource")] internal partial class InternalFunctionToolCallItemResource { } +[CodeGenType("FunctionToolCallItemResourceStatus")] internal readonly partial struct FunctionToolCallItemResourceStatus { } +[CodeGenType("FunctionToolCallOutputItemParam")] internal partial class InternalFunctionToolCallOutputItemParam { } +[CodeGenType("FunctionToolCallOutputItemResource")] internal partial class InternalFunctionToolCallOutputItemResource { } +[CodeGenType("FunctionToolCallOutputItemResourceStatus")] internal readonly partial struct FunctionToolCallOutputItemResourceStatus { } +[CodeGenType("ImageGenTool")] internal partial class InternalImageGenTool { } +[CodeGenType("ImageGenToolBackground")] internal readonly partial struct ImageGenToolBackground { } +[CodeGenType("ImageGenToolCallItemParam")] internal partial class InternalImageGenToolCallItemParam { } +[CodeGenType("ImageGenToolCallItemResource")] internal partial class InternalImageGenToolCallItemResource { } +[CodeGenType("ImageGenToolCallItemResourceStatus")] internal readonly partial struct ImageGenToolCallItemResourceStatus { } +[CodeGenType("ImageGenToolInputImageMask")] internal partial class InternalImageGenToolInputImageMask { } +[CodeGenType("ImageGenToolModeration")] internal readonly partial struct ImageGenToolModeration { } +[CodeGenType("ImageGenToolOutputFormat")] internal readonly partial struct ImageGenToolOutputFormat { } +[CodeGenType("ImageGenToolQuality")] internal readonly partial struct ImageGenToolQuality { } +[CodeGenType("ImageGenToolSize")] internal readonly partial struct ImageGenToolSize { } +[CodeGenType("ImplicitUserMessage")] internal partial class InternalImplicitUserMessage { } +[CodeGenType("ItemContent")] internal partial class InternalItemContent { } +[CodeGenType("ItemContentInputAudio")] internal partial class InternalItemContentInputAudio { } +[CodeGenType("ItemContentInputAudioFormat")] internal readonly partial struct ItemContentInputAudioFormat { } +[CodeGenType("ItemContentInputFile")] internal partial class InternalItemContentInputFile { } +[CodeGenType("ItemContentInputImage")] internal partial class InternalItemContentInputImage { } +[CodeGenType("ItemContentInputImageDetail")] internal readonly partial struct ItemContentInputImageDetail { } +[CodeGenType("ItemContentInputText")] internal partial class InternalItemContentInputText { } +[CodeGenType("ItemContentOutputAudio")] internal partial class InternalItemContentOutputAudio { } +[CodeGenType("ItemContentOutputText")] internal partial class InternalItemContentOutputText { } +[CodeGenType("ItemContentRefusal")] internal partial class InternalItemContentRefusal { } +[CodeGenType("ItemReferenceItemParam")] internal partial class InternalItemReferenceItemParam { } +[CodeGenType("LocalShellToolCallItemParam")] internal partial class InternalLocalShellToolCallItemParam { } +[CodeGenType("LocalShellToolCallOutputItemParam")] internal partial class InternalLocalShellToolCallOutputItemParam { } +[CodeGenType("LocalShellToolCallOutputItemResourceStatus")] internal readonly partial struct InternalLocalShellToolCallOutputItemResourceStatus { } +[CodeGenType("Location")] internal partial class InternalLocation { } +[CodeGenType("LogProb")] internal partial class InternalLogProb { } +[CodeGenType("MCPApprovalRequestItemParam")] internal partial class InternalMCPApprovalRequestItemParam { } +[CodeGenType("MCPApprovalRequestItemResource")] internal partial class InternalMCPApprovalRequestItemResource { } +[CodeGenType("MCPApprovalResponseItemParam")] internal partial class InternalMCPApprovalResponseItemParam { } +[CodeGenType("MCPApprovalResponseItemResource")] internal partial class InternalMCPApprovalResponseItemResource { } +[CodeGenType("MCPCallItemParam")] internal partial class InternalMCPCallItemParam { } +[CodeGenType("MCPCallItemResource")] internal partial class InternalMCPCallItemResource { } +[CodeGenType("MCPListToolsItemParam")] internal partial class InternalMCPListToolsItemParam { } +[CodeGenType("MCPListToolsItemResource")] internal partial class InternalMCPListToolsItemResource { } +[CodeGenType("MCPListToolsTool")] internal partial class InternalMCPListToolsTool { } +[CodeGenType("MCPTool")] internal partial class InternalMCPTool { } +[CodeGenType("MCPToolAllowedTools1")] internal partial class InternalMCPToolAllowedTools1 { } +[CodeGenType("MCPToolRequireApproval1")] internal partial class InternalMCPToolRequireApproval1 { } +[CodeGenType("MCPToolRequireApprovalAlways")] internal partial class InternalMCPToolRequireApprovalAlways { } +[CodeGenType("MCPToolRequireApprovalNever")] internal partial class InternalMCPToolRequireApprovalNever { } +[CodeGenType("RankingOptions")] internal partial class InternalRankingOptions { } +[CodeGenType("RankingOptionsRanker")] internal readonly partial struct RankingOptionsRanker { } +[CodeGenType("Reasoning")] internal partial class InternalReasoning { } +[CodeGenType("ReasoningEffort")] internal readonly partial struct ReasoningEffort { } +[CodeGenType("ReasoningGenerateSummary")] internal readonly partial struct ReasoningGenerateSummary { } +[CodeGenType("ReasoningItemParam")] internal partial class InternalReasoningItemParam { } +[CodeGenType("ReasoningItemResource")] internal partial class InternalReasoningItemResource { } +[CodeGenType("ReasoningItemSummaryPart")] internal partial class InternalReasoningItemSummaryPart { } +[CodeGenType("ReasoningItemSummaryTextPart")] internal partial class InternalReasoningItemSummaryTextPart { } +[CodeGenType("ReasoningSummary")] internal readonly partial struct ReasoningSummary { } +[CodeGenType("Response")] internal partial class InternalAgentResponse { } +[CodeGenType("ResponseError")] internal partial class InternalAgentResponseError { } +[CodeGenType("ResponseFormatJsonSchemaSchema")] internal partial class InternalResponseFormatJsonSchemaSchema { } +[CodeGenType("ResponsesAssistantMessageItemParam")] internal partial class InternalResponsesAssistantMessageItemParam { } +[CodeGenType("ResponsesAssistantMessageItemResource")] internal partial class InternalResponsesAssistantMessageItemResource { } +[CodeGenType("ResponsesDeveloperMessageItemParam")] internal partial class InternalResponsesDeveloperMessageItemParam { } +[CodeGenType("ResponsesDeveloperMessageItemResource")] internal partial class InternalResponsesDeveloperMessageItemResource { } +[CodeGenType("ResponsesMessageItemParam")] internal partial class InternalResponsesMessageItemParam { } +[CodeGenType("ResponsesMessageItemResource")] internal partial class InternalResponsesMessageItemResource { } +[CodeGenType("ResponsesMessageItemResourceStatus")] internal readonly partial struct ResponsesMessageItemResourceStatus { } +[CodeGenType("ResponsesMessageRole")] internal readonly partial struct ResponsesMessageRole { } +[CodeGenType("ResponsesSystemMessageItemParam")] internal partial class InternalResponsesSystemMessageItemParam { } +[CodeGenType("ResponsesSystemMessageItemResource")] internal partial class InternalResponsesSystemMessageItemResource { } +[CodeGenType("ResponseStatus")] internal readonly partial struct InternalAgentResponseStatus { } +[CodeGenType("ResponsesUserMessageItemParam")] internal partial class InternalResponsesUserMessageItemParam { } +[CodeGenType("ResponsesUserMessageItemResource")] internal partial class InternalResponsesUserMessageItemResource { } +[CodeGenType("ResponseTextFormatConfiguration")] internal partial class InternalResponseTextFormatConfiguration { } +[CodeGenType("ResponseTextFormatConfigurationJsonObject")] internal partial class InternalResponseTextFormatConfigurationJsonObject { } +[CodeGenType("ResponseTextFormatConfigurationJsonSchema")] internal partial class InternalResponseTextFormatConfigurationJsonSchema { } +[CodeGenType("ResponseTextFormatConfigurationText")] internal partial class InternalResponseTextFormatConfigurationText { } +[CodeGenType("ToolChoiceObject")] internal partial class InternalToolChoiceObject { } +[CodeGenType("ToolChoiceObjectCodeInterpreter")] internal partial class InternalToolChoiceObjectCodeInterpreter { } +[CodeGenType("ToolChoiceObjectComputer")] internal partial class InternalToolChoiceObjectComputer { } +[CodeGenType("ToolChoiceObjectFileSearch")] internal partial class InternalToolChoiceObjectFileSearch { } +[CodeGenType("ToolChoiceObjectFunction")] internal partial class InternalToolChoiceObjectFunction { } +[CodeGenType("ToolChoiceObjectImageGen")] internal partial class InternalToolChoiceObjectImageGen { } +[CodeGenType("ToolChoiceObjectMCP")] internal partial class InternalToolChoiceObjectMCP { } +[CodeGenType("ToolChoiceObjectWebSearch")] internal partial class InternalToolChoiceObjectWebSearch { } +[CodeGenType("ToolChoiceOptions")] internal readonly partial struct ToolChoiceOptions { } +[CodeGenType("TopLogProb")] internal partial class InternalTopLogProb { } +[CodeGenType("VectorStoreFileAttributes")] internal partial class InternalVectorStoreFileAttributes { } +[CodeGenType("WebSearchAction")] internal partial class InternalWebSearchAction { } +[CodeGenType("WebSearchActionFind")] internal partial class InternalWebSearchActionFind { } +[CodeGenType("WebSearchActionOpenPage")] internal partial class InternalWebSearchActionOpenPage { } +[CodeGenType("WebSearchActionSearch")] internal partial class InternalWebSearchActionSearch { } +[CodeGenType("WebSearchPreviewTool")] internal partial class InternalWebSearchPreviewTool { } +[CodeGenType("WebSearchPreviewToolSearchContextSize")] internal readonly partial struct WebSearchPreviewToolSearchContextSize { } +[CodeGenType("WebSearchToolCallItemParam")] internal partial class InternalWebSearchToolCallItemParam { } +[CodeGenType("WebSearchToolCallItemResource")] internal partial class InternalWebSearchToolCallItemResource { } +[CodeGenType("WebSearchToolCallItemResourceStatus")] internal readonly partial struct WebSearchToolCallItemResourceStatus { } diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/CodeGenStubs.Projects.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/CodeGenStubs.Projects.cs new file mode 100644 index 000000000000..5027464b65ef --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/CodeGenStubs.Projects.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.AI.Projects.OpenAI; + +namespace Azure.AI.Projects; + +/// The ProjectsClient. +[CodeGenType("ProjectsClient")] +[CodeGenSuppress("GetConversationsClient")] +[CodeGenSuppress("GetAgentClient")] +[CodeGenSuppress("GetMemoryStoresClient")] +[CodeGenSuppress("_cachedAgentClient")] +[CodeGenSuppress("_cachedConversations")] +[CodeGenSuppress("_cachedMemoryStores")] +internal partial class InternalProjectsClient +{ +} + +[CodeGenType("InternalProjectsClientOptions")] internal partial class InternalProjectsClientOptions { } + +[CodeGenType("AgentsClient")] internal partial class InternalAgentsClient { } +[CodeGenType("MemoryStoreClient")] internal partial class InternalMemoryStoreClient { } +[CodeGenType("MemoryStoreOperationUsageInputTokensDetails")] internal partial class InternalMemoryStoreOperationUsageInputTokensDetails { } +[CodeGenType("MemoryStoreOperationUsageOutputTokensDetails")] internal partial class InternalMemoryStoreOperationUsageOutputTokensDetails { } +[CodeGenType("UserProfileMemoryItem")] internal partial class UserProfileMemoryItem { } +[CodeGenType("MemoryUpdateResultDetails")] internal partial class InternalMemoryUpdateResultDetails { } +[CodeGenType("ConversationList")] internal partial class InternalConversationList { } diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/CodeGenStubs.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/CodeGenStubs.cs new file mode 100644 index 000000000000..fad7b34b625c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/CodeGenStubs.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ComponentModel; + +namespace Azure.AI.Projects.OpenAI; + +// Public type renames + +[CodeGenType("AgentId")] public partial class AgentInfo { } +[CodeGenType("AgentObject")] public partial class AgentRecord +{ + [CodeGenMember("Object")] + private string Object { get; } = "agent"; +} + +[CodeGenType("AgentProtocol")] public readonly partial struct AgentCommunicationMethod { } +[CodeGenType("CreatedBy")] public partial class AgentResponseItemSource { } +[CodeGenType("ItemType")] public readonly partial struct AgentResponseItemKind { } +[CodeGenType("WorkflowActionOutputItemResourceStatus")] public readonly partial struct AgentWorkflowActionStatus { } +[CodeGenType("ContainerAppAgentDefinition")] public partial class ContainerApplicationAgentDefinition { } + +[CodeGenType("MemorySearchToolCallItemResourceStatus")] public readonly partial struct MemorySearchToolCallStatus { } +[CodeGenType("OpenApiFunctionDefinitionFunction")] public partial class OpenAPIFunctionEntry { } + +[CodeGenType("LocalShellTool")] public partial class LocalShellAgentTool { } +[CodeGenType("LocalShellToolCallItemResourceStatus")] public readonly partial struct LocalShellAgentToolCallStatus { } +[CodeGenType("LocalShellExecAction")] public partial class LocalShellAgentToolExecutionAction { } diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/ContentFilterConfiguration.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/ContentFilterConfiguration.cs new file mode 100644 index 000000000000..8ee5016f47ab --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/ContentFilterConfiguration.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; + +namespace Azure.AI.Projects.OpenAI; + +[CodeGenType("RaiConfig")] +public partial class ContentFilterConfiguration +{ + /// The name of the RAI policy to apply. + [CodeGenMember("RaiPolicyName")] + public string PolicyName { get; set; } + + /// Initializes a new instance of . + /// The name of the RAI policy to apply. + /// is null. + public ContentFilterConfiguration(string policyName) + { + Argument.AssertNotNull(policyName, nameof(policyName)); + + PolicyName = policyName; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/ConversationClientExtensions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/ConversationClientExtensions.cs new file mode 100644 index 000000000000..62342623a091 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/ConversationClientExtensions.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using OpenAI.Conversations; + +namespace Azure.AI.Projects.OpenAI; + +public static partial class ConversationClientExtensions +{ + extension(ConversationClient client) + { + + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/CancellationTokenExtensions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/CancellationTokenExtensions.cs new file mode 100644 index 000000000000..09febd0c441d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/CancellationTokenExtensions.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System.ClientModel.Primitives; +using System.Threading; + +namespace Azure.AI.Projects.OpenAI; + +/// The AgentClient. +internal static partial class CancellationTokenExtensions +{ + public static RequestOptions ToRequestOptions(this CancellationToken cancellationToken) + { + return cancellationToken.CanBeCanceled + ? new RequestOptions() + { + CancellationToken = cancellationToken, + } + : null; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/ClientPipelineExtensions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/ClientPipelineExtensions.cs new file mode 100644 index 000000000000..d8b0ddacc328 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/ClientPipelineExtensions.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace Azure.AI.Projects.OpenAI; + +internal static partial class ClientPipelineExtensions +{ + public static async ValueTask ProcessMessageAsync( + this ClientPipeline pipeline, + PipelineMessage message, + RequestOptions options) + { + await pipeline.SendAsync(message).ConfigureAwait(false); + + if (message.Response.IsError && (options?.ErrorOptions & ClientErrorBehaviors.NoThrow) != ClientErrorBehaviors.NoThrow) + { + throw await TryBufferResponseAndCreateErrorAsync(message).ConfigureAwait(false) switch + { + string errorMessage when !string.IsNullOrEmpty(errorMessage) + => new ClientResultException(errorMessage, message.Response), + _ => new ClientResultException(message.Response), + }; + } + + return message.BufferResponse ? + message.Response : + message.ExtractResponse(); + } + + public static PipelineResponse ProcessMessage( + this ClientPipeline pipeline, + PipelineMessage message, + RequestOptions options) + { + pipeline.Send(message); + + if (message.Response.IsError && (options?.ErrorOptions & ClientErrorBehaviors.NoThrow) != ClientErrorBehaviors.NoThrow) + { + throw TryBufferResponseAndCreateError(message) switch + { + string errorMessage when !string.IsNullOrEmpty(errorMessage) + => new ClientResultException(errorMessage, message.Response), + _ => new ClientResultException(message.Response), + }; + } + + return message.BufferResponse ? + message.Response : + message.ExtractResponse(); + } + + private static string TryBufferResponseAndCreateError(PipelineMessage message) + { + message.Response.BufferContent(); + return TryCreateErrorMessageFromResponse(message.Response); + } + + private static async Task TryBufferResponseAndCreateErrorAsync(PipelineMessage message) + { + await message.Response.BufferContentAsync().ConfigureAwait(false); + return TryCreateErrorMessageFromResponse(message.Response); + } + + private static string TryCreateErrorMessageFromResponse(PipelineResponse response) + => FoundryOpenAIError.TryCreateFromResponse(response)?.ToExceptionMessage(response.Status) + ?? GetFallbackExceptionMessageFromResponse(response); + + private static string GetFallbackExceptionMessageFromResponse(PipelineResponse response) + { + return new StringBuilder("An error was encountered while processing the request.") + .AppendLine() + .AppendLine($"HTTP {response.Status}: {((HttpStatusCode)response.Status)}") + .AppendLine() + .AppendLine(response.Content.ToString()) + .ToString(); + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/ClientResultExtensions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/ClientResultExtensions.cs new file mode 100644 index 000000000000..ced4b7ea6da6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/ClientResultExtensions.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI; + +/// The AgentClient. +internal static partial class ClientResultExtensions +{ + public static ClientResult ToOpenAIResult(this ClientResult protocolResult) + where T : IJsonModel + => ToTypedResult(protocolResult, OpenAIContext.Default); + + public static ClientResult ToAgentClientResult(this ClientResult protocolResult) + where T : IJsonModel + => ToTypedResult(protocolResult, AzureAIProjectsOpenAIContext.Default); + + public static ClientResult ToTypedResult(this ClientResult protocolResult, ModelReaderWriterContext context) + where T : IJsonModel + { + PipelineResponse rawResponse = protocolResult.GetRawResponse(); + T value = ModelReaderWriter.Read(rawResponse.Content, ModelReaderWriterOptions.Json, context); + return ClientResult.FromValue(value, rawResponse); + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/CreateConversationItemsRequest.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/CreateConversationItemsRequest.cs new file mode 100644 index 000000000000..92ba42ebdaf0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/CreateConversationItemsRequest.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI; + +internal partial class CreateConversationItemsRequest +{ + /// The items to add to the conversation. You may add up to 20 items at a time. + [CodeGenMember("Items")] + public IList Items { get; } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/GenericActionPipelinePolicy.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/GenericActionPipelinePolicy.cs new file mode 100644 index 000000000000..1a43831bb1ef --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/GenericActionPipelinePolicy.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Azure.AI.Projects.OpenAI; + +internal partial class GenericActionPipelinePolicy : PipelinePolicy +{ + private readonly Action _requestAction; + private readonly Action _responseAction; + private readonly Action _messageAction; + + public GenericActionPipelinePolicy(Action requestAction = null, Action responseAction = null, Action messageAction = null) + { + _requestAction = (request) => + { + if (request is not null) + { + requestAction?.Invoke(request); + } + }; + _responseAction = (response) => + { + if (response is not null) + { + responseAction?.Invoke(response); + } + }; + _messageAction = (message) => + { + if (message is not null) + { + messageAction?.Invoke(message); + } + }; + } + + public override void Process(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) + { + _messageAction?.Invoke(message); + _requestAction?.Invoke(message.Request); + ProcessNext(message, pipeline, currentIndex); + _responseAction?.Invoke(message.Response); + _messageAction?.Invoke(message); + } + + public override async ValueTask ProcessAsync(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) + { + _messageAction?.Invoke(message); + _requestAction?.Invoke(message.Request); + await ProcessNextAsync(message, pipeline, currentIndex).ConfigureAwait(false); + _responseAction?.Invoke(message.Response); + _messageAction?.Invoke(message); + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/InternalItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/InternalItemParam.cs new file mode 100644 index 000000000000..3ed7654cac4d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/InternalItemParam.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI; + +[CodeGenType("ItemParam")] +internal partial class InternalItemParam +{ + internal static InternalItemParam DeserializeInternalItemParam(JsonElement element, ModelReaderWriterOptions options) + => throw new NotImplementedException(); +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/InternalOpenAIAsyncCollectionResultOfT.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/InternalOpenAIAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..769f2dafb27a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/InternalOpenAIAsyncCollectionResultOfT.cs @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Text.Json; +using System.Threading.Tasks; + +namespace Azure.AI.Projects.OpenAI; + +internal partial class InternalOpenAIAsyncCollectionResultOfT : AsyncCollectionResult +{ + private readonly ClientPipeline _pipeline; + private readonly Func _messageGenerator; + private readonly Func _dataItemDeserializer; + private readonly InternalOpenAICollectionResultOptions _resultOptions; + private readonly RequestOptions _requestOptions; + + public InternalOpenAIAsyncCollectionResultOfT( + ClientPipeline pipeline, + Func messageGenerator, + Func dataItemDeserializer, + InternalOpenAICollectionResultOptions resultOptions, + RequestOptions requestOptions) + { + _pipeline = pipeline; + _messageGenerator = messageGenerator; + _dataItemDeserializer = dataItemDeserializer; + _resultOptions = resultOptions; + _requestOptions = requestOptions; + } + + public override ContinuationToken GetContinuationToken(ClientResult rawPage) + { + InternalOpenAIPaginatedListResultOfT page = GetPageFromResult(rawPage); + if (page.HasMore) + { + return ContinuationToken.FromBytes(rawPage.GetRawResponse().Content); + } + return null; + } + + public ReadOnlyCollection GetDataFromPage(ClientResult rawPage) + { + return GetPageFromResult(rawPage); + } + + protected override async IAsyncEnumerable GetValuesFromPageAsync(ClientResult rawPage) + { + InternalOpenAIPaginatedListResultOfT page = GetPageFromResult(rawPage); + + foreach (TData dataItem in page) + { + yield return dataItem; + await Task.Yield(); + } + } + + public override async IAsyncEnumerable GetRawPagesAsync() + { + PipelineMessage message = _messageGenerator.Invoke(_resultOptions, _requestOptions); + while (true) + { + _ = await _pipeline.ProcessMessageAsync(message, _requestOptions).ConfigureAwait(false); + ClientResult result = ClientResult.FromResponse(message.Response); + yield return result; + + InternalOpenAIPaginatedListResultOfT page = GetPageFromResult(result); + + if (!page.HasMore) + { + yield break; + } + + message = _messageGenerator.Invoke(_resultOptions.GetCloneForPage(page), _requestOptions); + } + } + + private InternalOpenAIPaginatedListResultOfT GetPageFromResult(ClientResult result) + { + using JsonDocument pageDocument = JsonDocument.Parse(result.GetRawResponse().Content); + InternalOpenAIPaginatedListResultOfT typedDataResult + = InternalOpenAIPaginatedListResultOfT.DeserializeInternalOpenAIPaginatedListResultOfT( + pageDocument.RootElement, + _dataItemDeserializer, + options: ModelReaderWriterOptions.Json); + return typedDataResult; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/InternalOpenAICollectionResultOfT.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/InternalOpenAICollectionResultOfT.cs new file mode 100644 index 000000000000..da40a039d9be --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/InternalOpenAICollectionResultOfT.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI; + +internal partial class InternalOpenAICollectionResultOfT : CollectionResult +{ + private readonly ClientPipeline _pipeline; + private readonly Func _messageGenerator; + private readonly Func _dataItemDeserializer; + private readonly InternalOpenAICollectionResultOptions _resultOptions; + private readonly RequestOptions _requestOptions; + + public InternalOpenAICollectionResultOfT( + ClientPipeline pipeline, + Func messageGenerator, + Func dataItemDeserializer, + InternalOpenAICollectionResultOptions resultOptions, + RequestOptions requestOptions) + { + Argument.AssertNotNull(pipeline, nameof(pipeline)); + Argument.AssertNotNull(messageGenerator, nameof(messageGenerator)); + + _pipeline = pipeline; + _messageGenerator = messageGenerator; + _dataItemDeserializer = dataItemDeserializer; + _resultOptions = resultOptions; + _requestOptions = requestOptions; + } + + public override IEnumerable GetRawPages() + { + PipelineMessage message = _messageGenerator.Invoke(_resultOptions, _requestOptions); + while (true) + { + _ = _pipeline.ProcessMessage(message, _requestOptions); + ClientResult result = ClientResult.FromResponse(message.Response); + yield return result; + + InternalOpenAIPaginatedListResultOfT page = GetPageFromResult(result); + + if (!page.HasMore) + { + yield break; + } + message = _messageGenerator.Invoke(_resultOptions.GetCloneForPage(page), _requestOptions); + } + } + + public override ContinuationToken GetContinuationToken(ClientResult rawPage) + { + InternalOpenAIPaginatedListResultOfT page = GetPageFromResult(rawPage); + if (page.HasMore) + { + return ContinuationToken.FromBytes(rawPage.GetRawResponse().Content); + } + return null; + } + + public ReadOnlyCollection GetDataFromPage(ClientResult rawPage) + { + return GetPageFromResult(rawPage); + } + + protected override IEnumerable GetValuesFromPage(ClientResult rawPage) + { + return GetPageFromResult(rawPage); + } + + private InternalOpenAIPaginatedListResultOfT GetPageFromResult(ClientResult result) + { + using JsonDocument pageDocument = JsonDocument.Parse(result.GetRawResponse().Content); + InternalOpenAIPaginatedListResultOfT typedDataResult + = InternalOpenAIPaginatedListResultOfT.DeserializeInternalOpenAIPaginatedListResultOfT( + pageDocument.RootElement, + _dataItemDeserializer, + options: ModelReaderWriterOptions.Json); + return typedDataResult; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/InternalOpenAICollectionResultOptions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/InternalOpenAICollectionResultOptions.cs new file mode 100644 index 000000000000..a8e5e47cd72c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/InternalOpenAICollectionResultOptions.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI; + +internal partial class InternalOpenAICollectionResultOptions +{ + public string ParentResourceId { get; set; } + public int? Limit { get; set; } + public string Order { get; set; } + public string AfterId { get; set; } + public string BeforeId { get; set; } + public List Filters { get; } = []; + public List Includes { get; } = []; + public Dictionary ExtraQueryMap { get; } = []; + + public InternalOpenAICollectionResultOptions(int? limit = null, string order = null, string after = null, string before = null, IEnumerable filters = null, IEnumerable includes = null, IReadOnlyDictionary extraQueryMap = null) + { + Limit = limit; + Order = order; + AfterId = after; + BeforeId = before; + Filters ??= []; + foreach (string maybeFilter in filters ?? []) + { + if (!string.IsNullOrEmpty(maybeFilter)) + { + Filters.Add(maybeFilter); + } + } + Includes ??= []; + foreach (string maybeInclude in includes ?? []) + { + if (!string.IsNullOrEmpty(maybeInclude)) + { + Includes.Add(maybeInclude); + } + } + ExtraQueryMap ??= []; + if (extraQueryMap is not null) + { + foreach (KeyValuePair pair in extraQueryMap) + { + ExtraQueryMap.Add(pair.Key, pair.Value); + } + } + } + + public InternalOpenAICollectionResultOptions GetCloneForPage(InternalOpenAIPaginatedListResultOfT page) + { + InternalOpenAICollectionResultOptions clonedOptions = new() + { + ParentResourceId = ParentResourceId, + Limit = Limit, + Order = Order, + AfterId = page.LastId, + BeforeId = page.FirstId, + }; + clonedOptions.Filters.AddRange(Filters); + clonedOptions.Includes.AddRange(Includes); + foreach (KeyValuePair pair in ExtraQueryMap) + { + clonedOptions.ExtraQueryMap.Add(pair.Key, pair.Value); + } + + return clonedOptions; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/InternalOpenAIPaginatedListResultOfT.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/InternalOpenAIPaginatedListResultOfT.cs new file mode 100644 index 000000000000..57cb57f852b6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/InternalOpenAIPaginatedListResultOfT.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI; + +internal partial class InternalOpenAIPaginatedListResultOfT : ReadOnlyCollection +{ + public string FirstId { get; } + public string LastId { get; } + public bool HasMore { get; } + + internal InternalOpenAIPaginatedListResultOfT() : base(new ChangeTrackingList()) + { } + + internal InternalOpenAIPaginatedListResultOfT(string firstId, string lastId, bool hasMore, IList data) + : base(data) + { + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + } + + internal static InternalOpenAIPaginatedListResultOfT DeserializeInternalOpenAIPaginatedListResultOfT( + ClientResult protocolResult, + Func dataItemDeserializer, + ModelReaderWriterOptions options) + { + using JsonDocument document = JsonDocument.Parse(protocolResult.GetRawResponse().ContentStream); + return DeserializeInternalOpenAIPaginatedListResultOfT(document.RootElement, dataItemDeserializer, options); + } + + internal static InternalOpenAIPaginatedListResultOfT DeserializeInternalOpenAIPaginatedListResultOfT( + JsonElement element, + Func dataItemDeserializer, + ModelReaderWriterOptions options) + { + if (element.ValueKind != JsonValueKind.Object) + { + return null; + } + + string firstId = null; + string lastId = null; + bool hasMore = false; + List data = []; + + foreach (JsonProperty topProperty in element.EnumerateObject()) + { + if (topProperty.NameEquals("first_id"u8)) + { + firstId = topProperty.Value.GetString(); + } + else if (topProperty.NameEquals("last_id"u8)) + { + lastId = topProperty.Value.GetString(); + } + else if (topProperty.NameEquals("has_more"u8)) + { + hasMore = topProperty.Value.GetBoolean(); + } + else if (topProperty.NameEquals("data"u8)) + { + if (topProperty.Value.ValueKind == JsonValueKind.Array) + { + foreach (JsonElement dataElement in topProperty.Value.EnumerateArray()) + { + TData dataItem = dataItemDeserializer.Invoke(dataElement, options); + data.Add(dataItem); + } + } + } + } + + return new(firstId, lastId, hasMore, data); + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/PipelinePolicyHelpers.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/PipelinePolicyHelpers.cs new file mode 100644 index 000000000000..beb68dc43946 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/PipelinePolicyHelpers.cs @@ -0,0 +1,248 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.IO; +using System.Text; +using System.Text.Json.Nodes; +using System.Text.RegularExpressions; +using OpenAI.Files; + +namespace Azure.AI.Projects.OpenAI; + +#pragma warning disable CS0618 + +internal static partial class PipelinePolicyHelpers +{ + /// + /// Adds a policy to that ensures a query parameter with the provided/key value is present. + /// + /// + /// + /// + public static void AddQueryParameterPolicy(ClientPipelineOptions options, string key, string value) + => AddQueryParameterPolicy(options, key, () => value); + + /// + /// Adds a policy to that ensures a query parameter with the key is present, delay-invoking the provided value generator. + /// + /// + /// + /// + public static void AddQueryParameterPolicy(ClientPipelineOptions options, string key, Func valueGenerator) + { + options.AddPolicy( + new GenericActionPipelinePolicy( + requestAction: request => + { + if (request?.Uri is Uri requestUri + && requestUri.Query?.ToLowerInvariant()?.Contains($"{key.ToLowerInvariant()}=") != true + && requestUri.Query?.ToLowerInvariant()?.Contains($"{key.ToLowerInvariant()}[]=") != true + && valueGenerator.Invoke() is string generatedValue + && !string.IsNullOrEmpty(generatedValue)) + { + ClientUriBuilder builder = new(); + builder.Reset(requestUri); + builder.AppendQuery(key, generatedValue, escape: true); + + // ClientUriBuilder.Reset removes existing query; we need to restore it + request.Uri = string.IsNullOrEmpty(requestUri.Query) + ? builder.ToUri() + : new Uri($"{builder.ToUri()}&{requestUri.Query.Substring(1)}"); + } + }), + PipelinePosition.PerCall); + } + + public static void AddRequestHeaderPolicy(ClientPipelineOptions options, string key, string value, bool replaceExisting = false) + => AddRequestHeaderPolicy(options, key, () => value); + + public static void AddRequestHeaderPolicy(ClientPipelineOptions options, string key, Func valueGenerator, bool replaceExisting = false) + { + options.AddPolicy( + new GenericActionPipelinePolicy( + requestAction: request => + { + if (replaceExisting || !request.Headers.TryGetValue(key, out string _)) + { + request.Headers.Set(key, valueGenerator.Invoke()); + } + }), + PipelinePosition.PerCall); + } + + internal static partial class OpenAI + { + /// + /// Adds a policy to that removes "id" and "status" properties from each item in an array of OpenAIResponse items, as needed for full compatibility in specific operations. + /// + /// + /// This is a workaround for an issue in the OpenAI library: https://github.com/openai/openai-dotnet/issues/779 + /// + /// + public static void AddResponseItemInputTransformPolicy(ClientPipelineOptions options) + { + options.AddPolicy(new GenericActionPipelinePolicy( + requestAction: request => + { + if (request.Method == "POST" && (request.Uri?.AbsoluteUri?.EndsWith("/responses") == true || request.Uri?.AbsoluteUri?.Contains("/responses?") == true)) + { + using MemoryStream stream = new(); + request.Content.WriteTo(stream); + stream.Position = 0; + JsonNode node = JsonNode.Parse(stream); + if (node.AsObject() is JsonObject responseRequestObject + && responseRequestObject.TryGetPropertyValue("input", out JsonNode inputNode) == true + && inputNode.AsArray() is JsonArray inputArray) + { + foreach (JsonNode inputItemNode in inputArray) + { + if (inputItemNode?.AsObject() is JsonObject inputItemObject) + { + inputItemObject.Remove("id"); + inputItemObject.Remove("status"); + } + } + + request.Content = BinaryContent.Create(BinaryData.FromString(node.ToJsonString())); + } + } + }), + PipelinePosition.PerCall); + } + + /// + /// Adds a policy to that aggressively transforms divergent error response payloads into something with user-facing information. + /// Error response to exception message conversion is handled in the external OpenAI library for Responses and other OpenAI-based calls, so this heavier-weight + /// content reformatting is necessary (in contrast to internal calls, where we can control the deserialization directly). + /// + /// + /// This is a temporary workaround for internal issue 4771165. + /// + /// + public static void AddErrorTransformPolicy(ClientPipelineOptions options) + { + options.AddPolicy( + new GenericActionPipelinePolicy( + responseAction: response => + { + if (response?.IsError == true) + { + response.BufferContent(); + try + { + if (JsonNode.Parse(response.Content) is JsonObject errorResponseJsonObject) + { + if (FoundryOpenAIError.TryCreateFromResponse(response) is FoundryOpenAIError apiErrorInstance) + { + response.ContentStream = new MemoryStream(apiErrorInstance.ToOpenAIError().ToArray()); + } + else if (errorResponseJsonObject.TryGetPropertyValue("error", out JsonNode errorNode) + && errorNode is JsonObject errorObject + && (errorObject.TryGetPropertyValue("additional_info", out JsonNode _) + || errorObject.TryGetPropertyValue("details", out JsonNode _))) + { + StringBuilder messageRebuilder = new(errorObject.TryGetPropertyValue("message", out JsonNode messageNode) ? messageNode.ToString() : string.Empty); + messageRebuilder.AppendLine().AppendLine(); + messageRebuilder.Append(errorObject.ToString()); + + response.ContentStream = new MemoryStream(BinaryData.FromString($$""" + { + "error": { + "type": "ServiceError", + "code": {{JsonValue.Create(errorObject.TryGetPropertyValue("code", out JsonNode codeNode) ? codeNode.ToString() : string.Empty).ToJsonString()}}, + "param": {{JsonValue.Create(errorObject.TryGetPropertyValue("paramNode", out JsonNode paramNode) ? paramNode.ToString() : string.Empty).ToJsonString()}}, + "message": {{JsonValue.Create(messageRebuilder.ToString()).ToJsonString()}} + } + } + """).ToArray()); + } + } + } + catch (System.Text.Json.JsonException) + { } + } + }), + PipelinePosition.PerTry); + } + + public static void AddAzureFinetuningParityPolicy(ClientPipelineOptions options) + { + options.AddPolicy( + new GenericActionPipelinePolicy( + messageAction: message => + { + // Skip this policy for everything except file operations + if (message?.Request?.Uri?.AbsoluteUri?.Contains("openai/files") == false) + { + return; + } + + // When processing the message to send the request (no response yet), perform a fixup to ensure a multipart/form-data Content-Type is + // provided for the "file" content part (non-parity limitation) + if (message?.Request?.Method == "POST" && message?.Request is not null && message?.Response is null) + { + using MemoryStream requestStream = new(); + message.Request.Content.WriteTo(requestStream); + requestStream.Position = 0; + using StreamReader reader = new(requestStream); + + MemoryStream newRequestStream = new(); + StreamWriter newRequestWriter = new(newRequestStream); + string previousLine = null; + + for (string line = reader.ReadLine(); line is not null; line = reader.ReadLine()) + { + if (line == string.Empty + && Regex.Match( + previousLine, + "Content-Disposition: form-data; name=file; filename=([^;]*);.*") is Match fileContentDispositionMatch + && fileContentDispositionMatch.Success) + { + // We are explicitly set the line ending as + // WriteLine will add only \n symbol on Unix systems, + // Which will result in error 400 on te service side. + newRequestWriter.Write("Content-Type: application/octet-stream\r\n"); + } + newRequestWriter.Write($"{line}\r\n"); + previousLine = line; + } + + newRequestWriter.Flush(); + newRequestStream.Position = 0; + message.Request.Content = BinaryContent.Create(newRequestStream); + message.ResponseClassifier = PipelineMessageClassifier; + } + + // When processing the message for the response, force non-OpenAI "status" values to "processed" and relocate the extended value + // to an additional property + if (message?.Response is not null) + { + message?.Response.BufferContent(); + + // Only parse as JSON if the response Content-Type indicates JSON + string contentType = message?.Response?.Headers?.TryGetValue("Content-Type", out string ct) == true ? ct : string.Empty; + bool isJsonResponse = contentType.IndexOf("application/json", StringComparison.OrdinalIgnoreCase) >= 0; + + if (isJsonResponse + && JsonNode.Parse(message?.Response?.ContentStream) is JsonObject responseObject + && responseObject.TryGetPropertyValue("status", out JsonNode statusNode) + && statusNode is JsonValue statusValue + && !Enum.TryParse(statusValue.ToString(), out FileStatus _)) + { + responseObject["status"] = "processed"; + responseObject["_sdk_status"] = statusValue.ToString(); + message.Response.ContentStream = new MemoryStream(BinaryData.FromString(responseObject.ToJsonString()).ToArray()); + } + } + }), + PipelinePosition.PerCall); + } + + private static PipelineMessageClassifier s_pipelineMessageClassifier; + private static PipelineMessageClassifier PipelineMessageClassifier + => s_pipelineMessageClassifier ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200, 201 }); + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/ResponseItemHelpers.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/ResponseItemHelpers.cs new file mode 100644 index 000000000000..764a92262c9a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/ResponseItemHelpers.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.IO; +using System.Text.Json; +using OpenAI; +using OpenAI.Responses; + +namespace Azure.AI.Projects.OpenAI; + +#pragma warning disable SCME0001 + +internal static partial class ResponseItemHelpers +{ + internal static void DeserializeItemsValue(JsonProperty property, ref IList items) + { + if (property.Value.ValueKind == JsonValueKind.Array) + { + List deserializedItems = []; + foreach (JsonElement serializedResponseItemElement in property.Value.EnumerateArray()) + { + ResponseItem deserializedItem = ModelReaderWriter.Read( + BinaryData.FromString(serializedResponseItemElement.GetRawText()), + ModelReaderWriterOptions.Json, + OpenAIContext.Default); + deserializedItems.Add(deserializedItem); + } + items = deserializedItems; + } + } + + internal static void SerializeItemsValue(Utf8JsonWriter writer, IEnumerable items, ModelReaderWriterOptions options) + { + if (items is null) + { + writer.WriteNullValue(); + } + else + { + writer.WriteStartArray(); + foreach (ResponseItem item in items) + { + (item as IJsonModel)?.Write(writer, ModelSerializationExtensions.WireOptions); + } + writer.WriteEndArray(); + } + } + + internal static BinaryContent GetItemsRequestContent(IEnumerable items) + { + MemoryStream memoryStream = new(); + Utf8JsonWriter writer = new(memoryStream); + writer.WriteStartObject(); + writer.WritePropertyName("items"u8); + SerializeItemsValue(writer, items, ModelSerializationExtensions.WireOptions); + writer.WriteEndObject(); + writer.Flush(); + memoryStream.Position = 0; + return BinaryContent.Create(memoryStream); + } + + internal static ResponseItem GetCopyForInput(this ResponseItem item) + { + BinaryData serializedItem = ModelReaderWriter.Write(item, ModelSerializationExtensions.WireOptions, OpenAIContext.Default); + ResponseItem copiedItem = ModelReaderWriter.Read(serializedItem, ModelSerializationExtensions.WireOptions, OpenAIContext.Default); + copiedItem.Patch.Set("$.id"u8, string.Empty); + copiedItem.Patch.Set("$.status"u8, string.Empty); + copiedItem.Patch.Remove("$.id"u8); + copiedItem.Patch.Remove("$.status"u8); + return copiedItem; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/TelemetryDetails.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/TelemetryDetails.cs new file mode 100644 index 000000000000..f44c87312203 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/TelemetryDetails.cs @@ -0,0 +1,197 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Net; +using System.Net.Http.Headers; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Text; + +#nullable enable + +namespace Azure.AI.Projects.OpenAI; + +/// +/// Details about the package to be included in UserAgent telemetry +/// +internal class TelemetryDetails +{ + private const int MaxApplicationIdLength = 99; + + /// + /// The package type represented by this instance. + /// + public Assembly Assembly { get; } + + public RuntimeInformationWrapper Runtime { get; } + + private UserAgentInfo? _cachedUserAgentInfo = null; + public UserAgentInfo UserAgent => _cachedUserAgentInfo ??= GetUserAgentInfo(); + + private readonly string? _userAgentApplicationId; + + internal TelemetryDetails(Assembly assembly, string? applicationId = null) + : this(assembly, applicationId, new RuntimeInformationWrapper()) + { } + + internal TelemetryDetails(Assembly assembly, string? applicationId = null, RuntimeInformationWrapper? runtimeInformation = default) + { + Argument.AssertNotNull(assembly, nameof(assembly)); + if (applicationId?.Length > MaxApplicationIdLength) + { + throw new ArgumentOutOfRangeException(nameof(applicationId), $"{nameof(applicationId)} must be shorter than {MaxApplicationIdLength + 1} characters"); + } + + Assembly = assembly; + Runtime = runtimeInformation ?? new(); + _userAgentApplicationId = applicationId; + } + + private UserAgentInfo GetUserAgentInfo() + { + string assemblyName = Assembly.GetName().Name!; + + AssemblyInformationalVersionAttribute? versionAttribute + = Assembly.GetCustomAttribute() + ?? throw new InvalidOperationException( + $"{nameof(AssemblyInformationalVersionAttribute)} is required on client SDK assembly '{Assembly.FullName}'."); + + int hashSeparatorPosition = versionAttribute.InformationalVersion.LastIndexOf('+'); + string version = hashSeparatorPosition == -1 + ? versionAttribute.InformationalVersion + : versionAttribute.InformationalVersion.Substring(0, hashSeparatorPosition); + + // RFC 9110 section 5.5 https://www.rfc-editor.org/rfc/rfc9110.txt#section-5.5 does not require any specific encoding : "Fields needing a greater range of characters + // can use an encoding, such as the one defined in RFC8187." RFC8187 is targeted at parameter values, almost always filename, so using url encoding here instead, which is + // more widely used. Since user-agent does not usually contain non-ascii, only encode when necessary. + // This was added to support operating systems with non-ascii characters in their release names. +#if NET8_0_OR_GREATER + string osDescription = Ascii.IsValid(Runtime.OSDescription) ? Runtime.OSDescription : WebUtility.UrlEncode(Runtime.OSDescription); +#else + static bool ContainsNonAscii(string value) + { + foreach (char c in value) + { + if ((int)c > 0x7f) + { + return true; + } + } + return false; + } + string osDescription = ContainsNonAscii(Runtime.OSDescription) ? WebUtility.UrlEncode(Runtime.OSDescription) : Runtime.OSDescription; +#endif + + string platform = EscapeProductInformation($"({Runtime.FrameworkDescription}; {osDescription})"); + + return new UserAgentInfo(assemblyName, version, platform, _userAgentApplicationId); + } + + /// + /// If the ProductInformation is not in the proper format, this escapes any ')' , '(' or '\' characters per https://www.rfc-editor.org/rfc/rfc7230#section-3.2.6 + /// + /// The ProductInfo portion of the UserAgent + /// + private static string EscapeProductInformation(string productInfo) + { + // If the string is already valid, we don't need to escape anything + bool success = false; + try + { + success = ProductInfoHeaderValue.TryParse(productInfo, out var _); + } + catch (Exception) + { + // Invalid values can throw in Framework due to https://github.com/dotnet/runtime/issues/28558 + // Treat this as a failure to parse. + } + if (success) + { + return productInfo; + } + + var sb = new StringBuilder(productInfo.Length + 2); + sb.Append('('); + // exclude the first and last characters, which are the enclosing parentheses + for (int i = 1; i < productInfo.Length - 1; i++) + { + char c = productInfo[i]; + if (c == ')' || c == '(') + { + sb.Append('\\'); + } + // If we see a \, we don't need to escape it if it's followed by a '\', '(', or ')', because it is already escaped. + else if (c == '\\') + { + if (i + 1 < (productInfo.Length - 1)) + { + char next = productInfo[i + 1]; + if (next == '\\' || next == '(' || next == ')') + { + sb.Append(c); + sb.Append(next); + i++; + continue; + } + else + { + sb.Append('\\'); + } + } + else + { + sb.Append('\\'); + } + } + sb.Append(c); + } + sb.Append(')'); + return sb.ToString(); + } + + public class UserAgentInfo + { + public string? ApplicationId { get; } + + public string AssemblyName { get; } + + public string Version { get; } + + public string Platform { get; } + + private string? _cachedValueFull = null; + private string? _cachedValueNoPlatform = null; + + public UserAgentInfo(string assemblyName, string version, string platform, string? applicationId = null) + { + AssemblyName = assemblyName; + Version = version; + Platform = platform; + ApplicationId = applicationId; + } + + public string ToString(bool includePlatformInformation) + { + if (includePlatformInformation) + { + return _cachedValueFull ??= $"{ApplicationId}{(ApplicationId?.Length > 0 == true ? " " : "")}{AssemblyName}/{Version} {Platform}"; + } + else + { + return _cachedValueNoPlatform ??= $"{ApplicationId}{(ApplicationId?.Length > 0 == true ? " " : "")}{AssemblyName}/{Version}"; + } + } + + public override string ToString() => ToString(includePlatformInformation: true); + } + + internal class RuntimeInformationWrapper + { + public virtual string FrameworkDescription => RuntimeInformation.FrameworkDescription; + public virtual string OSDescription => RuntimeInformation.OSDescription; + public virtual Architecture OSArchitecture => RuntimeInformation.OSArchitecture; + public virtual Architecture ProcessArchitecture => RuntimeInformation.ProcessArchitecture; + public virtual bool IsOSPlatform(OSPlatform osPlatform) => RuntimeInformation.IsOSPlatform(osPlatform); + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/TelemetryObjectSerialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/TelemetryObjectSerialization.cs new file mode 100644 index 000000000000..faec98077c28 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Internal/TelemetryObjectSerialization.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text.Encodings.Web; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Text.Json.Serialization.Metadata; + +namespace Azure.AI.Projects.OpenAI; + +// The set of helper classes to serialize the event object. + +internal class EventContent +{ + public string content { get; set; } + public EventContent(string content) { this.content = content; } +} + +internal class EventRole +{ + public string role { get; set; } + public EventRole(string role) { this.role = role; } +} + +internal class EventContentRole +{ + public string content { get; set; } + public string role { get; set; } + public EventContentRole(string content, string role) + { + this.content = content; + this.role = role; + } +} + +internal class EventContentId +{ + public string content { get; set; } + public string id { get; set; } + public EventContentId(string content, string id) + { + this.content = content; + this.id = id; + } +} + +[JsonSerializable(typeof(EventContentId))] +[JsonSerializable(typeof(EventContentRole))] +[JsonSerializable(typeof(EventRole))] +[JsonSerializable(typeof(EventContent))] +[JsonSerializable(typeof(Dictionary))] +internal partial class EventsContext : JsonSerializerContext +{ + private JsonSerializerOptions _options; + + public new JsonSerializerOptions Options + { + get + { + JsonSerializerOptions options = _options; + + if (options is null) + { + options = new JsonSerializerOptions + { + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, // Allow non-ASCII characters + TypeInfoResolver = this + }; + options.MakeReadOnly(); + _options = options; + } + + return options; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/LocalShellToolCallAgentResponseItem.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/LocalShellToolCallAgentResponseItem.cs new file mode 100644 index 000000000000..bb388536675e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/LocalShellToolCallAgentResponseItem.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +namespace Azure.AI.Projects.OpenAI; + +[CodeGenType("LocalShellToolCallItemResource")] +public partial class LocalShellToolCallAgentResponseItem +{ +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/LocalShellToolCallOutputAgentResponseItem.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/LocalShellToolCallOutputAgentResponseItem.cs new file mode 100644 index 000000000000..13ee5b95af13 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/LocalShellToolCallOutputAgentResponseItem.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +namespace Azure.AI.Projects.OpenAI; + +[CodeGenType("LocalShellToolCallOutputItemResource")] +public partial class LocalShellToolCallOutputAgentResponseItem +{ + /// Gets the Status. + [CodeGenMember("Status")] + public LocalShellAgentToolCallStatus Status { get; } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ClientConnectionProviderExtensions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ClientConnectionProviderExtensions.cs new file mode 100644 index 000000000000..94ba99258056 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ClientConnectionProviderExtensions.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.ClientModel.Primitives; + +using Azure.AI.Projects.OpenAI; + +namespace Azure.AI.Projects; + +public static partial class ClientConnectionProviderExtensions +{ + extension(ClientConnectionProvider connectionProvider) + { + public ProjectOpenAIClient GetProjectOpenAIClient(ProjectOpenAIClientOptions options = null) + { + ClientConnection pipelineConnection = connectionProvider.GetConnection("Internal.DirectPipelinePassthrough"); + if (pipelineConnection.CredentialKind == CredentialKind.None) + { + ClientPipeline smuggledPipeline = pipelineConnection.Credential as ClientPipeline; + options ??= new() + { + Endpoint = new Uri(pipelineConnection.Locator), + }; + // If the option without endpoint were provided, make sure, we still set it. + options.Endpoint = new Uri(pipelineConnection.Locator); + return new ProjectOpenAIClient(smuggledPipeline, options); + } + return null; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ExtraDataDictionary.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ExtraDataDictionary.cs new file mode 100644 index 000000000000..a9c71c420428 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ExtraDataDictionary.cs @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; +using System.Text.Json.Nodes; +using OpenAI.Responses; + +#pragma warning disable OPENAI001 +#pragma warning disable SCME0001 + +namespace Azure.AI.Projects.OpenAI; + +public partial class ExtraDataDictionary : IDictionary +{ + private readonly ResponseCreationOptions _parentOptions; + private readonly ReadOnlyMemory _rootPathBytes; + + internal ExtraDataDictionary() + { + } + + internal ExtraDataDictionary(ResponseCreationOptions parentOptions, ReadOnlySpan rootPathBytes) + { + _parentOptions = parentOptions; + _rootPathBytes = new(rootPathBytes.ToArray()); + } + + public BinaryData this[string key] + { + get => TryGetValue(key, out BinaryData value) ? value : throw new KeyNotFoundException(); + set => _parentOptions.Patch.Set(GetPathBytes(key), value); + } + + public BinaryData this[ReadOnlySpan key] + { + get => TryGetValue(key, out BinaryData value) ? value : throw new KeyNotFoundException(); + set => _parentOptions.Patch.Set(GetPathBytes(key), value); + } + + public ICollection Keys => GetFullParsedDictionary().Keys; + + public ICollection Values => GetFullParsedDictionary().Values; + + public int Count => GetFullParsedDictionary().Count; + + public bool IsReadOnly => false; + + public void Add(string key, BinaryData value) => this[key] = value; + + public void Add(KeyValuePair item) => this[item.Key] = item.Value; + + public void Add(string key, string value) => this[key] = BinaryData.FromString(JsonValue.Create(value).ToJsonString()); + + public void Add(string key, int value) => this[key] = BinaryData.FromString($"{value}"); + + public void Add(string key, bool value) => this[key] = BinaryData.FromString($"{value}".ToLowerInvariant()); + + public void Clear() + { + foreach (string key in Keys) + { + Remove(key); + } + } + + public bool Contains(KeyValuePair item) => TryGetValue(item.Key, out BinaryData value) && item.Value == value; + + public bool ContainsKey(string key) => TryGetValue(key, out var _); + + public void CopyTo(KeyValuePair[] array, int arrayIndex) + { + throw new NotImplementedException(); + } + + IEnumerator> IEnumerable>.GetEnumerator() => GetFullParsedDictionary().GetEnumerator(); + + IEnumerator IEnumerable.GetEnumerator() => GetFullParsedDictionary().GetEnumerator(); + + public bool Remove(string key) + { + if (TryGetValue(key, out var _)) + { + _parentOptions.Patch.Remove(GetPathBytes(key)); + return true; + } + return false; + } + + public bool Remove(KeyValuePair item) => Remove(item.Key); + + public bool TryGetValue(ReadOnlySpan key, out BinaryData value) + { + if (_parentOptions.Patch.TryGetJson(GetPathBytes(key), out ReadOnlyMemory jsonValueBytes) + && !jsonValueBytes.IsEmpty) + { + value = BinaryData.FromBytes(jsonValueBytes); + return true; + } + value = null; + return false; + } + + public bool TryGetValue(string key, out BinaryData value) + => TryGetValue(Encoding.UTF8.GetBytes(key), out value); + + public void SetData(BinaryData dictionaryJsonBytes) + { + _parentOptions.Patch.Set(GetPathBytes(), dictionaryJsonBytes); + } + + private Dictionary GetFullParsedDictionary() + { + ReadOnlySpan rootPathBytes = GetPathBytes(); + Dictionary result = new(); + if (_parentOptions.Patch.Contains(rootPathBytes) + && !_parentOptions.Patch.IsRemoved(rootPathBytes) + && _parentOptions.Patch.TryGetJson(rootPathBytes, out ReadOnlyMemory jsonValueBytes) + && !jsonValueBytes.IsEmpty) + { + using JsonDocument document = JsonDocument.Parse(jsonValueBytes); + if (document.RootElement.ValueKind == JsonValueKind.Object) + { + foreach (JsonProperty property in document.RootElement.EnumerateObject()) + { + result.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + } + return result; + } + + private ReadOnlySpan GetPathBytes(string subPath = null) + => subPath is null ? _rootPathBytes.Span : GetPathBytes(Encoding.UTF8.GetBytes(subPath)); + + private ReadOnlySpan GetPathBytes(ReadOnlySpan subPathSpan) + { + if (subPathSpan.IsEmpty) + { + return _rootPathBytes.Span; + } + + ReadOnlySpan indexerStartSpan = "['"u8; + ReadOnlySpan indexerEndSpan = "']"u8; + + Span concatenatedSpan = new byte[_rootPathBytes.Length + indexerStartSpan.Length + subPathSpan.Length + indexerEndSpan.Length].AsSpan(); + + _rootPathBytes.Span.CopyTo(concatenatedSpan); + indexerStartSpan.CopyTo(concatenatedSpan.Slice(_rootPathBytes.Length)); + subPathSpan.CopyTo(concatenatedSpan.Slice(_rootPathBytes.Length + indexerStartSpan.Length)); + indexerEndSpan.CopyTo(concatenatedSpan.Slice(_rootPathBytes.Length + indexerStartSpan.Length + subPathSpan.Length)); + + return concatenatedSpan; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/FoundryOpenAIError.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/FoundryOpenAIError.cs new file mode 100644 index 000000000000..77f164e0c173 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/FoundryOpenAIError.cs @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Linq; +using System.Text; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI; + +/// The ApiError. +[CodeGenType("Error")] +internal partial class FoundryOpenAIError +{ + internal static FoundryOpenAIError TryCreateFromResponse(PipelineResponse response) + { + try + { + using JsonDocument errorDocument = JsonDocument.Parse(response.Content); + FoundryOpenAIError result = DeserializeFoundryOpenAIError(errorDocument.RootElement, ModelSerializationExtensions.WireOptions); + if (string.IsNullOrEmpty(result.Code) && string.IsNullOrEmpty(result.Param) && result.Details?.Count > 0 != true) + { + // Empty or uninteresting JSON documents should be treated like incomplete deserializations + return null; + } + return result; + } + catch (InvalidOperationException) + { + return null; + } + catch (JsonException) + { + return null; + } + catch (NullReferenceException) + { + return null; + } + } + + public string ToExceptionMessage(int httpStatus) + { + StringBuilder messageBuilder = new(); + messageBuilder.Append("HTTP ").Append(httpStatus).Append(" (").Append(Code).AppendLine(")"); + if (!string.IsNullOrEmpty(Param)) + { + messageBuilder.Append("Parameter: ").AppendLine(Param); + } + messageBuilder.AppendLine(); + messageBuilder.Append(Message); + if (Details?.Count > 0 == true) + { + messageBuilder.AppendLine().AppendLine(); + messageBuilder.Append(GetExceptionMessageRecursive()); + foreach (FoundryOpenAIError error in Details) + { + messageBuilder.AppendLine($"{error.Param ?? ""}:"); + messageBuilder.AppendLine().Append($" - {error.ToExceptionMessage(httpStatus)}"); + } + } + return messageBuilder.ToString(); + } + + private string GetExceptionMessageRecursive() + { + StringBuilder messageBuilder = new(); + foreach (FoundryOpenAIError error in Details) + { + messageBuilder.AppendLine($"{error.Param ?? ""}: {error.Message}"); + messageBuilder.AppendLine().Append($" - {error.GetExceptionMessageRecursive()}"); + } + return messageBuilder.ToString(); + } + + /// + /// Converts this instance payload into a formatted, equivalent response payload that conforms to the + /// expected schema in the OpenAI library. This will allow mechanisms like automatic exception message propagation to function as + /// intended. + /// + /// + public BinaryData ToOpenAIError() + { + StringBuilder messageBuilder = new(Message); + string parameterDetails = null; + if (Details?.Count > 0) + { + messageBuilder.Append(" ("); + foreach (FoundryOpenAIError error in Details) + { + messageBuilder.Append(error.GetExceptionMessageRecursive()); + messageBuilder.Append("; "); + } + messageBuilder.Remove(messageBuilder.Length - 2, 2); + messageBuilder.Append(')'); + parameterDetails = string.Join(";", Details.Select(x => x.Param)); + } + BinaryData newErrorBytes = BinaryData.FromString($$""" + { + "error": { + "message": "{{messageBuilder}}", + "type": "{{nameof(FoundryOpenAIError)}}", + "param": "{{(parameterDetails ?? string.Empty)}}", + "code": "{{(Code ?? string.Empty)}}" + } + } + """); + return newErrorBytes; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/JsonPatchExtensions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/JsonPatchExtensions.cs new file mode 100644 index 000000000000..d2657e17d881 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/JsonPatchExtensions.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable enable + +using System; +using System.ClientModel.Primitives; + +#pragma warning disable SCME0001 + +namespace Azure.AI.Projects.OpenAI; + +internal static partial class JsonPatchExtensions +{ + public static string? GetStringEx(this ref JsonPatch patch, ReadOnlySpan jsonPath) + => patch.IsRemoved(jsonPath) + || !patch.TryGetJson(jsonPath, out ReadOnlyMemory jsonBytes) + || jsonBytes.IsEmpty + ? null + : patch.GetString(jsonPath); + + public static T? GetJsonModelEx(this ref JsonPatch patch, ReadOnlySpan jsonPath, ModelReaderWriterContext? readerContext = null) + where T : class, IJsonModel + { + if (patch.IsRemoved(jsonPath) || !patch.TryGetJson(jsonPath, out ReadOnlyMemory jsonBytes) || jsonBytes.IsEmpty) + { + return null; + } + readerContext ??= AzureAIProjectsOpenAIContext.Default; + return ModelReaderWriter.Read(BinaryData.FromBytes(jsonBytes), ModelSerializationExtensions.WireOptions, readerContext); + } + + public static void SetOrClearEx(this ref JsonPatch patch, ReadOnlySpan jsonPath, ReadOnlySpan jsonRemovalPath, string? value) + { + if (value is null) + { + patch.Remove(jsonRemovalPath); + } + else + { + patch.Set(jsonPath, value); + } + } + + public static void SetOrClearEx( + this ref JsonPatch patch, + ReadOnlySpan jsonPath, + ReadOnlySpan jsonRemovalPath, + T? value, + ModelReaderWriterContext? writerContext = null) + where T : IJsonModel + { + if (value is null) + { + patch.Remove(jsonRemovalPath); + } + else + { + writerContext ??= AzureAIProjectsOpenAIContext.Default; + patch.Set(jsonPath, ModelReaderWriter.Write(value, ModelSerializationExtensions.WireOptions, writerContext)); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/OpenAIResponseExtensions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/OpenAIResponseExtensions.cs new file mode 100644 index 000000000000..37df708ab9c4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/OpenAIResponseExtensions.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using OpenAI.Responses; + +#pragma warning disable OPENAI001 +#pragma warning disable SCME0001 + +namespace Azure.AI.Projects.OpenAI; + +public static partial class OpenAIResponseExtensions +{ + extension(OpenAIResponse response) + { + public AgentReference Agent => response.Patch.GetJsonModelEx("$.agent"u8); + + public string AgentConversationId => response.Patch.GetStringEx("$.conversation.id"u8); + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectConversationCreationOptions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectConversationCreationOptions.cs new file mode 100644 index 000000000000..a1a39fd2bb50 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectConversationCreationOptions.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; +using OpenAI.Responses; + +namespace Azure.AI.Projects.OpenAI; + +[CodeGenType("CreateConversationRequest")] +[CodeGenSerialization(nameof(Items), SerializationName = "items", DeserializationValueHook = nameof(DeserializeItemsValue), SerializationValueHook = nameof(SerializeItemsValue))] +public partial class ProjectConversationCreationOptions +{ + /// + /// Initial items to include the conversation context. + /// You may add up to 20 items at a time. + /// + [CodeGenMember("Items")] + public IList Items { get; } + + /// Initializes a new instance of . + public ProjectConversationCreationOptions() + { + Metadata = new ChangeTrackingDictionary(); + Items = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + /// + /// Initial items to include the conversation context. + /// You may add up to 20 items at a time. + /// + /// Keeps track of any properties unknown to the library. + internal ProjectConversationCreationOptions(IDictionary metadata, IList items, IDictionary additionalBinaryDataProperties) + { + Metadata = metadata; + Items = items; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + private void SerializeItemsValue(Utf8JsonWriter writer, ModelReaderWriterOptions options) + => ResponseItemHelpers.SerializeItemsValue(writer, Items, options); + + private static void DeserializeItemsValue(JsonProperty property, ref IList items) + => ResponseItemHelpers.DeserializeItemsValue(property, ref items); +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectConversationUpdateOptions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectConversationUpdateOptions.cs new file mode 100644 index 000000000000..b456b3720e64 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectConversationUpdateOptions.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Azure.AI.Projects.OpenAI; + +[CodeGenType("UpdateConversationRequest")] +public partial class ProjectConversationUpdateOptions +{ + /// Initializes a new instance of . + public ProjectConversationUpdateOptions() + { + Metadata = new ChangeTrackingDictionary(); + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectConversationsClient.RestClient.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectConversationsClient.RestClient.cs new file mode 100644 index 000000000000..fca5386e3ab6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectConversationsClient.RestClient.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel.Primitives; +using System.Collections.Generic; +using OpenAI.Conversations; + +namespace Azure.AI.Projects.OpenAI; + +public partial class ProjectConversationsClient : ConversationClient +{ + /* + * Protocol message implementations are reproduced from the official OpenAI library + * https://github.com/openai/openai-dotnet/blob/ba45b1f4a01b0f0ca6e0e75d6382d7a1662ffa90/src/Generated/ConversationClient.RestClient.cs#L18 + * This logic is temporary pending incorporation of convenience layer Conversations support in the official library. + */ + + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + internal virtual PipelineMessage CreateGetProjectConversationsRequest(int? limit, string order, string after, string before, string agentName, string agentId, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/conversations", false); + if (limit != null) + { + uri.AppendQuery("limit", TypeFormatters.ConvertToString(limit), true); + } + if (order != null) + { + uri.AppendQuery("order", order, true); + } + if (after != null) + { + uri.AppendQuery("after", after, true); + } + if (before != null) + { + uri.AppendQuery("before", before, true); + } + if (agentName != null) + { + uri.AppendQuery("agent_name", agentName, true); + } + if (agentId != null) + { + uri.AppendQuery("agent_id", agentId, true); + } + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal virtual PipelineMessage CreateGetProjectConversationItemsRequest(string conversationId, string itemKind, int? limit, string order, string after, string before, IEnumerable include, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/conversations/", false); + uri.AppendPath(conversationId, true); + uri.AppendPath("/items", false); + if (itemKind != null) + { + uri.AppendQuery("item_type", itemKind, true); + } + if (limit != null) + { + uri.AppendQuery("limit", TypeFormatters.ConvertToString(limit), true); + } + if (order != null) + { + uri.AppendQuery("order", order, true); + } + if (after != null) + { + uri.AppendQuery("after", after, true); + } + if (before != null) + { + uri.AppendQuery("before", before, true); + } + if (include != null && !(include is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined)) + { + foreach (var @param in include) + { + uri.AppendQuery("include", @param.ToString(), true); + } + } + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectConversationsClient.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectConversationsClient.cs new file mode 100644 index 000000000000..8a1c53866bb2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectConversationsClient.cs @@ -0,0 +1,281 @@ +// 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.Collections.ObjectModel; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Azure.AI.Projects.OpenAI; +using OpenAI; +using OpenAI.Conversations; +using OpenAI.Responses; + +namespace Azure.AI.Projects.OpenAI; + +public partial class ProjectConversationsClient : ConversationClient +{ + /* + * These convenience methods (returning strongly-typed response items) are temporary, pending strongly-typed convenience method support in the official OpenAI ConversationClient. + */ + + private readonly Uri _endpoint; + + public ProjectConversationsClient(ClientPipeline pipeline, OpenAIClientOptions options) + : base(pipeline, options) + { + _endpoint = options.Endpoint; + } + + public virtual ClientResult CreateProjectConversation(ProjectConversationCreationOptions options = null, CancellationToken cancellationToken = default) + { + options ??= new(); + ClientResult protocolResult = base.CreateConversation(BinaryContent.Create(ModelReaderWriter.Write(options, ModelSerializationExtensions.WireOptions, AzureAIProjectsOpenAIContext.Default)), cancellationToken.ToRequestOptions()); + return protocolResult.ToAgentClientResult(); + } + + public virtual async Task> CreateProjectConversationAsync(ProjectConversationCreationOptions options = null, CancellationToken cancellationToken = default) + { + options ??= new(); + ClientResult protocolResult = await base.CreateConversationAsync(BinaryContent.Create(ModelReaderWriter.Write(options, ModelSerializationExtensions.WireOptions, AzureAIProjectsOpenAIContext.Default)), cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return protocolResult.ToAgentClientResult(); + } + + /// Returns the list of all conversations. + /// + /// If provided, only conversations associated with the referenced agent will be retrieved. + /// + /// + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the + /// default is 20. + /// + /// + /// Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` + /// for descending order. + /// + /// + /// 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. + /// + /// + /// 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. + /// + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual CollectionResult GetProjectConversations(AgentReference agent = null, int? limit = default, string order = null, string after = default, string before = default, CancellationToken cancellationToken = default) + { + string agentNameToUse = string.IsNullOrEmpty(agent?.Version) ? agent?.Name : null; + string agentIdToUse = string.IsNullOrEmpty(agent?.Version) ? null : $"{agent?.Name}:{agent?.Version}"; + + return new InternalOpenAICollectionResultOfT( + Pipeline, + messageGenerator: (localCollectionOptions, localRequestOptions) + => CreateGetProjectConversationsRequest( + localCollectionOptions.Limit, + localCollectionOptions.Order, + localCollectionOptions.AfterId, + localCollectionOptions.BeforeId, + localCollectionOptions.Filters.Count > 0 ? localCollectionOptions.Filters[0] : null, + localCollectionOptions.Filters.Count > 1 ? localCollectionOptions.Filters[1] : null, + localRequestOptions), + dataItemDeserializer: ProjectConversation.DeserializeProjectConversation, + new InternalOpenAICollectionResultOptions(limit, order?.ToString(), after, before, filters: [agentNameToUse, agentIdToUse]), + cancellationToken.ToRequestOptions()); + } + + /// Returns the list of all conversations. + /// + /// If provided, only conversations associated with the referenced agent will be retrieved. + /// + /// + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the + /// default is 20. + /// + /// + /// Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` + /// for descending order. + /// + /// + /// 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. + /// + /// + /// 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. + /// + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual AsyncCollectionResult GetProjectConversationsAsync(AgentReference agent = null, int? limit = default, string order = null, string after = default, string before = default, CancellationToken cancellationToken = default) + { + string agentNameToUse = string.IsNullOrEmpty(agent?.Version) ? agent?.Name : null; + string agentIdToUse = string.IsNullOrEmpty(agent?.Version) ? null : $"{agent?.Name}:{agent?.Version}"; + + return new InternalOpenAIAsyncCollectionResultOfT( + Pipeline, + messageGenerator: (localCollectionOptions, localRequestOptions) + => CreateGetProjectConversationsRequest( + localCollectionOptions.Limit, + localCollectionOptions.Order, + localCollectionOptions.AfterId, + localCollectionOptions.BeforeId, + localCollectionOptions.Filters.Count > 0 ? localCollectionOptions.Filters[0] : null, + localCollectionOptions.Filters.Count > 1 ? localCollectionOptions.Filters[1] : null, + localRequestOptions), + dataItemDeserializer: ProjectConversation.DeserializeProjectConversation, + new InternalOpenAICollectionResultOptions(limit, order?.ToString(), after, before, filters: [agentNameToUse, agentIdToUse]), + cancellationToken.ToRequestOptions()); + } + + public virtual ClientResult GetProjectConversation(string conversationId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + ClientResult protocolResult = base.GetConversation(conversationId, cancellationToken.ToRequestOptions()); + return protocolResult.ToAgentClientResult(); + } + + public virtual async Task> GetProjectConversationAsync(string conversationId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + ClientResult protocolResult = await base.GetConversationAsync(conversationId, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return protocolResult.ToAgentClientResult(); + } + + public virtual CollectionResult GetProjectConversationItems( + string conversationId, + AgentResponseItemKind? itemKind = null, + int? limit = null, + string order = null, + string after = null, + string before = null, + IEnumerable include = null, + CancellationToken cancellationToken = default) + { + return new InternalOpenAICollectionResultOfT( + Pipeline, + messageGenerator: (localCollectionOptions, localRequestOptions) + => CreateGetProjectConversationItemsRequest( + conversationId, + localCollectionOptions.Filters.Count > 0 ? localCollectionOptions.Filters[0] : null, + localCollectionOptions.Limit, + localCollectionOptions.Order, + localCollectionOptions.AfterId, + localCollectionOptions.BeforeId, + localCollectionOptions.Includes.Select(rawInclude => new IncludedConversationItemProperty(rawInclude)), + localRequestOptions), + dataItemDeserializer: AgentResponseItem.DeserializeAgentResponseItem, + new InternalOpenAICollectionResultOptions(limit, order, after, before: before, filters: [itemKind?.ToString()], includes: include?.Select(includeProperty => includeProperty.ToString()) ?? []), + cancellationToken.ToRequestOptions()); + } + + public virtual AsyncCollectionResult GetProjectConversationItemsAsync( + string conversationId, + AgentResponseItemKind? itemKind = null, + int? limit = null, + string order = null, + string after = null, + string before = null, + IEnumerable include = null, + CancellationToken cancellationToken = default) + { + return new InternalOpenAIAsyncCollectionResultOfT( + Pipeline, + messageGenerator: (localCollectionOptions, localRequestOptions) + => CreateGetProjectConversationItemsRequest( + conversationId, + localCollectionOptions.Filters.Count > 0 ? localCollectionOptions.Filters[0] : null, + localCollectionOptions.Limit, + localCollectionOptions.Order, + localCollectionOptions.AfterId, + localCollectionOptions.BeforeId, + localCollectionOptions.Includes.Select(rawInclude => new IncludedConversationItemProperty(rawInclude)), + localRequestOptions), + dataItemDeserializer: AgentResponseItem.DeserializeAgentResponseItem, + new InternalOpenAICollectionResultOptions(limit, order, after, before: before, filters: [itemKind?.ToString()], includes: include?.Select(includeProperty => includeProperty.ToString()) ?? []), + cancellationToken.ToRequestOptions()); + } + + public virtual ClientResult GetProjectConversationItem(string conversationId, string itemId, IEnumerable include = null, CancellationToken cancellationToken = default) + { + ClientResult protocolResult = GetConversationItem(conversationId, itemId, include, cancellationToken.ToRequestOptions()); + return protocolResult.ToAgentClientResult(); + } + + public virtual async Task> GetProjectConversationItemAsync(string conversationId, string itemId, IEnumerable include = null, CancellationToken cancellationToken = default) + { + ClientResult protocolResult = await GetConversationItemAsync(conversationId, itemId, include, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return protocolResult.ToAgentClientResult(); + } + + /// Create items in a conversation with the given ID. + /// The id of the conversation on which the item needs to be created. + /// The items to add to the conversation. You may add up to 20 items at a time. + /// + /// Additional fields to include in the response. + /// See the `include` parameter for listing Conversation items for more information. + /// + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult> CreateProjectConversationItems(string conversationId, IEnumerable items, IEnumerable include = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + BinaryContent content = ResponseItemHelpers.GetItemsRequestContent(items); + + ClientResult protocolResult = base.CreateConversationItems(conversationId, content, include, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue(new ReadOnlyCollection( + InternalOpenAIPaginatedListResultOfT.DeserializeInternalOpenAIPaginatedListResultOfT( + protocolResult, + (element, options) => AgentResponseItem.DeserializeAgentResponseItem(element, options).AsOpenAIResponseItem(), + ModelSerializationExtensions.WireOptions)), + protocolResult.GetRawResponse()); + } + + /// Create items in a conversation with the given ID. + /// The id of the conversation on which the item needs to be created. + /// The items to add to the conversation. You may add up to 20 items at a time. + /// + /// Additional fields to include in the response. + /// See the `include` parameter for listing Conversation items for more information. + /// + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task>> CreateProjectConversationItemsAsync(string conversationId, IEnumerable items, IEnumerable include = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(conversationId, nameof(conversationId)); + BinaryContent content = ResponseItemHelpers.GetItemsRequestContent(items); + + ClientResult protocolResult = await base.CreateConversationItemsAsync(conversationId, content, include, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue(new ReadOnlyCollection( + InternalOpenAIPaginatedListResultOfT.DeserializeInternalOpenAIPaginatedListResultOfT( + protocolResult, + (element, options) => AgentResponseItem.DeserializeAgentResponseItem(element, options).AsOpenAIResponseItem(), + ModelSerializationExtensions.WireOptions)), + protocolResult.GetRawResponse()); + } + + public virtual ClientResult UpdateProjectConversation(string conversationId, ProjectConversationUpdateOptions options, CancellationToken cancellationToken = default) + { + ClientResult protocolResult = base.UpdateConversation(conversationId, BinaryContent.Create(ModelReaderWriter.Write(options, ModelSerializationExtensions.WireOptions, AzureAIProjectsOpenAIContext.Default)), cancellationToken.ToRequestOptions()); + return protocolResult.ToAgentClientResult(); + } + + public virtual async Task> UpdateProjectConversationAsync(string conversationId, ProjectConversationUpdateOptions options, CancellationToken cancellationToken = default) + { + ClientResult protocolResult = await base.UpdateConversationAsync(conversationId, BinaryContent.Create(ModelReaderWriter.Write(options, ModelSerializationExtensions.WireOptions, AzureAIProjectsOpenAIContext.Default)), cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return protocolResult.ToAgentClientResult(); + } + + protected ProjectConversationsClient() + { } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectFilesClient.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectFilesClient.cs new file mode 100644 index 000000000000..375d9b56fa04 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectFilesClient.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel.Primitives; +using OpenAI; +using OpenAI.Files; + +namespace Azure.AI.Projects.OpenAI; + +public partial class ProjectFilesClient : OpenAIFileClient +{ + internal ProjectFilesClient(ClientPipeline pipeline, OpenAIClientOptions options) + : base(pipeline, options) + { + } + + protected ProjectFilesClient() + { } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectOpenAIClient.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectOpenAIClient.cs new file mode 100644 index 000000000000..b7295adf1340 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectOpenAIClient.cs @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.ComponentModel; +using System.Threading; +using OpenAI; +using OpenAI.Conversations; +using OpenAI.Files; +using OpenAI.Responses; + +namespace Azure.AI.Projects.OpenAI; + +public partial class ProjectOpenAIClient : OpenAIClient +{ + public virtual ProjectConversationsClient Conversations => GetProjectConversationsClient(); + public virtual ProjectResponsesClient Responses => GetProjectResponsesClient(); + public virtual ProjectFilesClient Files => GetProjectFilesClient(); + public virtual ProjectVectorStoresClient VectorStores => GetProjectVectorStoresClient(); + + private ProjectConversationsClient _cachedConversationClient; + private ProjectResponsesClient _cachedResponseClient; + private ProjectFilesClient _cachedFileClient; + private ProjectVectorStoresClient _cachedVectorStoreClient; + + private readonly ProjectOpenAIClientOptions _options; + + private static string s_defaultAuthorizationScope = "https://ai.azure.com/.default"; + + public ProjectOpenAIClient(Uri projectEndpoint, AuthenticationTokenProvider tokenProvider, ProjectOpenAIClientOptions options = null) + : base( + pipeline: CreatePipeline( + CreateAuthenticationPolicy(tokenProvider, options), + GetMergedOptions(projectEndpoint, options)), + options: GetMergedOptions(projectEndpoint, options)) + { + Argument.AssertNotNull(projectEndpoint, nameof(projectEndpoint)); + Argument.AssertNotNull(tokenProvider, nameof(tokenProvider)); + + _options = GetMergedOptions(projectEndpoint, options); + } + + public ProjectOpenAIClient(AuthenticationPolicy authenticationPolicy, ProjectOpenAIClientOptions options) + : base( + pipeline: CreatePipeline(authenticationPolicy, options), + options: options) + { + Argument.AssertNotNull(authenticationPolicy, nameof(authenticationPolicy)); + Argument.AssertNotNull(options, nameof(options)); + Argument.AssertNotNull(options.Endpoint, $"{nameof(options)}.{nameof(options.Endpoint)}"); + + _options = options; + } + + protected internal ProjectOpenAIClient(ClientPipeline pipeline, ProjectOpenAIClientOptions options) + : base(pipeline, options) + { + _options = options; + } + + protected ProjectOpenAIClient() + { } + + [EditorBrowsable(EditorBrowsableState.Never)] + public override ConversationClient GetConversationClient() + => GetProjectConversationsClient(); + + public virtual ProjectConversationsClient GetProjectConversationsClient() + { + return Volatile.Read(ref _cachedConversationClient) + ?? Interlocked.CompareExchange(ref _cachedConversationClient, new ProjectConversationsClient(Pipeline, _options), null) + ?? _cachedConversationClient; + } + + public virtual ProjectFilesClient GetProjectFilesClient() + { + return Volatile.Read(ref _cachedFileClient) + ?? Interlocked.CompareExchange(ref _cachedFileClient, new ProjectFilesClient(Pipeline, _options), null) + ?? _cachedFileClient; + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public override OpenAIFileClient GetOpenAIFileClient() => GetProjectFilesClient(); + + public virtual ProjectVectorStoresClient GetProjectVectorStoresClient() + { + return Volatile.Read(ref _cachedVectorStoreClient) + ?? Interlocked.CompareExchange(ref _cachedVectorStoreClient, new ProjectVectorStoresClient(Pipeline, _options), null) + ?? _cachedVectorStoreClient; + } + + public virtual ProjectResponsesClient GetProjectResponsesClient() + { + return Volatile.Read(ref _cachedResponseClient) + ?? Interlocked.CompareExchange(ref _cachedResponseClient, new ProjectResponsesClient(Pipeline, _options, defaultAgent: null, defaultConversationId: null), null) + ?? _cachedResponseClient; + } + + [EditorBrowsable(EditorBrowsableState.Never)] + public override OpenAIResponseClient GetOpenAIResponseClient(string defaultModel) + => GetProjectResponsesClientForModel(defaultModel); + + public virtual ProjectResponsesClient GetProjectResponsesClientForAgent(AgentReference defaultAgent, string defaultConversationId = null) + { + Argument.AssertNotNull(defaultAgent, nameof(defaultAgent)); + return new ProjectResponsesClient( + Pipeline, + _options, + defaultAgent, + defaultConversationId); + } + + public virtual ProjectResponsesClient GetProjectResponsesClientForModel(string defaultModel, string defaultConversationId = null) + { + Argument.AssertNotNullOrEmpty(defaultModel, nameof(defaultModel)); + return new ProjectResponsesClient( + Pipeline, + _options, + new AgentReference($"model:{defaultModel}"), + defaultConversationId); + } + + internal static ClientPipeline CreatePipeline(AuthenticationPolicy authenticationPolicy, ProjectOpenAIClientOptions options) + { + options ??= new ProjectOpenAIClientOptions(); + + TelemetryDetails telemetryDetails = new(typeof(ProjectOpenAIClient).Assembly, options?.UserAgentApplicationId); + + PipelinePolicyHelpers.AddQueryParameterPolicy(options, "api-version", options.ApiVersion); + PipelinePolicyHelpers.AddRequestHeaderPolicy(options, "User-Agent", telemetryDetails.UserAgent.ToString()); + PipelinePolicyHelpers.AddRequestHeaderPolicy(options, "x-ms-client-request-id", () => Guid.NewGuid().ToString().ToLowerInvariant()); + PipelinePolicyHelpers.OpenAI.AddResponseItemInputTransformPolicy(options); + PipelinePolicyHelpers.OpenAI.AddErrorTransformPolicy(options); + PipelinePolicyHelpers.OpenAI.AddAzureFinetuningParityPolicy(options); + + return ClientPipeline.Create(options, Array.Empty(), new PipelinePolicy[] { authenticationPolicy }, Array.Empty()); + } + + internal static AuthenticationPolicy CreateAuthenticationPolicy(AuthenticationTokenProvider tokenProvider, ProjectOpenAIClientOptions options = null) + { + // Future: allow custom scope/audience via options in this path + + return new BearerTokenPolicy(tokenProvider, s_defaultAuthorizationScope); + } + + internal static ProjectOpenAIClientOptions GetMergedOptions(Uri projectEndpoint, ProjectOpenAIClientOptions options = null) + { + if (projectEndpoint is null) + { + return options; + } + string rawTargetOpenAIEndpoint = projectEndpoint.AbsoluteUri.TrimEnd('/') + "/openai"; + if (options?.Endpoint is not null && options?.Endpoint?.AbsoluteUri != rawTargetOpenAIEndpoint) + { + throw new InvalidOperationException( + $"Cannot supply both a constructor '{nameof(projectEndpoint)}' and {nameof(options)}.{nameof(options.Endpoint)}."); + } + options ??= new(); + options?.Endpoint ??= new Uri(rawTargetOpenAIEndpoint); + return options; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectOpenAIClientOptions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectOpenAIClientOptions.cs new file mode 100644 index 000000000000..86b6479364de --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectOpenAIClientOptions.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using OpenAI; + +namespace Azure.AI.Projects.OpenAI; + +public partial class ProjectOpenAIClientOptions : OpenAIClientOptions +{ + private string _apiVersion; + + public string ApiVersion + { + get => _apiVersion; + set + { + AssertNotFrozen(); + _apiVersion = value; + } + } + + public ProjectOpenAIClientOptions() : base() + { + _apiVersion = "2025-11-15-preview"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectResponsesClient.RestClient.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectResponsesClient.RestClient.cs new file mode 100644 index 000000000000..c86cd3e369ea --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectResponsesClient.RestClient.cs @@ -0,0 +1,60 @@ +// 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.Threading; +using System.Threading.Tasks; +using OpenAI; +using OpenAI.Conversations; +using OpenAI.Responses; + +namespace Azure.AI.Projects.OpenAI; + +public partial class ProjectResponsesClient +{ + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + internal virtual PipelineMessage CreateGetProjectResponsesRequest(int? limit, string order, string after, string before, string agentName, string agentId, string conversationId, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(Endpoint); + uri.AppendPath("/responses", false); + if (limit != null) + { + uri.AppendQuery("limit", TypeFormatters.ConvertToString(limit), true); + } + if (order != null) + { + uri.AppendQuery("order", order, true); + } + if (after != null) + { + uri.AppendQuery("after", after, true); + } + if (before != null) + { + uri.AppendQuery("before", before, true); + } + if (!string.IsNullOrEmpty(agentName)) + { + uri.AppendQuery("agent_name", agentName, escape: true); + } + if (!string.IsNullOrEmpty(agentId)) + { + uri.AppendQuery("agent_id", agentId, escape: true); + } + if (!string.IsNullOrEmpty(conversationId)) + { + uri.AppendQuery("conversation_id", conversationId, escape: true); + } + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectResponsesClient.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectResponsesClient.cs new file mode 100644 index 000000000000..dbea44058987 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectResponsesClient.cs @@ -0,0 +1,223 @@ +// 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 System.Threading; +using System.Threading.Tasks; +using OpenAI; +using OpenAI.Responses; + +namespace Azure.AI.Projects.OpenAI; + +public partial class ProjectResponsesClient : OpenAIResponseClient +{ + private readonly string _defaultModelName; + private readonly string _defaultAgentName; + private readonly string _defaultAgentVersion; + private readonly string _defaultConversationId; + + /// + /// Creates a new instance of . + /// + /// + /// This constructor will automatically construct the base URI for requests from the supplied + /// value. To use a base URI directly, use the alternative constructor and set on the + /// options supplied. + /// + /// + /// + /// + public ProjectResponsesClient(Uri projectEndpoint, AuthenticationTokenProvider tokenProvider, ProjectResponsesClientOptions options = null) + : this(projectEndpoint, tokenProvider, defaultAgent: null, defaultConversationId: null, options) + { } + + /// + /// Creates a new instance of . + /// + /// + /// + /// + /// + /// + /// + /// + public ProjectResponsesClient(Uri projectEndpoint, AuthenticationTokenProvider tokenProvider, AgentReference defaultAgent, string defaultConversationId = null, ProjectResponsesClientOptions options = null) + : this( + pipeline: ProjectOpenAIClient.CreatePipeline( + ProjectOpenAIClient.CreateAuthenticationPolicy( + tokenProvider, + ProjectOpenAIClient.GetMergedOptions(projectEndpoint, options)), + ProjectOpenAIClient.GetMergedOptions(projectEndpoint, options)), + options: ProjectOpenAIClient.GetMergedOptions(projectEndpoint, options), + defaultAgent: defaultAgent, + defaultConversationId: defaultConversationId) + { } + + /// + /// Creates a new instance of . + /// + /// + /// This constructor will directly use the supplied value from the provided + /// and will perform no additional automatic resolution. + /// + /// + /// + public ProjectResponsesClient(AuthenticationTokenProvider tokenProvider, ProjectResponsesClientOptions options) + : this(projectEndpoint: null, tokenProvider, defaultAgent: null, defaultConversationId: null, options) + { } + + public ProjectResponsesClient(AuthenticationTokenProvider tokenProvider, ProjectResponsesClientOptions options = null, AgentReference defaultAgent = null, string defaultConversationId = null) + : this(projectEndpoint: null, tokenProvider, defaultAgent, defaultConversationId, options) + { } + + internal ProjectResponsesClient(ClientPipeline pipeline, OpenAIClientOptions options, AgentReference defaultAgent, string defaultConversationId) + : base(pipeline, model: "placeholder", options) + { + if (defaultAgent?.Name?.ToLowerInvariant()?.StartsWith("model:") == true) + { + _defaultModelName = defaultAgent.Name.Substring("model:".Length); + } + else if (defaultAgent is not null) + { + _defaultAgentName = defaultAgent.Name; + _defaultAgentVersion = defaultAgent.Version; + } + _defaultConversationId = defaultConversationId; + } + + protected ProjectResponsesClient() + { } + + public override ClientResult CreateResponse(string userInputText, ResponseCreationOptions options = null, CancellationToken cancellationToken = default) + { + options ??= new(); + ApplyClientDefaults(options); + return base.CreateResponse(userInputText, options, cancellationToken); + } + + public override ClientResult CreateResponse(IEnumerable inputItems, ResponseCreationOptions options = null, CancellationToken cancellationToken = default) + { + options ??= new(); + ApplyClientDefaults(options); + return base.CreateResponse(inputItems, options, cancellationToken); + } + + public override Task> CreateResponseAsync(IEnumerable inputItems, ResponseCreationOptions options = null, CancellationToken cancellationToken = default) + { + options ??= new(); + ApplyClientDefaults(options); + return base.CreateResponseAsync(inputItems, options, cancellationToken); + } + + public override Task> CreateResponseAsync(string userInputText, ResponseCreationOptions options = null, CancellationToken cancellationToken = default) + { + options ??= new(); + ApplyClientDefaults(options); + return base.CreateResponseAsync(userInputText, options, cancellationToken); + } + + public override CollectionResult CreateResponseStreaming(IEnumerable inputItems, ResponseCreationOptions options = null, CancellationToken cancellationToken = default) + { + options ??= new(); + ApplyClientDefaults(options); + return base.CreateResponseStreaming(inputItems, options, cancellationToken); + } + + public override CollectionResult CreateResponseStreaming(string userInputText, ResponseCreationOptions options = null, CancellationToken cancellationToken = default) + { + options ??= new(); + ApplyClientDefaults(options); + return base.CreateResponseStreaming(userInputText, options, cancellationToken); + } + + public override AsyncCollectionResult CreateResponseStreamingAsync(IEnumerable inputItems, ResponseCreationOptions options = null, CancellationToken cancellationToken = default) + { + options ??= new(); + ApplyClientDefaults(options); + return base.CreateResponseStreamingAsync(inputItems, options, cancellationToken); + } + + public override AsyncCollectionResult CreateResponseStreamingAsync(string userInputText, ResponseCreationOptions options = null, CancellationToken cancellationToken = default) + { + options ??= new(); + ApplyClientDefaults(options); + return base.CreateResponseStreamingAsync(userInputText, options, cancellationToken); + } + + public virtual CollectionResult GetProjectResponses(AgentReference agent = null, string conversationId = null, int? limit = default, string order = null, string after = default, string before = default, CancellationToken cancellationToken = default) + { + Dictionary extraQueryForProtocol = new() + { + ["agent_name"] = string.IsNullOrEmpty(agent?.Version) ? agent?.Name : null, + ["agent_id"] = string.IsNullOrEmpty(agent?.Version) ? null : $"{agent?.Name}:{agent?.Version}", + ["conversation_id"] = conversationId, + }; + + return new InternalOpenAICollectionResultOfT( + Pipeline, + messageGenerator: (localCollectionOptions, localRequestOptions) + => CreateGetProjectResponsesRequest( + localCollectionOptions.Limit, + localCollectionOptions.Order, + localCollectionOptions.AfterId, + localCollectionOptions.BeforeId, + agentName: localCollectionOptions.ExtraQueryMap["agent_name"], + agentId: localCollectionOptions.ExtraQueryMap["agent_id"], + conversationId: localCollectionOptions.ExtraQueryMap["conversation_id"], + localRequestOptions), + dataItemDeserializer: DeserializeOpenAIResponse, + new InternalOpenAICollectionResultOptions(limit, order?.ToString(), after, before, extraQueryMap: extraQueryForProtocol), + cancellationToken.ToRequestOptions()); + } + + public virtual AsyncCollectionResult GetProjectResponsesAsync(AgentReference agent = null, string conversationId = null, int? limit = default, string order = null, string after = default, string before = default, CancellationToken cancellationToken = default) + { + Dictionary extraQueryForProtocol = new() + { + ["agent_name"] = string.IsNullOrEmpty(agent?.Version) ? agent?.Name : null, + ["agent_id"] = string.IsNullOrEmpty(agent?.Version) ? null : $"{agent?.Name}:{agent?.Version}", + ["conversation_id"] = conversationId, + }; + + return new InternalOpenAIAsyncCollectionResultOfT( + Pipeline, + messageGenerator: (localCollectionOptions, localRequestOptions) + => CreateGetProjectResponsesRequest( + localCollectionOptions.Limit, + localCollectionOptions.Order, + localCollectionOptions.AfterId, + localCollectionOptions.BeforeId, + agentName: localCollectionOptions.ExtraQueryMap["agent_name"], + agentId: localCollectionOptions.ExtraQueryMap["agent_id"], + conversationId: localCollectionOptions.ExtraQueryMap["conversation_id"], + localRequestOptions), + dataItemDeserializer: DeserializeOpenAIResponse, + new InternalOpenAICollectionResultOptions(limit, order?.ToString(), after, before, extraQueryMap: extraQueryForProtocol), + cancellationToken.ToRequestOptions()); + } + + private void ApplyClientDefaults(ResponseCreationOptions options) + { + if (options.Agent is null && !string.IsNullOrEmpty(_defaultAgentName)) + { + options.Agent = new AgentReference(_defaultAgentName, _defaultAgentVersion); + } + options.AgentConversationId ??= _defaultConversationId; + if (options.Model is null) + { + options.Model = _defaultModelName ?? null; + } + } + + private static OpenAIResponse DeserializeOpenAIResponse(JsonElement element, ModelReaderWriterOptions options) + { + return ModelReaderWriter.Read( + BinaryData.FromString(element.GetRawText()), + options, + OpenAIContext.Default); + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectResponsesClientOptions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectResponsesClientOptions.cs new file mode 100644 index 000000000000..67d6a374dcd7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectResponsesClientOptions.cs @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Azure.AI.Projects.OpenAI; + +public partial class ProjectResponsesClientOptions : ProjectOpenAIClientOptions +{ +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectVectorStoresClient.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectVectorStoresClient.cs new file mode 100644 index 000000000000..35d056e61ef2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ProjectVectorStoresClient.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel.Primitives; +using OpenAI; +using OpenAI.VectorStores; + +namespace Azure.AI.Projects.OpenAI; + +public partial class ProjectVectorStoresClient : VectorStoreClient +{ + internal ProjectVectorStoresClient(ClientPipeline pipeline, OpenAIClientOptions options) + : base(pipeline, options) + { + } + + protected ProjectVectorStoresClient() + { } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ResponseCreationOptionsExtensions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ResponseCreationOptionsExtensions.cs new file mode 100644 index 000000000000..f99edb16e7a2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/ResponseCreationOptionsExtensions.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Text.Json.Nodes; +using Azure.AI.Projects.OpenAI; +using OpenAI.Responses; + +#pragma warning disable OPENAI001 +#pragma warning disable SCME0001 + +namespace Azure.AI.Projects.OpenAI; + +public static partial class ResponseCreationOptionsExtensions +{ + extension(ResponseCreationOptions options) + { + public string Model + { + get => options.Patch.GetStringEx("$.model"u8); + set => options.Patch.SetOrClearEx("$.model"u8, "$.model"u8, value); + } + + public AgentReference Agent + { + get => options.Patch.GetJsonModelEx("$.agent"u8); + set => options.Patch.SetOrClearEx("$.agent"u8, "$.agent"u8, value); + } + + public string AgentConversationId + { + get => options.Patch.GetStringEx("$.conversation.id"u8); + set => options.Patch.SetOrClearEx("$.conversation.id"u8, "$.conversation"u8, value); + } + + public ExtraDataDictionary StructuredInputs => new ExtraDataDictionary(options, "$.structured_inputs"u8); + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/StructuredInputDefinition.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/StructuredInputDefinition.cs new file mode 100644 index 000000000000..b2d962a101bf --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAI/StructuredInputDefinition.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using Azure.AI.Projects.OpenAI; + +namespace Azure.AI.Projects.OpenAI; + +[CodeGenType("StructuredInputDefinition")] +public partial class StructuredInputDefinition +{ + [CodeGenMember("Required")] + public bool? IsRequired { get; set; } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAIFileExtensions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAIFileExtensions.cs new file mode 100644 index 000000000000..4e2fe9a8876e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAIFileExtensions.cs @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel; +using System.IO; +using System.Text; +using System.Text.Json; +using OpenAI.Files; + +#pragma warning disable CS0618 + +namespace Azure.AI.Projects.OpenAI; + +public static partial class OpenAIFileExtensions +{ + public static string GetAzureFileStatus(this OpenAIFile file) + { + using BinaryContent contentBytes = BinaryContent.Create(file, ModelSerializationExtensions.WireOptions); + using var stream = new MemoryStream(); + contentBytes.WriteTo(stream); + string json = Encoding.UTF8.GetString(stream.ToArray()); + JsonDocument doc = JsonDocument.Parse(json); + if (doc.RootElement.TryGetProperty("_sdk_status", out JsonElement extraStatusElement)) + { + string extraStatusValue = extraStatusElement.GetString(); + if (!string.IsNullOrEmpty(extraStatusValue)) + { + return extraStatusValue; + } + } + return null; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAIResponseExtension.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAIResponseExtension.cs new file mode 100644 index 000000000000..26d84a6ac7f6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/OpenAIResponseExtension.cs @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; +using System.IO; +using System.Text; +using System.Text.Json.Nodes; +using System.Threading; +using System.Threading.Tasks; +using Azure.AI.Projects.OpenAI; +using OpenAI.Responses; + +namespace Azure.AI.Projects.OpenAI; + +public static partial class OpenAIResponseExtension +{ + public static ClientResult CreateResponse(this OpenAIResponseClient responseClient, ProjectConversation conversation, AgentReference agentRef, CancellationToken cancellationToken = default) + { + using BinaryContent content = RemoveItems(conversation: conversation, agentRef: agentRef); + ClientResult protocolResult = responseClient.CreateResponse( + content, + cancellationToken.ToRequestOptions() ?? new RequestOptions() + ); + OpenAIResponse convenienceValue = (OpenAIResponse)protocolResult; + return ClientResult.FromValue(convenienceValue, protocolResult.GetRawResponse()); + } + + public static async Task> CreateResponseAsync(this OpenAIResponseClient responseClient, ProjectConversation conversation, AgentReference agentRef, CancellationToken cancellationToken = default) + { + using BinaryContent content = RemoveItems(conversation: conversation, agentRef: agentRef); + ClientResult protocolResult = await responseClient.CreateResponseAsync( + content, + cancellationToken.ToRequestOptions() ?? new RequestOptions() + ).ConfigureAwait(false); + OpenAIResponse convenienceValue = (OpenAIResponse)protocolResult; + return ClientResult.FromValue(convenienceValue, protocolResult.GetRawResponse()); + } + + private static BinaryContent RemoveItems(ProjectConversation conversation, AgentReference agentRef) + { + ResponseCreationOptions responseOptions = new() + { + Agent = agentRef, + AgentConversationId = conversation.Id, + }; + using BinaryContent contentBytes = BinaryContent.Create(responseOptions, ModelSerializationExtensions.WireOptions); + using var stream = new MemoryStream(); + contentBytes.WriteTo(stream); + string json = Encoding.UTF8.GetString(stream.ToArray()); + JsonObject fixedOptions = new(); + JsonObject options = JsonObject.Parse(json).AsObject(); + options.Remove("input"); + return BinaryContent.CreateJson(options.ToJsonString()); + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/ProjectConversation.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/ProjectConversation.cs new file mode 100644 index 000000000000..92582fe7ea37 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/ProjectConversation.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Azure.AI.Projects.OpenAI; + +[CodeGenType("ConversationResource")] +public partial class ProjectConversation +{ + [CodeGenMember("Object")] + private string Object { get; } = "conversation"; + + public static implicit operator string(ProjectConversation conversation) => conversation.Id; +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/ProjectsOpenAIModelFactory.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/ProjectsOpenAIModelFactory.cs new file mode 100644 index 000000000000..1f3b0b868413 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/ProjectsOpenAIModelFactory.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +namespace Azure.AI.Projects.OpenAI; + +/// A factory class for creating instances of the models for mocking. +public static partial class ProjectsOpenAIModelFactory +{ +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/PromptAgentDefinition.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/PromptAgentDefinition.cs new file mode 100644 index 000000000000..60e4c9f4c22d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/PromptAgentDefinition.cs @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; +using OpenAI.Responses; + +namespace Azure.AI.Projects.OpenAI; + +[CodeGenType("PromptAgentDefinition")] +[CodeGenSerialization(nameof(Tools), DeserializationValueHook = nameof(DeserializeToolsValue))] +[CodeGenSerialization(propertyName: nameof(ReasoningOptions), SerializationName = "reasoning", DeserializationValueHook = nameof(DeserializeReasoningValue))] +[CodeGenSerialization(propertyName: nameof(TextOptions), SerializationName = "text", DeserializationValueHook = nameof(DeserializeTextValue))] +public partial class PromptAgentDefinition +{ + /// + /// An array of tools the model may call while generating a response. You + /// can specify which tool to use by setting the `tool_choice` parameter. + /// + [CodeGenMember("Tools")] + public IList Tools { get; } + + [CodeGenMember("Reasoning")] + public global::OpenAI.Responses.ResponseReasoningOptions ReasoningOptions { get; set; } + + [CodeGenMember("Text")] + public global::OpenAI.Responses.ResponseTextOptions TextOptions { get; set; } + + private static void DeserializeToolsValue(JsonProperty property, ref IList tools) + { + IList replacementTools = new ChangeTrackingList(); + + if (property.Value.ValueKind == JsonValueKind.Array) + { + foreach (JsonElement element in property.Value.EnumerateArray()) + { + ResponseTool tool = ModelReaderWriter.Read( + BinaryData.FromString(element.GetRawText()), + ModelReaderWriterOptions.Json, + OpenAIContext.Default); + replacementTools.Add(tool); + } + } + tools = replacementTools; + } + + /// Initializes a new instance of . + /// The model deployment to use for this agent. + /// is null. + public PromptAgentDefinition(string model) : base(AgentKind.Prompt) + { + Argument.AssertNotNull(model, nameof(model)); + + Model = model; + Tools = new ChangeTrackingList(); + StructuredInputs = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// + /// Configuration for Responsible AI (RAI) content filtering and safety features. + /// Keeps track of any properties unknown to the library. + /// The model deployment to use for this agent. + /// A system (or developer) message inserted into the model's context. + /// + /// 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. + /// We generally recommend altering this or `top_p` but not both. + /// + /// + /// 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. + /// + /// + /// + /// An array of tools the model may call while generating a response. You + /// can specify which tool to use by setting the `tool_choice` parameter. + /// + /// Configuration options for a text response from the model. Can be plain text or structured JSON data. + /// Set of structured inputs that can participate in prompt template substitution or tool argument bindings. + internal PromptAgentDefinition(AgentKind kind, ContentFilterConfiguration contentFilterConfiguration, IDictionary additionalBinaryDataProperties, string model, string instructions, float? temperature, float? topP, ResponseReasoningOptions reasoningOptions, IList tools, ResponseTextOptions textOptions, IDictionary structuredInputs) : base(kind, contentFilterConfiguration, additionalBinaryDataProperties) + { + Model = model; + Instructions = instructions; + Temperature = temperature; + TopP = topP; + ReasoningOptions = reasoningOptions; + Tools = tools; + TextOptions = textOptions; + StructuredInputs = structuredInputs; + } + + private static void DeserializeReasoningValue(JsonProperty property, ref ResponseReasoningOptions reasoningOptions) + { + if (property.Value.ValueKind == JsonValueKind.Object) + { + reasoningOptions = ModelReaderWriter.Read( + BinaryData.FromString(property.Value.GetRawText()), + ModelReaderWriterOptions.Json, + OpenAIContext.Default); + } + } + + private static void DeserializeTextValue(JsonProperty property, ref ResponseTextOptions textOptions) + { + if (property.Value.ValueKind == JsonValueKind.Object) + { + textOptions = ModelReaderWriter.Read( + BinaryData.FromString(property.Value.GetRawText()), + ModelReaderWriterOptions.Json, + OpenAIContext.Default); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/ResponseItemExtensions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/ResponseItemExtensions.cs new file mode 100644 index 000000000000..ff5467c41471 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/ResponseItemExtensions.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.ClientModel.Primitives; +using OpenAI.Responses; + +namespace Azure.AI.Projects.OpenAI; + +#pragma warning disable OPENAI001 + +public static partial class ResponseItemExtensions +{ + public static AgentResponseItem AsAgentResponseItem(this ResponseItem responseItem) + { + BinaryData serializedResponseItem = ModelReaderWriter.Write(responseItem, ModelSerializationExtensions.WireOptions, AzureAIProjectsOpenAIContext.Default); + return ModelReaderWriter.Read(serializedResponseItem, ModelSerializationExtensions.WireOptions, AzureAIProjectsOpenAIContext.Default); + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/ResponseToolExtensions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/ResponseToolExtensions.cs new file mode 100644 index 000000000000..c77c1d85c86b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/ResponseToolExtensions.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel.Primitives; +using OpenAI; +using OpenAI.Responses; + +namespace Azure.AI.Projects.OpenAI; + +public static partial class ResponseToolExtensions +{ + public static AgentTool AsAgentTool(this ResponseTool responseTool) + { + return ModelReaderWriter.Read( + ModelReaderWriter.Write(responseTool, ModelSerializationExtensions.WireOptions, OpenAIContext.Default), + ModelSerializationExtensions.WireOptions, + AzureAIProjectsOpenAIContext.Default); + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Responses.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Responses.cs new file mode 100644 index 000000000000..c76b0a682f72 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/Responses.cs @@ -0,0 +1,272 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +//using System; +//using System.Linq; +//using System.Collections.Generic; +//using System.Threading; +//using System.Threading.Tasks; +//using Azure.AI.Projects.OpenAI.Models; + +//namespace Azure.AI.Projects.OpenAI; + +//public partial class Responses +//{ +// /// Creates a model response. +// /// +// /// 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, and querying for objects via API or the dashboard. +// /// +// /// Keys are strings with a maximum length of 64 characters. Values are strings +// /// with a maximum length of 512 characters. +// /// +// /// +// /// 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. +// /// We generally recommend altering this or `top_p` but not both. +// /// +// /// +// /// 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. +// /// +// /// A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). +// /// An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. +// /// +// /// The unique ID of the previous response to the model. Use this to +// /// create multi-turn conversations. Learn more about +// /// [conversation state](/docs/guides/conversation-state). +// /// +// /// +// /// +// /// Whether to run the model response in the background. +// /// [Learn more](/docs/guides/background). +// /// +// /// An upper bound for the number of tokens that can be generated for a response, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). +// /// The maximum number of total calls to built-in tools that can be processed in a response. This maximum number applies across all built-in tool calls, not per individual tool. Any further attempts to call a tool by the model will be ignored. +// /// +// /// Configuration options for a text response from the model. Can be plain +// /// text or structured JSON data. Learn more: +// /// - [Text inputs and outputs](/docs/guides/text) +// /// - [Structured Outputs](/docs/guides/structured-outputs) +// /// +// /// +// /// How the model should select which tool (or tools) to use when generating +// /// a response. See the `tools` parameter to see how to specify which tools +// /// the model can call. +// /// +// /// +// /// +// /// The truncation strategy to use for the model response. +// /// - `auto`: If the context of this response and previous ones exceeds +// /// the model's context window size, the model will truncate the +// /// response to fit the context window by dropping input items in the +// /// middle of the conversation. +// /// - `disabled` (default): If a model response will exceed the context window +// /// size for a model, the request will fail with a 400 error. +// /// +// /// +// /// Specify additional output data to include in the model response. Currently +// /// supported values are: +// /// - `code_interpreter_call.outputs`: Includes the outputs of python code execution +// /// in code interpreter tool call items. +// /// - `computer_call_output.output.image_url`: Include image urls from the computer call output. +// /// - `file_search_call.results`: Include the search results of +// /// the file search tool call. +// /// - `message.input_image.image_url`: Include image urls from the input message. +// /// - `message.output_text.logprobs`: Include logprobs with assistant messages. +// /// - `reasoning.encrypted_content`: Includes an encrypted version of reasoning +// /// tokens in reasoning item outputs. This enables reasoning items to be used in +// /// multi-turn conversations when using the Responses API statelessly (like +// /// when the `store` parameter is set to `false`, or when an organization is +// /// enrolled in the zero data retention program). +// /// +// /// Whether to allow the model to run tool calls in parallel. +// /// +// /// Whether to store the generated model response for later retrieval via +// /// API. +// /// +// /// +// /// A system (or developer) message inserted into the model's context. +// /// +// /// When using along with `previous_response_id`, the instructions from a previous +// /// response will not be carried over to the next response. This makes it simple +// /// to swap out system (or developer) messages in new responses. +// /// +// /// +// /// If set to true, the model response data will be streamed to the client +// /// as it is generated using [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format). +// /// See the [Streaming section below](/docs/api-reference/responses-streaming) +// /// for more information. +// /// +// /// +// /// The model deployment to use for the creation of this response. +// /// The agent to use for generating the response. +// /// +// /// +// /// The cancellation token that can be used to cancel the operation. +// /// Service returned a non-success status code. +// internal virtual Response CreateResponse(IDictionary metadata = default, float? temperature = default, float? topP = default, string user = default, int? topLogprobs = default, string previousResponseId = default, Reasoning reasoning = default, bool? background = default, int? maxOutputTokens = default, int? maxToolCalls = default, CreateResponseRequestText text = default, BinaryData toolChoice = default, Prompt prompt = default, CreateResponseRequestTruncation? truncation = default, IEnumerable include = default, bool? parallelToolCalls = default, bool? store = default, string instructions = default, bool? stream = default, BinaryData conversation = default, string model = default, AgentReference agent = default, BinaryData input = default, IEnumerable tools = default, CancellationToken cancellationToken = default) +// { +// CreateResponseRequest spreadModel = new CreateResponseRequest( +// ((IReadOnlyDictionary)metadata) ?? new Dictionary(), +// temperature, +// null, +// user, +// null, +// null, +// reasoning, +// background, +// null, +// null, +// text, +// null, +// prompt, +// truncation, +// include?.ToList() as IList ?? new ChangeTrackingList(), +// null, +// store, +// instructions, +// stream, +// conversation, +// model, +// agent, +// input, +// tools?.ToList() as IList ?? new ChangeTrackingList(), +// null); +// Response result = CreateResponse(spreadModel, cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null); +// return Response.FromValue((AgentResponse)result, result); +// } + +// /// Creates a model response. +// /// +// /// 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, and querying for objects via API or the dashboard. +// /// +// /// Keys are strings with a maximum length of 64 characters. Values are strings +// /// with a maximum length of 512 characters. +// /// +// /// +// /// 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. +// /// We generally recommend altering this or `top_p` but not both. +// /// +// /// +// /// 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. +// /// +// /// A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids). +// /// An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. +// /// +// /// The unique ID of the previous response to the model. Use this to +// /// create multi-turn conversations. Learn more about +// /// [conversation state](/docs/guides/conversation-state). +// /// +// /// +// /// +// /// Whether to run the model response in the background. +// /// [Learn more](/docs/guides/background). +// /// +// /// An upper bound for the number of tokens that can be generated for a response, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). +// /// The maximum number of total calls to built-in tools that can be processed in a response. This maximum number applies across all built-in tool calls, not per individual tool. Any further attempts to call a tool by the model will be ignored. +// /// +// /// Configuration options for a text response from the model. Can be plain +// /// text or structured JSON data. Learn more: +// /// - [Text inputs and outputs](/docs/guides/text) +// /// - [Structured Outputs](/docs/guides/structured-outputs) +// /// +// /// +// /// How the model should select which tool (or tools) to use when generating +// /// a response. See the `tools` parameter to see how to specify which tools +// /// the model can call. +// /// +// /// +// /// +// /// The truncation strategy to use for the model response. +// /// - `auto`: If the context of this response and previous ones exceeds +// /// the model's context window size, the model will truncate the +// /// response to fit the context window by dropping input items in the +// /// middle of the conversation. +// /// - `disabled` (default): If a model response will exceed the context window +// /// size for a model, the request will fail with a 400 error. +// /// +// /// +// /// Specify additional output data to include in the model response. Currently +// /// supported values are: +// /// - `code_interpreter_call.outputs`: Includes the outputs of python code execution +// /// in code interpreter tool call items. +// /// - `computer_call_output.output.image_url`: Include image urls from the computer call output. +// /// - `file_search_call.results`: Include the search results of +// /// the file search tool call. +// /// - `message.input_image.image_url`: Include image urls from the input message. +// /// - `message.output_text.logprobs`: Include logprobs with assistant messages. +// /// - `reasoning.encrypted_content`: Includes an encrypted version of reasoning +// /// tokens in reasoning item outputs. This enables reasoning items to be used in +// /// multi-turn conversations when using the Responses API statelessly (like +// /// when the `store` parameter is set to `false`, or when an organization is +// /// enrolled in the zero data retention program). +// /// +// /// Whether to allow the model to run tool calls in parallel. +// /// +// /// Whether to store the generated model response for later retrieval via +// /// API. +// /// +// /// +// /// A system (or developer) message inserted into the model's context. +// /// +// /// When using along with `previous_response_id`, the instructions from a previous +// /// response will not be carried over to the next response. This makes it simple +// /// to swap out system (or developer) messages in new responses. +// /// +// /// +// /// If set to true, the model response data will be streamed to the client +// /// as it is generated using [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format). +// /// See the [Streaming section below](/docs/api-reference/responses-streaming) +// /// for more information. +// /// +// /// +// /// The model deployment to use for the creation of this response. +// /// The agent to use for generating the response. +// /// +// /// +// /// The cancellation token that can be used to cancel the operation. +// /// Service returned a non-success status code. +// public virtual async Task> CreateResponseAsync(IDictionary metadata = default, float? temperature = default, float? topP = default, string user = default, int? topLogprobs = default, string previousResponseId = default, Reasoning reasoning = default, bool? background = default, int? maxOutputTokens = default, int? maxToolCalls = default, CreateResponseRequestText text = default, BinaryData toolChoice = default, Prompt prompt = default, CreateResponseRequestTruncation? truncation = default, IEnumerable include = default, bool? parallelToolCalls = default, bool? store = default, string instructions = default, bool? stream = default, BinaryData conversation = default, string model = default, AgentReference agent = default, BinaryData input = default, IEnumerable tools = default, CancellationToken cancellationToken = default) +// { +// CreateResponseRequest spreadModel = new CreateResponseRequest( +// ((IReadOnlyDictionary)metadata) ?? new Dictionary(), +// temperature, +// null, +// user, +// null, +// null, +// reasoning, +// background, +// null, +// null, +// text, +// null, +// prompt, +// truncation, +// include?.ToList() as IList ?? new ChangeTrackingList(), +// null, +// store, +// instructions, +// stream, +// conversation, +// model, +// agent, +// input, +// tools?.ToList() as IList ?? new ChangeTrackingList(), +// null); +// Response result = await CreateResponseAsync(spreadModel, cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null).ConfigureAwait(false); +// return Response.FromValue((AgentResponse)result, result); +// } +//} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/WorkflowAgentDefinition.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/WorkflowAgentDefinition.cs new file mode 100644 index 000000000000..df660d544615 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Custom/WorkflowAgentDefinition.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +namespace Azure.AI.Projects.OpenAI; + +[CodeGenType("WorkflowDefinition")] +public partial class WorkflowAgentDefinition +{ + /// Initializes a new instance of . + internal WorkflowAgentDefinition() : base(AgentKind.Workflow) + { + } + + public static WorkflowAgentDefinition FromYaml(string workflowYamlDocument) + { + return new() + { + WorkflowYaml = workflowYamlDocument, + }; + } + + [CodeGenMember("Workflow")] + private string WorkflowYaml { get; set; } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/A2ATool.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/A2ATool.Serialization.cs new file mode 100644 index 000000000000..9f7fe1c9f8d9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/A2ATool.Serialization.cs @@ -0,0 +1,156 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// An agent implementing the A2A protocol. + public partial class A2ATool : AgentTool, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(A2ATool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(BaseUri)) + { + writer.WritePropertyName("base_url"u8); + writer.WriteStringValue(BaseUri.AbsoluteUri); + } + if (Optional.IsDefined(AgentCardPath)) + { + writer.WritePropertyName("agent_card_path"u8); + writer.WriteStringValue(AgentCardPath); + } + if (Optional.IsDefined(ProjectConnectionId)) + { + writer.WritePropertyName("project_connection_id"u8); + writer.WriteStringValue(ProjectConnectionId); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + A2ATool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (A2ATool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(A2ATool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeA2ATool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static A2ATool DeserializeA2ATool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + Uri baseUri = default; + string agentCardPath = default; + string projectConnectionId = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("base_url"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + baseUri = new Uri(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("agent_card_path"u8)) + { + agentCardPath = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("project_connection_id"u8)) + { + projectConnectionId = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new A2ATool(@type, additionalBinaryDataProperties, baseUri, agentCardPath, projectConnectionId); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(A2ATool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + A2ATool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (A2ATool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeA2ATool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(A2ATool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/A2ATool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/A2ATool.cs new file mode 100644 index 000000000000..caa86bc5fc4b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/A2ATool.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// An agent implementing the A2A protocol. + public partial class A2ATool : AgentTool + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// Base URL of the agent. + /// + /// The path to the agent card relative to the `base_url`. + /// If not provided, defaults to `/.well-known/agent-card.json` + /// + /// + /// The connection ID in the project for the A2A server. + /// The connection stores authentication and other connection details needed to connect to the A2A server. + /// + internal A2ATool(ToolType @type, IDictionary additionalBinaryDataProperties, Uri baseUri, string agentCardPath, string projectConnectionId) : base(@type, additionalBinaryDataProperties) + { + BaseUri = baseUri; + AgentCardPath = agentCardPath; + ProjectConnectionId = projectConnectionId; + } + + /// + /// The path to the agent card relative to the `base_url`. + /// If not provided, defaults to `/.well-known/agent-card.json` + /// + public string AgentCardPath { get; set; } + + /// + /// The connection ID in the project for the A2A server. + /// The connection stores authentication and other connection details needed to connect to the A2A server. + /// + public string ProjectConnectionId { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentCommunicationMethod.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentCommunicationMethod.cs new file mode 100644 index 000000000000..45b82ac10618 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentCommunicationMethod.cs @@ -0,0 +1,65 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects.OpenAI +{ + /// + public readonly partial struct AgentCommunicationMethod : IEquatable + { + private readonly string _value; + private const string ActivityProtocolValue = "activity_protocol"; + private const string ResponsesValue = "responses"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public AgentCommunicationMethod(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the ActivityProtocol. + public static AgentCommunicationMethod ActivityProtocol { get; } = new AgentCommunicationMethod(ActivityProtocolValue); + + /// Gets the Responses. + public static AgentCommunicationMethod Responses { get; } = new AgentCommunicationMethod(ResponsesValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(AgentCommunicationMethod left, AgentCommunicationMethod right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(AgentCommunicationMethod left, AgentCommunicationMethod right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator AgentCommunicationMethod(string value) => new AgentCommunicationMethod(value); + + /// Converts a string to a . + /// The value. + public static implicit operator AgentCommunicationMethod?(string value) => value == null ? null : new AgentCommunicationMethod(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AgentCommunicationMethod other && Equals(other); + + /// + public bool Equals(AgentCommunicationMethod other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentDefinition.Serialization.cs new file mode 100644 index 000000000000..790511833612 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentDefinition.Serialization.cs @@ -0,0 +1,147 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// + /// The AgentDefinition. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , and . + /// + [PersistableModelProxy(typeof(UnknownAgentDefinition))] + public abstract partial class AgentDefinition : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AgentDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentDefinition)} does not support writing '{format}' format."); + } + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind.ToString()); + if (Optional.IsDefined(ContentFilterConfiguration)) + { + writer.WritePropertyName("rai_config"u8); + writer.WriteObjectValue(ContentFilterConfiguration, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AgentDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AgentDefinition DeserializeAgentDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("kind"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "workflow": + return WorkflowAgentDefinition.DeserializeWorkflowAgentDefinition(element, options); + case "hosted": + return HostedAgentDefinition.DeserializeHostedAgentDefinition(element, options); + case "container_app": + return ContainerApplicationAgentDefinition.DeserializeContainerApplicationAgentDefinition(element, options); + case "prompt": + return PromptAgentDefinition.DeserializePromptAgentDefinition(element, options); + } + } + return UnknownAgentDefinition.DeserializeUnknownAgentDefinition(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(AgentDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AgentDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AgentDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentDefinition.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentDefinition.cs new file mode 100644 index 000000000000..590d66d8e990 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentDefinition.cs @@ -0,0 +1,40 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// + /// The AgentDefinition. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , and . + /// + public abstract partial class AgentDefinition + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + private protected AgentDefinition(AgentKind kind) + { + Kind = kind; + } + + /// Initializes a new instance of . + /// + /// Configuration for Responsible AI (RAI) content filtering and safety features. + /// Keeps track of any properties unknown to the library. + internal AgentDefinition(AgentKind kind, ContentFilterConfiguration contentFilterConfiguration, IDictionary additionalBinaryDataProperties) + { + Kind = kind; + ContentFilterConfiguration = contentFilterConfiguration; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Kind. + internal AgentKind Kind { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentInfo.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentInfo.Serialization.cs new file mode 100644 index 000000000000..5d089c719cf9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentInfo.Serialization.cs @@ -0,0 +1,155 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The AgentInfo. + public partial class AgentInfo : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AgentInfo() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentInfo)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AgentInfo JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentInfo)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentInfo(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AgentInfo DeserializeAgentInfo(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = default; + string name = default; + string version = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("version"u8)) + { + version = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AgentInfo(@type, name, version, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(AgentInfo)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AgentInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AgentInfo PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentInfo)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentInfo.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentInfo.cs new file mode 100644 index 000000000000..7acbea84e7e1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentInfo.cs @@ -0,0 +1,47 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// The AgentInfo. + public partial class AgentInfo + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The name of the agent. + /// The version identifier of the agent. + internal AgentInfo(string name, string version) + { + Name = name; + Version = version; + } + + /// Initializes a new instance of . + /// + /// The name of the agent. + /// The version identifier of the agent. + /// Keeps track of any properties unknown to the library. + internal AgentInfo(string @type, string name, string version, IDictionary additionalBinaryDataProperties) + { + Type = @type; + Name = name; + Version = version; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Type. + public string Type { get; } = "agent_id"; + + /// The name of the agent. + public string Name { get; } + + /// The version identifier of the agent. + public string Version { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentKind.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentKind.cs new file mode 100644 index 000000000000..eb45710ccbc5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentKind.cs @@ -0,0 +1,73 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects.OpenAI +{ + /// + internal readonly partial struct AgentKind : IEquatable + { + private readonly string _value; + private const string PromptValue = "prompt"; + private const string HostedValue = "hosted"; + private const string ContainerAppValue = "container_app"; + private const string WorkflowValue = "workflow"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public AgentKind(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Prompt. + public static AgentKind Prompt { get; } = new AgentKind(PromptValue); + + /// Gets the Hosted. + public static AgentKind Hosted { get; } = new AgentKind(HostedValue); + + /// Gets the ContainerApp. + public static AgentKind ContainerApp { get; } = new AgentKind(ContainerAppValue); + + /// Gets the Workflow. + public static AgentKind Workflow { get; } = new AgentKind(WorkflowValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(AgentKind left, AgentKind right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(AgentKind left, AgentKind right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator AgentKind(string value) => new AgentKind(value); + + /// Converts a string to a . + /// The value. + public static implicit operator AgentKind?(string value) => value == null ? null : new AgentKind(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AgentKind other && Equals(other); + + /// + public bool Equals(AgentKind other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentObjectVersions.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentObjectVersions.Serialization.cs new file mode 100644 index 000000000000..c26dd65d65bd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentObjectVersions.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The AgentObjectVersions. + public partial class AgentObjectVersions : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AgentObjectVersions() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentObjectVersions)} does not support writing '{format}' format."); + } + writer.WritePropertyName("latest"u8); + writer.WriteObjectValue(Latest, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentObjectVersions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AgentObjectVersions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentObjectVersions)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentObjectVersions(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AgentObjectVersions DeserializeAgentObjectVersions(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentVersion latest = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("latest"u8)) + { + latest = AgentVersion.DeserializeAgentVersion(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AgentObjectVersions(latest, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(AgentObjectVersions)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AgentObjectVersions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AgentObjectVersions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentObjectVersions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentObjectVersions)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentObjectVersions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentObjectVersions.cs new file mode 100644 index 000000000000..5717168a1e20 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentObjectVersions.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// The AgentObjectVersions. + public partial class AgentObjectVersions + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + internal AgentObjectVersions(AgentVersion latest) + { + Latest = latest; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal AgentObjectVersions(AgentVersion latest, IDictionary additionalBinaryDataProperties) + { + Latest = latest; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Latest. + public AgentVersion Latest { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentRecord.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentRecord.Serialization.cs new file mode 100644 index 000000000000..37416dc90f6f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentRecord.Serialization.cs @@ -0,0 +1,163 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The AgentRecord. + public partial class AgentRecord : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AgentRecord() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentRecord)} does not support writing '{format}' format."); + } + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("versions"u8); + writer.WriteObjectValue(Versions, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentRecord IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AgentRecord JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentRecord)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentRecord(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AgentRecord DeserializeAgentRecord(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @object = default; + string id = default; + string name = default; + AgentObjectVersions versions = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("object"u8)) + { + @object = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("versions"u8)) + { + versions = AgentObjectVersions.DeserializeAgentObjectVersions(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AgentRecord(@object, id, name, versions, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(AgentRecord)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AgentRecord IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AgentRecord PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentRecord(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentRecord)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentRecord.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentRecord.cs new file mode 100644 index 000000000000..93930dbb272e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentRecord.cs @@ -0,0 +1,51 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// The AgentRecord. + public partial class AgentRecord + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The unique identifier of the agent. + /// The name of the agent. + /// The latest version of the agent. + internal AgentRecord(string id, string name, AgentObjectVersions versions) + { + Id = id; + Name = name; + Versions = versions; + } + + /// Initializes a new instance of . + /// The object type, which is always 'agent'. + /// The unique identifier of the agent. + /// The name of the agent. + /// The latest version of the agent. + /// Keeps track of any properties unknown to the library. + internal AgentRecord(string @object, string id, string name, AgentObjectVersions versions, IDictionary additionalBinaryDataProperties) + { + Object = @object; + Id = id; + Name = name; + Versions = versions; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The unique identifier of the agent. + public string Id { get; } + + /// The name of the agent. + public string Name { get; } + + /// The latest version of the agent. + public AgentObjectVersions Versions { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentReference.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentReference.Serialization.cs new file mode 100644 index 000000000000..aa26a60a67d0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentReference.Serialization.cs @@ -0,0 +1,158 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The AgentReference. + public partial class AgentReference : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AgentReference() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentReference)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsDefined(Version)) + { + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentReference IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AgentReference JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentReference)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentReference(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AgentReference DeserializeAgentReference(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = default; + string name = default; + string version = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("version"u8)) + { + version = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AgentReference(@type, name, version, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(AgentReference)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AgentReference IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AgentReference PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentReference(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentReference)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentReference.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentReference.cs new file mode 100644 index 000000000000..7027f1102b00 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentReference.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// The AgentReference. + public partial class AgentReference + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// The name of the agent. + /// The version identifier of the agent. + /// Keeps track of any properties unknown to the library. + internal AgentReference(string @type, string name, string version, IDictionary additionalBinaryDataProperties) + { + Type = @type; + Name = name; + Version = version; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Type. + internal string Type { get; } = "agent_reference"; + + /// The name of the agent. + public string Name { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentResponseItem.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentResponseItem.Serialization.cs new file mode 100644 index 000000000000..5ace788846b3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentResponseItem.Serialization.cs @@ -0,0 +1,182 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// + /// Content item used to generate a response. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , , , and . + /// + [PersistableModelProxy(typeof(UnknownItemResource))] + public abstract partial class AgentResponseItem : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AgentResponseItem() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentResponseItem)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + if (Optional.IsDefined(CreatedBy)) + { + writer.WritePropertyName("created_by"u8); + writer.WriteObjectValue(CreatedBy, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentResponseItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentResponseItem)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentResponseItem(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AgentResponseItem DeserializeAgentResponseItem(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "structured_outputs": + return AgentStructuredOutputsResponseItem.DeserializeAgentStructuredOutputsResponseItem(element, options); + case "workflow_action": + return AgentWorkflowActionResponseItem.DeserializeAgentWorkflowActionResponseItem(element, options); + case "oauth_consent_request": + return OAuthConsentRequestResponseItem.DeserializeOAuthConsentRequestResponseItem(element, options); + case "message": + return InternalResponsesMessageItemResource.DeserializeInternalResponsesMessageItemResource(element, options); + case "computer_call_output": + return InternalComputerToolCallOutputItemResource.DeserializeInternalComputerToolCallOutputItemResource(element, options); + case "function_call": + return InternalFunctionToolCallItemResource.DeserializeInternalFunctionToolCallItemResource(element, options); + case "function_call_output": + return InternalFunctionToolCallOutputItemResource.DeserializeInternalFunctionToolCallOutputItemResource(element, options); + case "mcp_approval_response": + return InternalMCPApprovalResponseItemResource.DeserializeInternalMCPApprovalResponseItemResource(element, options); + case "file_search_call": + return InternalFileSearchToolCallItemResource.DeserializeInternalFileSearchToolCallItemResource(element, options); + case "computer_call": + return InternalComputerToolCallItemResource.DeserializeInternalComputerToolCallItemResource(element, options); + case "web_search_call": + return InternalWebSearchToolCallItemResource.DeserializeInternalWebSearchToolCallItemResource(element, options); + case "reasoning": + return InternalReasoningItemResource.DeserializeInternalReasoningItemResource(element, options); + case "image_generation_call": + return InternalImageGenToolCallItemResource.DeserializeInternalImageGenToolCallItemResource(element, options); + case "code_interpreter_call": + return InternalCodeInterpreterToolCallItemResource.DeserializeInternalCodeInterpreterToolCallItemResource(element, options); + case "local_shell_call": + return LocalShellToolCallAgentResponseItem.DeserializeLocalShellToolCallAgentResponseItem(element, options); + case "local_shell_call_output": + return LocalShellToolCallOutputAgentResponseItem.DeserializeLocalShellToolCallOutputAgentResponseItem(element, options); + case "mcp_list_tools": + return InternalMCPListToolsItemResource.DeserializeInternalMCPListToolsItemResource(element, options); + case "mcp_approval_request": + return InternalMCPApprovalRequestItemResource.DeserializeInternalMCPApprovalRequestItemResource(element, options); + case "mcp_call": + return InternalMCPCallItemResource.DeserializeInternalMCPCallItemResource(element, options); + case "memory_search_call": + return MemorySearchToolCallResponseItem.DeserializeMemorySearchToolCallResponseItem(element, options); + } + } + return UnknownItemResource.DeserializeUnknownItemResource(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(AgentResponseItem)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AgentResponseItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentResponseItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentResponseItem)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentResponseItem.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentResponseItem.cs new file mode 100644 index 000000000000..544b37e5c499 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentResponseItem.cs @@ -0,0 +1,50 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// + /// Content item used to generate a response. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , , , and . + /// + public abstract partial class AgentResponseItem + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// + private protected AgentResponseItem(AgentResponseItemKind @type, string id) + { + Type = @type; + Id = id; + } + + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + internal AgentResponseItem(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties) + { + Type = @type; + Id = id; + CreatedBy = createdBy; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Type. + internal AgentResponseItemKind Type { get; set; } + + /// Gets the Id. + public virtual string Id { get; } + + /// The information about the creator of the item. + public AgentResponseItemSource CreatedBy { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentResponseItemKind.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentResponseItemKind.cs new file mode 100644 index 000000000000..17a5aea5d47d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentResponseItemKind.cs @@ -0,0 +1,141 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects.OpenAI +{ + /// + public readonly partial struct AgentResponseItemKind : IEquatable + { + private readonly string _value; + private const string MessageValue = "message"; + private const string FileSearchCallValue = "file_search_call"; + private const string FunctionCallValue = "function_call"; + private const string FunctionCallOutputValue = "function_call_output"; + private const string ComputerCallValue = "computer_call"; + private const string ComputerCallOutputValue = "computer_call_output"; + private const string WebSearchCallValue = "web_search_call"; + private const string ReasoningValue = "reasoning"; + private const string ItemReferenceValue = "item_reference"; + private const string ImageGenerationCallValue = "image_generation_call"; + private const string CodeInterpreterCallValue = "code_interpreter_call"; + private const string LocalShellCallValue = "local_shell_call"; + private const string LocalShellCallOutputValue = "local_shell_call_output"; + private const string McpListToolsValue = "mcp_list_tools"; + private const string McpApprovalRequestValue = "mcp_approval_request"; + private const string McpApprovalResponseValue = "mcp_approval_response"; + private const string McpCallValue = "mcp_call"; + private const string StructuredOutputsValue = "structured_outputs"; + private const string WorkflowActionValue = "workflow_action"; + private const string MemorySearchCallValue = "memory_search_call"; + private const string OauthConsentRequestValue = "oauth_consent_request"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public AgentResponseItemKind(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Message. + public static AgentResponseItemKind Message { get; } = new AgentResponseItemKind(MessageValue); + + /// Gets the FileSearchCall. + public static AgentResponseItemKind FileSearchCall { get; } = new AgentResponseItemKind(FileSearchCallValue); + + /// Gets the FunctionCall. + public static AgentResponseItemKind FunctionCall { get; } = new AgentResponseItemKind(FunctionCallValue); + + /// Gets the FunctionCallOutput. + public static AgentResponseItemKind FunctionCallOutput { get; } = new AgentResponseItemKind(FunctionCallOutputValue); + + /// Gets the ComputerCall. + public static AgentResponseItemKind ComputerCall { get; } = new AgentResponseItemKind(ComputerCallValue); + + /// Gets the ComputerCallOutput. + public static AgentResponseItemKind ComputerCallOutput { get; } = new AgentResponseItemKind(ComputerCallOutputValue); + + /// Gets the WebSearchCall. + public static AgentResponseItemKind WebSearchCall { get; } = new AgentResponseItemKind(WebSearchCallValue); + + /// Gets the Reasoning. + public static AgentResponseItemKind Reasoning { get; } = new AgentResponseItemKind(ReasoningValue); + + /// Gets the ItemReference. + public static AgentResponseItemKind ItemReference { get; } = new AgentResponseItemKind(ItemReferenceValue); + + /// Gets the ImageGenerationCall. + public static AgentResponseItemKind ImageGenerationCall { get; } = new AgentResponseItemKind(ImageGenerationCallValue); + + /// Gets the CodeInterpreterCall. + public static AgentResponseItemKind CodeInterpreterCall { get; } = new AgentResponseItemKind(CodeInterpreterCallValue); + + /// Gets the LocalShellCall. + public static AgentResponseItemKind LocalShellCall { get; } = new AgentResponseItemKind(LocalShellCallValue); + + /// Gets the LocalShellCallOutput. + public static AgentResponseItemKind LocalShellCallOutput { get; } = new AgentResponseItemKind(LocalShellCallOutputValue); + + /// Gets the McpListTools. + public static AgentResponseItemKind McpListTools { get; } = new AgentResponseItemKind(McpListToolsValue); + + /// Gets the McpApprovalRequest. + public static AgentResponseItemKind McpApprovalRequest { get; } = new AgentResponseItemKind(McpApprovalRequestValue); + + /// Gets the McpApprovalResponse. + public static AgentResponseItemKind McpApprovalResponse { get; } = new AgentResponseItemKind(McpApprovalResponseValue); + + /// Gets the McpCall. + public static AgentResponseItemKind McpCall { get; } = new AgentResponseItemKind(McpCallValue); + + /// Gets the StructuredOutputs. + public static AgentResponseItemKind StructuredOutputs { get; } = new AgentResponseItemKind(StructuredOutputsValue); + + /// Gets the WorkflowAction. + public static AgentResponseItemKind WorkflowAction { get; } = new AgentResponseItemKind(WorkflowActionValue); + + /// Gets the MemorySearchCall. + public static AgentResponseItemKind MemorySearchCall { get; } = new AgentResponseItemKind(MemorySearchCallValue); + + /// Gets the OauthConsentRequest. + public static AgentResponseItemKind OauthConsentRequest { get; } = new AgentResponseItemKind(OauthConsentRequestValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(AgentResponseItemKind left, AgentResponseItemKind right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(AgentResponseItemKind left, AgentResponseItemKind right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator AgentResponseItemKind(string value) => new AgentResponseItemKind(value); + + /// Converts a string to a . + /// The value. + public static implicit operator AgentResponseItemKind?(string value) => value == null ? null : new AgentResponseItemKind(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AgentResponseItemKind other && Equals(other); + + /// + public bool Equals(AgentResponseItemKind other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentResponseItemSource.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentResponseItemSource.Serialization.cs new file mode 100644 index 000000000000..27230dae61d1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentResponseItemSource.Serialization.cs @@ -0,0 +1,152 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The AgentResponseItemSource. + public partial class AgentResponseItemSource : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentResponseItemSource)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Agent)) + { + writer.WritePropertyName("agent"u8); + writer.WriteObjectValue(Agent, options); + } + if (Optional.IsDefined(ResponseId)) + { + writer.WritePropertyName("response_id"u8); + writer.WriteStringValue(ResponseId); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentResponseItemSource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AgentResponseItemSource JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentResponseItemSource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentResponseItemSource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AgentResponseItemSource DeserializeAgentResponseItemSource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentInfo agent = default; + string responseId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("agent"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + agent = AgentInfo.DeserializeAgentInfo(prop.Value, options); + continue; + } + if (prop.NameEquals("response_id"u8)) + { + responseId = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AgentResponseItemSource(agent, responseId, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(AgentResponseItemSource)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AgentResponseItemSource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AgentResponseItemSource PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentResponseItemSource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentResponseItemSource)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentResponseItemSource.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentResponseItemSource.cs new file mode 100644 index 000000000000..c25c3c447e99 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentResponseItemSource.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// The AgentResponseItemSource. + public partial class AgentResponseItemSource + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal AgentResponseItemSource() + { + } + + /// Initializes a new instance of . + /// The agent that created the item. + /// The response on which the item is created. + /// Keeps track of any properties unknown to the library. + internal AgentResponseItemSource(AgentInfo agent, string responseId, IDictionary additionalBinaryDataProperties) + { + Agent = agent; + ResponseId = responseId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The agent that created the item. + public AgentInfo Agent { get; } + + /// The response on which the item is created. + public string ResponseId { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentStructuredOutputsResponseItem.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentStructuredOutputsResponseItem.Serialization.cs new file mode 100644 index 000000000000..7ae7438bf141 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentStructuredOutputsResponseItem.Serialization.cs @@ -0,0 +1,154 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The AgentStructuredOutputsResponseItem. + public partial class AgentStructuredOutputsResponseItem : AgentResponseItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AgentStructuredOutputsResponseItem() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentStructuredOutputsResponseItem)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("output"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Output); +#else + using (JsonDocument document = JsonDocument.Parse(Output)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentStructuredOutputsResponseItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AgentStructuredOutputsResponseItem)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentStructuredOutputsResponseItem)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentStructuredOutputsResponseItem(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AgentStructuredOutputsResponseItem DeserializeAgentStructuredOutputsResponseItem(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + string id = default; + AgentResponseItemSource createdBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + BinaryData output = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdBy = AgentResponseItemSource.DeserializeAgentResponseItemSource(prop.Value, options); + continue; + } + if (prop.NameEquals("output"u8)) + { + output = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AgentStructuredOutputsResponseItem(@type, id, createdBy, additionalBinaryDataProperties, output); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(AgentStructuredOutputsResponseItem)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AgentStructuredOutputsResponseItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AgentStructuredOutputsResponseItem)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentStructuredOutputsResponseItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentStructuredOutputsResponseItem)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentStructuredOutputsResponseItem.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentStructuredOutputsResponseItem.cs new file mode 100644 index 000000000000..6660618cd400 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentStructuredOutputsResponseItem.cs @@ -0,0 +1,61 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The AgentStructuredOutputsResponseItem. + public partial class AgentStructuredOutputsResponseItem : AgentResponseItem + { + /// Initializes a new instance of . + /// + /// The structured output captured during the response. + internal AgentStructuredOutputsResponseItem(string id, BinaryData output) : base(AgentResponseItemKind.StructuredOutputs, id) + { + Output = output; + } + + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + /// The structured output captured during the response. + internal AgentStructuredOutputsResponseItem(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties, BinaryData output) : base(@type, id, createdBy, additionalBinaryDataProperties) + { + Output = output; + } + + /// + /// The structured output captured during the response. + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData Output { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentTool.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentTool.Serialization.cs new file mode 100644 index 000000000000..e2f81759c8c2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentTool.Serialization.cs @@ -0,0 +1,173 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// + /// The AgentTool. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , , , , , , , , , and . + /// + [PersistableModelProxy(typeof(UnknownTool))] + public abstract partial class AgentTool : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AgentTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentTool)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AgentTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AgentTool DeserializeAgentTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "function": + return InternalFunctionTool.DeserializeInternalFunctionTool(element, options); + case "file_search": + return InternalFileSearchTool.DeserializeInternalFileSearchTool(element, options); + case "computer_use_preview": + return InternalComputerUsePreviewTool.DeserializeInternalComputerUsePreviewTool(element, options); + case "web_search_preview": + return InternalWebSearchPreviewTool.DeserializeInternalWebSearchPreviewTool(element, options); + case "code_interpreter": + return InternalCodeInterpreterTool.DeserializeInternalCodeInterpreterTool(element, options); + case "image_generation": + return InternalImageGenTool.DeserializeInternalImageGenTool(element, options); + case "local_shell": + return LocalShellAgentTool.DeserializeLocalShellAgentTool(element, options); + case "mcp": + return InternalMCPTool.DeserializeInternalMCPTool(element, options); + case "bing_grounding": + return BingGroundingAgentTool.DeserializeBingGroundingAgentTool(element, options); + case "fabric_dataagent_preview": + return MicrosoftFabricAgentTool.DeserializeMicrosoftFabricAgentTool(element, options); + case "sharepoint_grounding_preview": + return SharepointAgentTool.DeserializeSharepointAgentTool(element, options); + case "azure_ai_search": + return AzureAISearchAgentTool.DeserializeAzureAISearchAgentTool(element, options); + case "openapi": + return OpenAPIAgentTool.DeserializeOpenAPIAgentTool(element, options); + case "bing_custom_search_preview": + return BingCustomSearchAgentTool.DeserializeBingCustomSearchAgentTool(element, options); + case "browser_automation_preview": + return BrowserAutomationAgentTool.DeserializeBrowserAutomationAgentTool(element, options); + case "azure_function": + return AzureFunctionAgentTool.DeserializeAzureFunctionAgentTool(element, options); + case "capture_structured_outputs": + return CaptureStructuredOutputsTool.DeserializeCaptureStructuredOutputsTool(element, options); + case "a2a_preview": + return A2ATool.DeserializeA2ATool(element, options); + case "memory_search": + return MemorySearchTool.DeserializeMemorySearchTool(element, options); + } + } + return UnknownTool.DeserializeUnknownTool(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(AgentTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AgentTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AgentTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentTool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentTool.cs new file mode 100644 index 000000000000..b263c17338cf --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentTool.cs @@ -0,0 +1,39 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// + /// The AgentTool. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , , , , , , , , , and . + /// + public abstract partial class AgentTool + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + private protected AgentTool(ToolType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal AgentTool(ToolType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Type. + internal ToolType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentVersion.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentVersion.Serialization.cs new file mode 100644 index 000000000000..ec74c815b10b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentVersion.Serialization.cs @@ -0,0 +1,242 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The AgentVersion. + public partial class AgentVersion : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AgentVersion() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentVersion)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"u8); + } + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + writer.WritePropertyName("definition"u8); + writer.WriteObjectValue(Definition, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentVersion IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AgentVersion JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentVersion)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentVersion(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AgentVersion DeserializeAgentVersion(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary metadata = default; + string @object = default; + string id = default; + string name = default; + string version = default; + string description = default; + DateTimeOffset createdAt = default; + AgentDefinition definition = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("metadata"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + metadata = new ChangeTrackingDictionary(); + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + metadata = dictionary; + continue; + } + if (prop.NameEquals("object"u8)) + { + @object = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("version"u8)) + { + version = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_at"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64()); + continue; + } + if (prop.NameEquals("definition"u8)) + { + definition = AgentDefinition.DeserializeAgentDefinition(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AgentVersion( + metadata, + @object, + id, + name, + version, + description, + createdAt, + definition, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(AgentVersion)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AgentVersion IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AgentVersion PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentVersion(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentVersion)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentVersion.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentVersion.cs new file mode 100644 index 000000000000..4043a8a14a0d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentVersion.cs @@ -0,0 +1,98 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// The AgentVersion. + public partial class AgentVersion + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + /// The unique identifier of the agent version. + /// The name of the agent. Name can be used to retrieve/update/delete the agent. + /// The version identifier of the agent. Agents are immutable and every update creates a new version while keeping the name same. + /// The Unix timestamp (seconds) when the agent was created. + /// + internal AgentVersion(IDictionary metadata, string id, string name, string version, DateTimeOffset createdAt, AgentDefinition definition) + { + Metadata = metadata; + Id = id; + Name = name; + Version = version; + CreatedAt = createdAt; + Definition = definition; + } + + /// Initializes a new instance of . + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + /// The object type, which is always 'agent.version'. + /// The unique identifier of the agent version. + /// The name of the agent. Name can be used to retrieve/update/delete the agent. + /// The version identifier of the agent. Agents are immutable and every update creates a new version while keeping the name same. + /// A human-readable description of the agent. + /// The Unix timestamp (seconds) when the agent was created. + /// + /// Keeps track of any properties unknown to the library. + internal AgentVersion(IDictionary metadata, string @object, string id, string name, string version, string description, DateTimeOffset createdAt, AgentDefinition definition, IDictionary additionalBinaryDataProperties) + { + Metadata = metadata; + Object = @object; + Id = id; + Name = name; + Version = version; + Description = description; + CreatedAt = createdAt; + Definition = definition; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + public IDictionary Metadata { get; } + + /// The unique identifier of the agent version. + public string Id { get; } + + /// The name of the agent. Name can be used to retrieve/update/delete the agent. + public string Name { get; } + + /// The version identifier of the agent. Agents are immutable and every update creates a new version while keeping the name same. + public string Version { get; } + + /// A human-readable description of the agent. + public string Description { get; } + + /// The Unix timestamp (seconds) when the agent was created. + public DateTimeOffset CreatedAt { get; } + + /// Gets the Definition. + public AgentDefinition Definition { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentWorkflowActionResponseItem.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentWorkflowActionResponseItem.Serialization.cs new file mode 100644 index 000000000000..5cd6fe37b62b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentWorkflowActionResponseItem.Serialization.cs @@ -0,0 +1,194 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The AgentWorkflowActionResponseItem. + public partial class AgentWorkflowActionResponseItem : AgentResponseItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AgentWorkflowActionResponseItem() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentWorkflowActionResponseItem)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind); + writer.WritePropertyName("action_id"u8); + writer.WriteStringValue(ActionId); + if (Optional.IsDefined(ParentActionId)) + { + writer.WritePropertyName("parent_action_id"u8); + writer.WriteStringValue(ParentActionId); + } + if (Optional.IsDefined(PreviousActionId)) + { + writer.WritePropertyName("previous_action_id"u8); + writer.WriteStringValue(PreviousActionId); + } + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentWorkflowActionResponseItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AgentWorkflowActionResponseItem)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentWorkflowActionResponseItem)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentWorkflowActionResponseItem(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AgentWorkflowActionResponseItem DeserializeAgentWorkflowActionResponseItem(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + string id = default; + AgentResponseItemSource createdBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string kind = default; + string actionId = default; + string parentActionId = default; + string previousActionId = default; + AgentWorkflowActionStatus? status = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdBy = AgentResponseItemSource.DeserializeAgentResponseItemSource(prop.Value, options); + continue; + } + if (prop.NameEquals("kind"u8)) + { + kind = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("action_id"u8)) + { + actionId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("parent_action_id"u8)) + { + parentActionId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("previous_action_id"u8)) + { + previousActionId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("status"u8)) + { + status = new AgentWorkflowActionStatus(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AgentWorkflowActionResponseItem( + @type, + id, + createdBy, + additionalBinaryDataProperties, + kind, + actionId, + parentActionId, + previousActionId, + status); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(AgentWorkflowActionResponseItem)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AgentWorkflowActionResponseItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AgentWorkflowActionResponseItem)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentWorkflowActionResponseItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentWorkflowActionResponseItem)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentWorkflowActionResponseItem.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentWorkflowActionResponseItem.cs new file mode 100644 index 000000000000..ea1ffc87aa11 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentWorkflowActionResponseItem.cs @@ -0,0 +1,56 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// The AgentWorkflowActionResponseItem. + public partial class AgentWorkflowActionResponseItem : AgentResponseItem + { + /// Initializes a new instance of . + /// + /// The kind of CSDL action (e.g., 'SetVariable', 'InvokeAzureAgent'). + /// Unique identifier for the action. + /// Status of the action (e.g., 'in_progress', 'completed', 'failed', 'cancelled'). + internal AgentWorkflowActionResponseItem(string id, string kind, string actionId, AgentWorkflowActionStatus? status) : base(AgentResponseItemKind.WorkflowAction, id) + { + Kind = kind; + ActionId = actionId; + Status = status; + } + + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + /// The kind of CSDL action (e.g., 'SetVariable', 'InvokeAzureAgent'). + /// Unique identifier for the action. + /// ID of the parent action if this is a nested action. + /// ID of the previous action if this action follows another. + /// Status of the action (e.g., 'in_progress', 'completed', 'failed', 'cancelled'). + internal AgentWorkflowActionResponseItem(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties, string kind, string actionId, string parentActionId, string previousActionId, AgentWorkflowActionStatus? status) : base(@type, id, createdBy, additionalBinaryDataProperties) + { + Kind = kind; + ActionId = actionId; + ParentActionId = parentActionId; + PreviousActionId = previousActionId; + Status = status; + } + + /// The kind of CSDL action (e.g., 'SetVariable', 'InvokeAzureAgent'). + public string Kind { get; } + + /// Unique identifier for the action. + public string ActionId { get; } + + /// ID of the parent action if this is a nested action. + public string ParentActionId { get; } + + /// ID of the previous action if this action follows another. + public string PreviousActionId { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentWorkflowActionStatus.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentWorkflowActionStatus.cs new file mode 100644 index 000000000000..4ae32a8c9552 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AgentWorkflowActionStatus.cs @@ -0,0 +1,73 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects.OpenAI +{ + /// + public readonly partial struct AgentWorkflowActionStatus : IEquatable + { + private readonly string _value; + private const string CompletedValue = "completed"; + private const string FailedValue = "failed"; + private const string InProgressValue = "in_progress"; + private const string CancelledValue = "cancelled"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public AgentWorkflowActionStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Completed. + public static AgentWorkflowActionStatus Completed { get; } = new AgentWorkflowActionStatus(CompletedValue); + + /// Gets the Failed. + public static AgentWorkflowActionStatus Failed { get; } = new AgentWorkflowActionStatus(FailedValue); + + /// Gets the InProgress. + public static AgentWorkflowActionStatus InProgress { get; } = new AgentWorkflowActionStatus(InProgressValue); + + /// Gets the Cancelled. + public static AgentWorkflowActionStatus Cancelled { get; } = new AgentWorkflowActionStatus(CancelledValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(AgentWorkflowActionStatus left, AgentWorkflowActionStatus right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(AgentWorkflowActionStatus left, AgentWorkflowActionStatus right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator AgentWorkflowActionStatus(string value) => new AgentWorkflowActionStatus(value); + + /// Converts a string to a . + /// The value. + public static implicit operator AgentWorkflowActionStatus?(string value) => value == null ? null : new AgentWorkflowActionStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AgentWorkflowActionStatus other && Equals(other); + + /// + public bool Equals(AgentWorkflowActionStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AnnotationType.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AnnotationType.cs new file mode 100644 index 000000000000..79e202c241a5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AnnotationType.cs @@ -0,0 +1,74 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + /// + internal readonly partial struct AnnotationType : IEquatable + { + private readonly string _value; + private const string FileCitationValue = "file_citation"; + private const string UrlCitationValue = "url_citation"; + private const string FilePathValue = "file_path"; + private const string ContainerFileCitationValue = "container_file_citation"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public AnnotationType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the FileCitation. + public static AnnotationType FileCitation { get; } = new AnnotationType(FileCitationValue); + + /// Gets the UrlCitation. + public static AnnotationType UrlCitation { get; } = new AnnotationType(UrlCitationValue); + + /// Gets the FilePath. + public static AnnotationType FilePath { get; } = new AnnotationType(FilePathValue); + + /// Gets the ContainerFileCitation. + public static AnnotationType ContainerFileCitation { get; } = new AnnotationType(ContainerFileCitationValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(AnnotationType left, AnnotationType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(AnnotationType left, AnnotationType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator AnnotationType(string value) => new AnnotationType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator AnnotationType?(string value) => value == null ? null : new AnnotationType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AnnotationType other && Equals(other); + + /// + public bool Equals(AnnotationType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureAISearchAgentTool.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureAISearchAgentTool.Serialization.cs new file mode 100644 index 000000000000..24f1b4285011 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureAISearchAgentTool.Serialization.cs @@ -0,0 +1,127 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// The input definition information for an Azure AI search tool as used to configure an agent. + public partial class AzureAISearchAgentTool : AgentTool, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureAISearchAgentTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("azure_ai_search"u8); + writer.WriteObjectValue(Options, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + AzureAISearchAgentTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AzureAISearchAgentTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureAISearchAgentTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureAISearchAgentTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureAISearchAgentTool DeserializeAzureAISearchAgentTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + AzureAISearchToolOptions options0 = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("azure_ai_search"u8)) + { + options0 = AzureAISearchToolOptions.DeserializeAzureAISearchToolOptions(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureAISearchAgentTool(@type, additionalBinaryDataProperties, options0); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(AzureAISearchAgentTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AzureAISearchAgentTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AzureAISearchAgentTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAzureAISearchAgentTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureAISearchAgentTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureAISearchAgentTool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureAISearchAgentTool.cs new file mode 100644 index 000000000000..a2689c8e2dd0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureAISearchAgentTool.cs @@ -0,0 +1,23 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// The input definition information for an Azure AI search tool as used to configure an agent. + public partial class AzureAISearchAgentTool : AgentTool + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The azure ai search index resource. + internal AzureAISearchAgentTool(ToolType @type, IDictionary additionalBinaryDataProperties, AzureAISearchToolOptions options) : base(@type, additionalBinaryDataProperties) + { + Options = options; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureAISearchQueryType.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureAISearchQueryType.cs new file mode 100644 index 000000000000..dbadba39e1a4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureAISearchQueryType.cs @@ -0,0 +1,82 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects.OpenAI +{ + /// Available query types for Azure AI Search tool. + public readonly partial struct AzureAISearchQueryType : IEquatable + { + private readonly string _value; + /// Query type `simple`. + private const string SimpleValue = "simple"; + /// Query type `semantic`. + private const string SemanticValue = "semantic"; + /// Query type `vector`. + private const string VectorValue = "vector"; + /// Query type `vector_simple_hybrid`. + private const string VectorSimpleHybridValue = "vector_simple_hybrid"; + /// Query type `vector_semantic_hybrid`. + private const string VectorSemanticHybridValue = "vector_semantic_hybrid"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public AzureAISearchQueryType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Query type `simple`. + public static AzureAISearchQueryType Simple { get; } = new AzureAISearchQueryType(SimpleValue); + + /// Query type `semantic`. + public static AzureAISearchQueryType Semantic { get; } = new AzureAISearchQueryType(SemanticValue); + + /// Query type `vector`. + public static AzureAISearchQueryType Vector { get; } = new AzureAISearchQueryType(VectorValue); + + /// Query type `vector_simple_hybrid`. + public static AzureAISearchQueryType VectorSimpleHybrid { get; } = new AzureAISearchQueryType(VectorSimpleHybridValue); + + /// Query type `vector_semantic_hybrid`. + public static AzureAISearchQueryType VectorSemanticHybrid { get; } = new AzureAISearchQueryType(VectorSemanticHybridValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(AzureAISearchQueryType left, AzureAISearchQueryType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(AzureAISearchQueryType left, AzureAISearchQueryType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator AzureAISearchQueryType(string value) => new AzureAISearchQueryType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator AzureAISearchQueryType?(string value) => value == null ? null : new AzureAISearchQueryType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AzureAISearchQueryType other && Equals(other); + + /// + public bool Equals(AzureAISearchQueryType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureAISearchToolIndex.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureAISearchToolIndex.Serialization.cs new file mode 100644 index 000000000000..6ad2843d49c0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureAISearchToolIndex.Serialization.cs @@ -0,0 +1,207 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// A AI Search Index resource. + public partial class AzureAISearchToolIndex : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureAISearchToolIndex)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(ProjectConnectionId)) + { + writer.WritePropertyName("project_connection_id"u8); + writer.WriteStringValue(ProjectConnectionId); + } + if (Optional.IsDefined(IndexName)) + { + writer.WritePropertyName("index_name"u8); + writer.WriteStringValue(IndexName); + } + if (Optional.IsDefined(QueryType)) + { + writer.WritePropertyName("query_type"u8); + writer.WriteStringValue(QueryType.Value.ToString()); + } + if (Optional.IsDefined(TopK)) + { + writer.WritePropertyName("top_k"u8); + writer.WriteNumberValue(TopK.Value); + } + if (Optional.IsDefined(Filter)) + { + writer.WritePropertyName("filter"u8); + writer.WriteStringValue(Filter); + } + if (Optional.IsDefined(IndexAssetId)) + { + writer.WritePropertyName("index_asset_id"u8); + writer.WriteStringValue(IndexAssetId); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AzureAISearchToolIndex IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AzureAISearchToolIndex JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureAISearchToolIndex)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureAISearchToolIndex(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureAISearchToolIndex DeserializeAzureAISearchToolIndex(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string projectConnectionId = default; + string indexName = default; + AzureAISearchQueryType? queryType = default; + int? topK = default; + string filter = default; + string indexAssetId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("project_connection_id"u8)) + { + projectConnectionId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("index_name"u8)) + { + indexName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("query_type"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + queryType = new AzureAISearchQueryType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("top_k"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + topK = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("filter"u8)) + { + filter = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("index_asset_id"u8)) + { + indexAssetId = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureAISearchToolIndex( + projectConnectionId, + indexName, + queryType, + topK, + filter, + indexAssetId, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(AzureAISearchToolIndex)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AzureAISearchToolIndex IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AzureAISearchToolIndex PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAzureAISearchToolIndex(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureAISearchToolIndex)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureAISearchToolIndex.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureAISearchToolIndex.cs new file mode 100644 index 000000000000..8fa533cde9e5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureAISearchToolIndex.cs @@ -0,0 +1,58 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// A AI Search Index resource. + public partial class AzureAISearchToolIndex + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public AzureAISearchToolIndex() + { + } + + /// Initializes a new instance of . + /// An index connection ID in an IndexResource attached to this agent. + /// The name of an index in an IndexResource attached to this agent. + /// Type of query in an AIIndexResource attached to this agent. + /// Number of documents to retrieve from search and present to the model. + /// filter string for search resource. [Learn more here](https://learn.microsoft.com/azure/search/search-filters). + /// Index asset id for search resource. + /// Keeps track of any properties unknown to the library. + internal AzureAISearchToolIndex(string projectConnectionId, string indexName, AzureAISearchQueryType? queryType, int? topK, string filter, string indexAssetId, IDictionary additionalBinaryDataProperties) + { + ProjectConnectionId = projectConnectionId; + IndexName = indexName; + QueryType = queryType; + TopK = topK; + Filter = filter; + IndexAssetId = indexAssetId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// An index connection ID in an IndexResource attached to this agent. + public string ProjectConnectionId { get; set; } + + /// The name of an index in an IndexResource attached to this agent. + public string IndexName { get; set; } + + /// Type of query in an AIIndexResource attached to this agent. + public AzureAISearchQueryType? QueryType { get; set; } + + /// Number of documents to retrieve from search and present to the model. + public int? TopK { get; set; } + + /// filter string for search resource. [Learn more here](https://learn.microsoft.com/azure/search/search-filters). + public string Filter { get; set; } + + /// Index asset id for search resource. + public string IndexAssetId { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureAISearchToolOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureAISearchToolOptions.Serialization.cs new file mode 100644 index 000000000000..62a0aa68a27e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureAISearchToolOptions.Serialization.cs @@ -0,0 +1,149 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// A set of index resources used by the `azure_ai_search` tool. + public partial class AzureAISearchToolOptions : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AzureAISearchToolOptions() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureAISearchToolOptions)} does not support writing '{format}' format."); + } + writer.WritePropertyName("indexes"u8); + writer.WriteStartArray(); + foreach (AzureAISearchToolIndex item in Indexes) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AzureAISearchToolOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AzureAISearchToolOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureAISearchToolOptions)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureAISearchToolOptions(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureAISearchToolOptions DeserializeAzureAISearchToolOptions(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList indexes = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("indexes"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(AzureAISearchToolIndex.DeserializeAzureAISearchToolIndex(item, options)); + } + indexes = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureAISearchToolOptions(indexes, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(AzureAISearchToolOptions)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AzureAISearchToolOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AzureAISearchToolOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAzureAISearchToolOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureAISearchToolOptions)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureAISearchToolOptions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureAISearchToolOptions.cs new file mode 100644 index 000000000000..c9aac56eb5f1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureAISearchToolOptions.cs @@ -0,0 +1,42 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects.OpenAI +{ + /// A set of index resources used by the `azure_ai_search` tool. + public partial class AzureAISearchToolOptions + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// The indices attached to this agent. There can be a maximum of 1 index + /// resource attached to the agent. + /// + /// is null. + public AzureAISearchToolOptions(IEnumerable indexes) + { + Argument.AssertNotNull(indexes, nameof(indexes)); + + Indexes = indexes.ToList(); + } + + /// Initializes a new instance of . + /// + /// The indices attached to this agent. There can be a maximum of 1 index + /// resource attached to the agent. + /// + /// Keeps track of any properties unknown to the library. + internal AzureAISearchToolOptions(IList indexes, IDictionary additionalBinaryDataProperties) + { + Indexes = indexes; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionAgentTool.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionAgentTool.Serialization.cs new file mode 100644 index 000000000000..7119065e60ef --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionAgentTool.Serialization.cs @@ -0,0 +1,132 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// The input definition information for an Azure Function Tool, as used to configure an Agent. + public partial class AzureFunctionAgentTool : AgentTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AzureFunctionAgentTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureFunctionAgentTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("azure_function"u8); + writer.WriteObjectValue(AzureFunction, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + AzureFunctionAgentTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AzureFunctionAgentTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureFunctionAgentTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureFunctionAgentTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureFunctionAgentTool DeserializeAzureFunctionAgentTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + AzureFunctionDefinition azureFunction = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("azure_function"u8)) + { + azureFunction = AzureFunctionDefinition.DeserializeAzureFunctionDefinition(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureFunctionAgentTool(@type, additionalBinaryDataProperties, azureFunction); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(AzureFunctionAgentTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AzureFunctionAgentTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AzureFunctionAgentTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAzureFunctionAgentTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureFunctionAgentTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionAgentTool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionAgentTool.cs new file mode 100644 index 000000000000..e5a68b43c79a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionAgentTool.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// The input definition information for an Azure Function Tool, as used to configure an Agent. + public partial class AzureFunctionAgentTool : AgentTool + { + /// Initializes a new instance of . + /// The Azure Function Tool definition. + /// is null. + public AzureFunctionAgentTool(AzureFunctionDefinition azureFunction) : base(ToolType.AzureFunction) + { + Argument.AssertNotNull(azureFunction, nameof(azureFunction)); + + AzureFunction = azureFunction; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The Azure Function Tool definition. + internal AzureFunctionAgentTool(ToolType @type, IDictionary additionalBinaryDataProperties, AzureFunctionDefinition azureFunction) : base(@type, additionalBinaryDataProperties) + { + AzureFunction = azureFunction; + } + + /// The Azure Function Tool definition. + public AzureFunctionDefinition AzureFunction { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionBinding.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionBinding.Serialization.cs new file mode 100644 index 000000000000..d691a5be0f9a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionBinding.Serialization.cs @@ -0,0 +1,147 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The structure for keeping storage queue name and URI. + public partial class AzureFunctionBinding : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AzureFunctionBinding() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureFunctionBinding)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + writer.WritePropertyName("storage_queue"u8); + writer.WriteObjectValue(StorageQueue, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AzureFunctionBinding IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AzureFunctionBinding JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureFunctionBinding)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureFunctionBinding(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureFunctionBinding DeserializeAzureFunctionBinding(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = default; + AzureFunctionStorageQueue storageQueue = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("storage_queue"u8)) + { + storageQueue = AzureFunctionStorageQueue.DeserializeAzureFunctionStorageQueue(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureFunctionBinding(@type, storageQueue, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(AzureFunctionBinding)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AzureFunctionBinding IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AzureFunctionBinding PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAzureFunctionBinding(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureFunctionBinding)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionBinding.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionBinding.cs new file mode 100644 index 000000000000..432ab57e7d69 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionBinding.cs @@ -0,0 +1,43 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// The structure for keeping storage queue name and URI. + public partial class AzureFunctionBinding + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Storage queue. + /// is null. + public AzureFunctionBinding(AzureFunctionStorageQueue storageQueue) + { + Argument.AssertNotNull(storageQueue, nameof(storageQueue)); + + StorageQueue = storageQueue; + } + + /// Initializes a new instance of . + /// The type of binding, which is always 'storage_queue'. + /// Storage queue. + /// Keeps track of any properties unknown to the library. + internal AzureFunctionBinding(string @type, AzureFunctionStorageQueue storageQueue, IDictionary additionalBinaryDataProperties) + { + Type = @type; + StorageQueue = storageQueue; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The type of binding, which is always 'storage_queue'. + public string Type { get; } = "storage_queue"; + + /// Storage queue. + public AzureFunctionStorageQueue StorageQueue { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionDefinition.Serialization.cs new file mode 100644 index 000000000000..c6085c865021 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionDefinition.Serialization.cs @@ -0,0 +1,155 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The definition of Azure function. + public partial class AzureFunctionDefinition : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AzureFunctionDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureFunctionDefinition)} does not support writing '{format}' format."); + } + writer.WritePropertyName("function"u8); + writer.WriteObjectValue(Function, options); + writer.WritePropertyName("input_binding"u8); + writer.WriteObjectValue(InputBinding, options); + writer.WritePropertyName("output_binding"u8); + writer.WriteObjectValue(OutputBinding, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AzureFunctionDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AzureFunctionDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureFunctionDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureFunctionDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureFunctionDefinition DeserializeAzureFunctionDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AzureFunctionDefinitionFunction function = default; + AzureFunctionBinding inputBinding = default; + AzureFunctionBinding outputBinding = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("function"u8)) + { + function = AzureFunctionDefinitionFunction.DeserializeAzureFunctionDefinitionFunction(prop.Value, options); + continue; + } + if (prop.NameEquals("input_binding"u8)) + { + inputBinding = AzureFunctionBinding.DeserializeAzureFunctionBinding(prop.Value, options); + continue; + } + if (prop.NameEquals("output_binding"u8)) + { + outputBinding = AzureFunctionBinding.DeserializeAzureFunctionBinding(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureFunctionDefinition(function, inputBinding, outputBinding, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(AzureFunctionDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AzureFunctionDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AzureFunctionDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAzureFunctionDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureFunctionDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionDefinition.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionDefinition.cs new file mode 100644 index 000000000000..524cb7eefa7c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionDefinition.cs @@ -0,0 +1,54 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// The definition of Azure function. + public partial class AzureFunctionDefinition + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The definition of azure function and its parameters. + /// Input storage queue. The queue storage trigger runs a function as messages are added to it. + /// Output storage queue. The function writes output to this queue when the input items are processed. + /// , or is null. + public AzureFunctionDefinition(AzureFunctionDefinitionFunction function, AzureFunctionBinding inputBinding, AzureFunctionBinding outputBinding) + { + Argument.AssertNotNull(function, nameof(function)); + Argument.AssertNotNull(inputBinding, nameof(inputBinding)); + Argument.AssertNotNull(outputBinding, nameof(outputBinding)); + + Function = function; + InputBinding = inputBinding; + OutputBinding = outputBinding; + } + + /// Initializes a new instance of . + /// The definition of azure function and its parameters. + /// Input storage queue. The queue storage trigger runs a function as messages are added to it. + /// Output storage queue. The function writes output to this queue when the input items are processed. + /// Keeps track of any properties unknown to the library. + internal AzureFunctionDefinition(AzureFunctionDefinitionFunction function, AzureFunctionBinding inputBinding, AzureFunctionBinding outputBinding, IDictionary additionalBinaryDataProperties) + { + Function = function; + InputBinding = inputBinding; + OutputBinding = outputBinding; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The definition of azure function and its parameters. + public AzureFunctionDefinitionFunction Function { get; set; } + + /// Input storage queue. The queue storage trigger runs a function as messages are added to it. + public AzureFunctionBinding InputBinding { get; set; } + + /// Output storage queue. The function writes output to this queue when the input items are processed. + public AzureFunctionBinding OutputBinding { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionDefinitionFunction.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionDefinitionFunction.Serialization.cs new file mode 100644 index 000000000000..c9343fd9f9d1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionDefinitionFunction.Serialization.cs @@ -0,0 +1,165 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The AzureFunctionDefinitionFunction. + public partial class AzureFunctionDefinitionFunction : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AzureFunctionDefinitionFunction() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureFunctionDefinitionFunction)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("parameters"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Parameters); +#else + using (JsonDocument document = JsonDocument.Parse(Parameters)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AzureFunctionDefinitionFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AzureFunctionDefinitionFunction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureFunctionDefinitionFunction)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureFunctionDefinitionFunction(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureFunctionDefinitionFunction DeserializeAzureFunctionDefinitionFunction(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string description = default; + BinaryData parameters = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("parameters"u8)) + { + parameters = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureFunctionDefinitionFunction(name, description, parameters, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(AzureFunctionDefinitionFunction)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AzureFunctionDefinitionFunction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AzureFunctionDefinitionFunction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAzureFunctionDefinitionFunction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureFunctionDefinitionFunction)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionDefinitionFunction.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionDefinitionFunction.cs new file mode 100644 index 000000000000..ecb04294e9ed --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionDefinitionFunction.cs @@ -0,0 +1,77 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The AzureFunctionDefinitionFunction. + public partial class AzureFunctionDefinitionFunction + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The name of the function to be called. + /// The parameters the functions accepts, described as a JSON Schema object. + /// or is null. + public AzureFunctionDefinitionFunction(string name, BinaryData parameters) + { + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(parameters, nameof(parameters)); + + Name = name; + Parameters = parameters; + } + + /// Initializes a new instance of . + /// The name of the function to be called. + /// A description of what the function does, used by the model to choose when and how to call the function. + /// The parameters the functions accepts, described as a JSON Schema object. + /// Keeps track of any properties unknown to the library. + internal AzureFunctionDefinitionFunction(string name, string description, BinaryData parameters, IDictionary additionalBinaryDataProperties) + { + Name = name; + Description = description; + Parameters = parameters; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The name of the function to be called. + public string Name { get; set; } + + /// A description of what the function does, used by the model to choose when and how to call the function. + public string Description { get; set; } + + /// + /// The parameters the functions accepts, described as a JSON Schema object. + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData Parameters { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionStorageQueue.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionStorageQueue.Serialization.cs new file mode 100644 index 000000000000..d26e543e2018 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionStorageQueue.Serialization.cs @@ -0,0 +1,147 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The structure for keeping storage queue name and URI. + public partial class AzureFunctionStorageQueue : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AzureFunctionStorageQueue() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureFunctionStorageQueue)} does not support writing '{format}' format."); + } + writer.WritePropertyName("queue_service_endpoint"u8); + writer.WriteStringValue(QueueServiceEndpoint); + writer.WritePropertyName("queue_name"u8); + writer.WriteStringValue(QueueName); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AzureFunctionStorageQueue IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AzureFunctionStorageQueue JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureFunctionStorageQueue)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureFunctionStorageQueue(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureFunctionStorageQueue DeserializeAzureFunctionStorageQueue(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string queueServiceEndpoint = default; + string queueName = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("queue_service_endpoint"u8)) + { + queueServiceEndpoint = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("queue_name"u8)) + { + queueName = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureFunctionStorageQueue(queueServiceEndpoint, queueName, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(AzureFunctionStorageQueue)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AzureFunctionStorageQueue IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AzureFunctionStorageQueue PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAzureFunctionStorageQueue(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureFunctionStorageQueue)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionStorageQueue.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionStorageQueue.cs new file mode 100644 index 000000000000..852ddd7f2cbf --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/AzureFunctionStorageQueue.cs @@ -0,0 +1,46 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// The structure for keeping storage queue name and URI. + public partial class AzureFunctionStorageQueue + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// URI to the Azure Storage Queue service allowing you to manipulate a queue. + /// The name of an Azure function storage queue. + /// or is null. + public AzureFunctionStorageQueue(string queueServiceEndpoint, string queueName) + { + Argument.AssertNotNull(queueServiceEndpoint, nameof(queueServiceEndpoint)); + Argument.AssertNotNull(queueName, nameof(queueName)); + + QueueServiceEndpoint = queueServiceEndpoint; + QueueName = queueName; + } + + /// Initializes a new instance of . + /// URI to the Azure Storage Queue service allowing you to manipulate a queue. + /// The name of an Azure function storage queue. + /// Keeps track of any properties unknown to the library. + internal AzureFunctionStorageQueue(string queueServiceEndpoint, string queueName, IDictionary additionalBinaryDataProperties) + { + QueueServiceEndpoint = queueServiceEndpoint; + QueueName = queueName; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// URI to the Azure Storage Queue service allowing you to manipulate a queue. + public string QueueServiceEndpoint { get; set; } + + /// The name of an Azure function storage queue. + public string QueueName { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingCustomSearchAgentTool.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingCustomSearchAgentTool.Serialization.cs new file mode 100644 index 000000000000..53b2ab8b162c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingCustomSearchAgentTool.Serialization.cs @@ -0,0 +1,132 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// The input definition information for a Bing custom search tool as used to configure an agent. + public partial class BingCustomSearchAgentTool : AgentTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BingCustomSearchAgentTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingCustomSearchAgentTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("bing_custom_search_preview"u8); + writer.WriteObjectValue(BingCustomSearchPreview, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + BingCustomSearchAgentTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (BingCustomSearchAgentTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingCustomSearchAgentTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBingCustomSearchAgentTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BingCustomSearchAgentTool DeserializeBingCustomSearchAgentTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + BingCustomSearchToolParameters bingCustomSearchPreview = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("bing_custom_search_preview"u8)) + { + bingCustomSearchPreview = BingCustomSearchToolParameters.DeserializeBingCustomSearchToolParameters(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BingCustomSearchAgentTool(@type, additionalBinaryDataProperties, bingCustomSearchPreview); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(BingCustomSearchAgentTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + BingCustomSearchAgentTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (BingCustomSearchAgentTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeBingCustomSearchAgentTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BingCustomSearchAgentTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingCustomSearchAgentTool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingCustomSearchAgentTool.cs new file mode 100644 index 000000000000..5b20ed1713f1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingCustomSearchAgentTool.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// The input definition information for a Bing custom search tool as used to configure an agent. + public partial class BingCustomSearchAgentTool : AgentTool + { + /// Initializes a new instance of . + /// The bing custom search tool parameters. + /// is null. + public BingCustomSearchAgentTool(BingCustomSearchToolParameters bingCustomSearchPreview) : base(ToolType.BingCustomSearchPreview) + { + Argument.AssertNotNull(bingCustomSearchPreview, nameof(bingCustomSearchPreview)); + + BingCustomSearchPreview = bingCustomSearchPreview; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The bing custom search tool parameters. + internal BingCustomSearchAgentTool(ToolType @type, IDictionary additionalBinaryDataProperties, BingCustomSearchToolParameters bingCustomSearchPreview) : base(@type, additionalBinaryDataProperties) + { + BingCustomSearchPreview = bingCustomSearchPreview; + } + + /// The bing custom search tool parameters. + public BingCustomSearchToolParameters BingCustomSearchPreview { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingCustomSearchConfiguration.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingCustomSearchConfiguration.Serialization.cs new file mode 100644 index 000000000000..344b85773c82 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingCustomSearchConfiguration.Serialization.cs @@ -0,0 +1,202 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// A bing custom search configuration. + public partial class BingCustomSearchConfiguration : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BingCustomSearchConfiguration() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingCustomSearchConfiguration)} does not support writing '{format}' format."); + } + writer.WritePropertyName("project_connection_id"u8); + writer.WriteStringValue(ProjectConnectionId); + writer.WritePropertyName("instance_name"u8); + writer.WriteStringValue(InstanceName); + if (Optional.IsDefined(Market)) + { + writer.WritePropertyName("market"u8); + writer.WriteStringValue(Market); + } + if (Optional.IsDefined(SetLang)) + { + writer.WritePropertyName("set_lang"u8); + writer.WriteStringValue(SetLang); + } + if (Optional.IsDefined(Count)) + { + writer.WritePropertyName("count"u8); + writer.WriteNumberValue(Count.Value); + } + if (Optional.IsDefined(Freshness)) + { + writer.WritePropertyName("freshness"u8); + writer.WriteStringValue(Freshness); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + BingCustomSearchConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual BingCustomSearchConfiguration JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingCustomSearchConfiguration)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBingCustomSearchConfiguration(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BingCustomSearchConfiguration DeserializeBingCustomSearchConfiguration(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string projectConnectionId = default; + string instanceName = default; + string market = default; + string setLang = default; + long? count = default; + string freshness = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("project_connection_id"u8)) + { + projectConnectionId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("instance_name"u8)) + { + instanceName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("market"u8)) + { + market = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("set_lang"u8)) + { + setLang = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("count"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + count = prop.Value.GetInt64(); + continue; + } + if (prop.NameEquals("freshness"u8)) + { + freshness = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BingCustomSearchConfiguration( + projectConnectionId, + instanceName, + market, + setLang, + count, + freshness, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(BingCustomSearchConfiguration)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + BingCustomSearchConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual BingCustomSearchConfiguration PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeBingCustomSearchConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BingCustomSearchConfiguration)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingCustomSearchConfiguration.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingCustomSearchConfiguration.cs new file mode 100644 index 000000000000..d808f3f79b35 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingCustomSearchConfiguration.cs @@ -0,0 +1,66 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// A bing custom search configuration. + public partial class BingCustomSearchConfiguration + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Project connection id for grounding with bing search. + /// Name of the custom configuration instance given to config. + /// or is null. + public BingCustomSearchConfiguration(string projectConnectionId, string instanceName) + { + Argument.AssertNotNull(projectConnectionId, nameof(projectConnectionId)); + Argument.AssertNotNull(instanceName, nameof(instanceName)); + + ProjectConnectionId = projectConnectionId; + InstanceName = instanceName; + } + + /// Initializes a new instance of . + /// Project connection id for grounding with bing search. + /// Name of the custom configuration instance given to config. + /// The market where the results come from. + /// The language to use for user interface strings when calling Bing API. + /// The number of search results to return in the bing api response. + /// Filter search results by a specific time range. See [accepted values here](https://learn.microsoft.com/bing/search-apis/bing-web-search/reference/query-parameters). + /// Keeps track of any properties unknown to the library. + internal BingCustomSearchConfiguration(string projectConnectionId, string instanceName, string market, string setLang, long? count, string freshness, IDictionary additionalBinaryDataProperties) + { + ProjectConnectionId = projectConnectionId; + InstanceName = instanceName; + Market = market; + SetLang = setLang; + Count = count; + Freshness = freshness; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Project connection id for grounding with bing search. + public string ProjectConnectionId { get; set; } + + /// Name of the custom configuration instance given to config. + public string InstanceName { get; set; } + + /// The market where the results come from. + public string Market { get; set; } + + /// The language to use for user interface strings when calling Bing API. + public string SetLang { get; set; } + + /// The number of search results to return in the bing api response. + public long? Count { get; set; } + + /// Filter search results by a specific time range. See [accepted values here](https://learn.microsoft.com/bing/search-apis/bing-web-search/reference/query-parameters). + public string Freshness { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingCustomSearchToolParameters.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingCustomSearchToolParameters.Serialization.cs new file mode 100644 index 000000000000..f8bd6afe64ef --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingCustomSearchToolParameters.Serialization.cs @@ -0,0 +1,149 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The bing custom search tool parameters. + public partial class BingCustomSearchToolParameters : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BingCustomSearchToolParameters() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingCustomSearchToolParameters)} does not support writing '{format}' format."); + } + writer.WritePropertyName("search_configurations"u8); + writer.WriteStartArray(); + foreach (BingCustomSearchConfiguration item in SearchConfigurations) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + BingCustomSearchToolParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual BingCustomSearchToolParameters JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingCustomSearchToolParameters)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBingCustomSearchToolParameters(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BingCustomSearchToolParameters DeserializeBingCustomSearchToolParameters(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList searchConfigurations = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("search_configurations"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(BingCustomSearchConfiguration.DeserializeBingCustomSearchConfiguration(item, options)); + } + searchConfigurations = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BingCustomSearchToolParameters(searchConfigurations, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(BingCustomSearchToolParameters)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + BingCustomSearchToolParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual BingCustomSearchToolParameters PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeBingCustomSearchToolParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BingCustomSearchToolParameters)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingCustomSearchToolParameters.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingCustomSearchToolParameters.cs new file mode 100644 index 000000000000..8144c6b2586b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingCustomSearchToolParameters.cs @@ -0,0 +1,48 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects.OpenAI +{ + /// The bing custom search tool parameters. + public partial class BingCustomSearchToolParameters + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// The project connections attached to this tool. There can be a maximum of 1 connection + /// resource attached to the tool. + /// + /// is null. + public BingCustomSearchToolParameters(IEnumerable searchConfigurations) + { + Argument.AssertNotNull(searchConfigurations, nameof(searchConfigurations)); + + SearchConfigurations = searchConfigurations.ToList(); + } + + /// Initializes a new instance of . + /// + /// The project connections attached to this tool. There can be a maximum of 1 connection + /// resource attached to the tool. + /// + /// Keeps track of any properties unknown to the library. + internal BingCustomSearchToolParameters(IList searchConfigurations, IDictionary additionalBinaryDataProperties) + { + SearchConfigurations = searchConfigurations; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// The project connections attached to this tool. There can be a maximum of 1 connection + /// resource attached to the tool. + /// + public IList SearchConfigurations { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingGroundingAgentTool.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingGroundingAgentTool.Serialization.cs new file mode 100644 index 000000000000..9bb6757678b6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingGroundingAgentTool.Serialization.cs @@ -0,0 +1,132 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// The input definition information for a bing grounding search tool as used to configure an agent. + public partial class BingGroundingAgentTool : AgentTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BingGroundingAgentTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingGroundingAgentTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("bing_grounding"u8); + writer.WriteObjectValue(BingGrounding, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + BingGroundingAgentTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (BingGroundingAgentTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingGroundingAgentTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBingGroundingAgentTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BingGroundingAgentTool DeserializeBingGroundingAgentTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + BingGroundingSearchToolOptions bingGrounding = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("bing_grounding"u8)) + { + bingGrounding = BingGroundingSearchToolOptions.DeserializeBingGroundingSearchToolOptions(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BingGroundingAgentTool(@type, additionalBinaryDataProperties, bingGrounding); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(BingGroundingAgentTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + BingGroundingAgentTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (BingGroundingAgentTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeBingGroundingAgentTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BingGroundingAgentTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingGroundingAgentTool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingGroundingAgentTool.cs new file mode 100644 index 000000000000..cec4343a051f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingGroundingAgentTool.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// The input definition information for a bing grounding search tool as used to configure an agent. + public partial class BingGroundingAgentTool : AgentTool + { + /// Initializes a new instance of . + /// The bing grounding search tool parameters. + /// is null. + public BingGroundingAgentTool(BingGroundingSearchToolOptions bingGrounding) : base(ToolType.BingGrounding) + { + Argument.AssertNotNull(bingGrounding, nameof(bingGrounding)); + + BingGrounding = bingGrounding; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The bing grounding search tool parameters. + internal BingGroundingAgentTool(ToolType @type, IDictionary additionalBinaryDataProperties, BingGroundingSearchToolOptions bingGrounding) : base(@type, additionalBinaryDataProperties) + { + BingGrounding = bingGrounding; + } + + /// The bing grounding search tool parameters. + public BingGroundingSearchToolOptions BingGrounding { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingGroundingSearchConfiguration.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingGroundingSearchConfiguration.Serialization.cs new file mode 100644 index 000000000000..095d8b60f284 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingGroundingSearchConfiguration.Serialization.cs @@ -0,0 +1,193 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// Search configuration for Bing Grounding. + public partial class BingGroundingSearchConfiguration : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BingGroundingSearchConfiguration() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingGroundingSearchConfiguration)} does not support writing '{format}' format."); + } + writer.WritePropertyName("project_connection_id"u8); + writer.WriteStringValue(ProjectConnectionId); + if (Optional.IsDefined(Market)) + { + writer.WritePropertyName("market"u8); + writer.WriteStringValue(Market); + } + if (Optional.IsDefined(SetLang)) + { + writer.WritePropertyName("set_lang"u8); + writer.WriteStringValue(SetLang); + } + if (Optional.IsDefined(Count)) + { + writer.WritePropertyName("count"u8); + writer.WriteNumberValue(Count.Value); + } + if (Optional.IsDefined(Freshness)) + { + writer.WritePropertyName("freshness"u8); + writer.WriteStringValue(Freshness); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + BingGroundingSearchConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual BingGroundingSearchConfiguration JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingGroundingSearchConfiguration)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBingGroundingSearchConfiguration(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BingGroundingSearchConfiguration DeserializeBingGroundingSearchConfiguration(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string projectConnectionId = default; + string market = default; + string setLang = default; + long? count = default; + string freshness = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("project_connection_id"u8)) + { + projectConnectionId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("market"u8)) + { + market = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("set_lang"u8)) + { + setLang = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("count"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + count = prop.Value.GetInt64(); + continue; + } + if (prop.NameEquals("freshness"u8)) + { + freshness = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BingGroundingSearchConfiguration( + projectConnectionId, + market, + setLang, + count, + freshness, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(BingGroundingSearchConfiguration)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + BingGroundingSearchConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual BingGroundingSearchConfiguration PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeBingGroundingSearchConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BingGroundingSearchConfiguration)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingGroundingSearchConfiguration.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingGroundingSearchConfiguration.cs new file mode 100644 index 000000000000..daa1bb688c02 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingGroundingSearchConfiguration.cs @@ -0,0 +1,58 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// Search configuration for Bing Grounding. + public partial class BingGroundingSearchConfiguration + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Project connection id for grounding with bing search. + /// is null. + public BingGroundingSearchConfiguration(string projectConnectionId) + { + Argument.AssertNotNull(projectConnectionId, nameof(projectConnectionId)); + + ProjectConnectionId = projectConnectionId; + } + + /// Initializes a new instance of . + /// Project connection id for grounding with bing search. + /// The market where the results come from. + /// The language to use for user interface strings when calling Bing API. + /// The number of search results to return in the bing api response. + /// Filter search results by a specific time range. See [accepted values here](https://learn.microsoft.com/bing/search-apis/bing-web-search/reference/query-parameters). + /// Keeps track of any properties unknown to the library. + internal BingGroundingSearchConfiguration(string projectConnectionId, string market, string setLang, long? count, string freshness, IDictionary additionalBinaryDataProperties) + { + ProjectConnectionId = projectConnectionId; + Market = market; + SetLang = setLang; + Count = count; + Freshness = freshness; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Project connection id for grounding with bing search. + public string ProjectConnectionId { get; set; } + + /// The market where the results come from. + public string Market { get; set; } + + /// The language to use for user interface strings when calling Bing API. + public string SetLang { get; set; } + + /// The number of search results to return in the bing api response. + public long? Count { get; set; } + + /// Filter search results by a specific time range. See [accepted values here](https://learn.microsoft.com/bing/search-apis/bing-web-search/reference/query-parameters). + public string Freshness { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingGroundingSearchToolOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingGroundingSearchToolOptions.Serialization.cs new file mode 100644 index 000000000000..8c649374f8be --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingGroundingSearchToolOptions.Serialization.cs @@ -0,0 +1,149 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The bing grounding search tool parameters. + public partial class BingGroundingSearchToolOptions : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BingGroundingSearchToolOptions() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingGroundingSearchToolOptions)} does not support writing '{format}' format."); + } + writer.WritePropertyName("search_configurations"u8); + writer.WriteStartArray(); + foreach (BingGroundingSearchConfiguration item in SearchConfigurations) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + BingGroundingSearchToolOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual BingGroundingSearchToolOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingGroundingSearchToolOptions)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBingGroundingSearchToolOptions(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BingGroundingSearchToolOptions DeserializeBingGroundingSearchToolOptions(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList searchConfigurations = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("search_configurations"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(BingGroundingSearchConfiguration.DeserializeBingGroundingSearchConfiguration(item, options)); + } + searchConfigurations = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BingGroundingSearchToolOptions(searchConfigurations, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(BingGroundingSearchToolOptions)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + BingGroundingSearchToolOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual BingGroundingSearchToolOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeBingGroundingSearchToolOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BingGroundingSearchToolOptions)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingGroundingSearchToolOptions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingGroundingSearchToolOptions.cs new file mode 100644 index 000000000000..3443f12ce851 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BingGroundingSearchToolOptions.cs @@ -0,0 +1,48 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects.OpenAI +{ + /// The bing grounding search tool parameters. + public partial class BingGroundingSearchToolOptions + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// The search configurations attached to this tool. There can be a maximum of 1 + /// search configuration resource attached to the tool. + /// + /// is null. + public BingGroundingSearchToolOptions(IEnumerable searchConfigurations) + { + Argument.AssertNotNull(searchConfigurations, nameof(searchConfigurations)); + + SearchConfigurations = searchConfigurations.ToList(); + } + + /// Initializes a new instance of . + /// + /// The search configurations attached to this tool. There can be a maximum of 1 + /// search configuration resource attached to the tool. + /// + /// Keeps track of any properties unknown to the library. + internal BingGroundingSearchToolOptions(IList searchConfigurations, IDictionary additionalBinaryDataProperties) + { + SearchConfigurations = searchConfigurations; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// The search configurations attached to this tool. There can be a maximum of 1 + /// search configuration resource attached to the tool. + /// + public IList SearchConfigurations { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BrowserAutomationAgentTool.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BrowserAutomationAgentTool.Serialization.cs new file mode 100644 index 000000000000..d4bf2c9f334e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BrowserAutomationAgentTool.Serialization.cs @@ -0,0 +1,132 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// The input definition information for a Browser Automation Tool, as used to configure an Agent. + public partial class BrowserAutomationAgentTool : AgentTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BrowserAutomationAgentTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrowserAutomationAgentTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("browser_automation_preview"u8); + writer.WriteObjectValue(BrowserAutomationPreview, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + BrowserAutomationAgentTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (BrowserAutomationAgentTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrowserAutomationAgentTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrowserAutomationAgentTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BrowserAutomationAgentTool DeserializeBrowserAutomationAgentTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + BrowserAutomationToolParameters browserAutomationPreview = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("browser_automation_preview"u8)) + { + browserAutomationPreview = BrowserAutomationToolParameters.DeserializeBrowserAutomationToolParameters(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BrowserAutomationAgentTool(@type, additionalBinaryDataProperties, browserAutomationPreview); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(BrowserAutomationAgentTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + BrowserAutomationAgentTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (BrowserAutomationAgentTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeBrowserAutomationAgentTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrowserAutomationAgentTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BrowserAutomationAgentTool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BrowserAutomationAgentTool.cs new file mode 100644 index 000000000000..ea0e64fdd671 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BrowserAutomationAgentTool.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// The input definition information for a Browser Automation Tool, as used to configure an Agent. + public partial class BrowserAutomationAgentTool : AgentTool + { + /// Initializes a new instance of . + /// The Browser Automation Tool parameters. + /// is null. + public BrowserAutomationAgentTool(BrowserAutomationToolParameters browserAutomationPreview) : base(ToolType.BrowserAutomationPreview) + { + Argument.AssertNotNull(browserAutomationPreview, nameof(browserAutomationPreview)); + + BrowserAutomationPreview = browserAutomationPreview; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The Browser Automation Tool parameters. + internal BrowserAutomationAgentTool(ToolType @type, IDictionary additionalBinaryDataProperties, BrowserAutomationToolParameters browserAutomationPreview) : base(@type, additionalBinaryDataProperties) + { + BrowserAutomationPreview = browserAutomationPreview; + } + + /// The Browser Automation Tool parameters. + public BrowserAutomationToolParameters BrowserAutomationPreview { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BrowserAutomationToolConnectionParameters.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BrowserAutomationToolConnectionParameters.Serialization.cs new file mode 100644 index 000000000000..f49bee98626d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BrowserAutomationToolConnectionParameters.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// Definition of input parameters for the connection used by the Browser Automation Tool. + public partial class BrowserAutomationToolConnectionParameters : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BrowserAutomationToolConnectionParameters() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrowserAutomationToolConnectionParameters)} does not support writing '{format}' format."); + } + writer.WritePropertyName("project_connection_id"u8); + writer.WriteStringValue(ProjectConnectionId); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + BrowserAutomationToolConnectionParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual BrowserAutomationToolConnectionParameters JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrowserAutomationToolConnectionParameters)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrowserAutomationToolConnectionParameters(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BrowserAutomationToolConnectionParameters DeserializeBrowserAutomationToolConnectionParameters(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string projectConnectionId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("project_connection_id"u8)) + { + projectConnectionId = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BrowserAutomationToolConnectionParameters(projectConnectionId, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(BrowserAutomationToolConnectionParameters)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + BrowserAutomationToolConnectionParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual BrowserAutomationToolConnectionParameters PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeBrowserAutomationToolConnectionParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrowserAutomationToolConnectionParameters)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BrowserAutomationToolConnectionParameters.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BrowserAutomationToolConnectionParameters.cs new file mode 100644 index 000000000000..81faec023a1f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BrowserAutomationToolConnectionParameters.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// Definition of input parameters for the connection used by the Browser Automation Tool. + public partial class BrowserAutomationToolConnectionParameters + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The ID of the project connection to your Azure Playwright resource. + /// is null. + public BrowserAutomationToolConnectionParameters(string projectConnectionId) + { + Argument.AssertNotNull(projectConnectionId, nameof(projectConnectionId)); + + ProjectConnectionId = projectConnectionId; + } + + /// Initializes a new instance of . + /// The ID of the project connection to your Azure Playwright resource. + /// Keeps track of any properties unknown to the library. + internal BrowserAutomationToolConnectionParameters(string projectConnectionId, IDictionary additionalBinaryDataProperties) + { + ProjectConnectionId = projectConnectionId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The ID of the project connection to your Azure Playwright resource. + public string ProjectConnectionId { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BrowserAutomationToolParameters.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BrowserAutomationToolParameters.Serialization.cs new file mode 100644 index 000000000000..c312b27c0d45 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BrowserAutomationToolParameters.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// Definition of input parameters for the Browser Automation Tool. + public partial class BrowserAutomationToolParameters : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BrowserAutomationToolParameters() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrowserAutomationToolParameters)} does not support writing '{format}' format."); + } + writer.WritePropertyName("connection"u8); + writer.WriteObjectValue(Connection, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + BrowserAutomationToolParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual BrowserAutomationToolParameters JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrowserAutomationToolParameters)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrowserAutomationToolParameters(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BrowserAutomationToolParameters DeserializeBrowserAutomationToolParameters(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BrowserAutomationToolConnectionParameters connection = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("connection"u8)) + { + connection = BrowserAutomationToolConnectionParameters.DeserializeBrowserAutomationToolConnectionParameters(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BrowserAutomationToolParameters(connection, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(BrowserAutomationToolParameters)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + BrowserAutomationToolParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual BrowserAutomationToolParameters PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeBrowserAutomationToolParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrowserAutomationToolParameters)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BrowserAutomationToolParameters.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BrowserAutomationToolParameters.cs new file mode 100644 index 000000000000..13f11fa74ab7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/BrowserAutomationToolParameters.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// Definition of input parameters for the Browser Automation Tool. + public partial class BrowserAutomationToolParameters + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The project connection parameters associated with the Browser Automation Tool. + /// is null. + public BrowserAutomationToolParameters(BrowserAutomationToolConnectionParameters connection) + { + Argument.AssertNotNull(connection, nameof(connection)); + + Connection = connection; + } + + /// Initializes a new instance of . + /// The project connection parameters associated with the Browser Automation Tool. + /// Keeps track of any properties unknown to the library. + internal BrowserAutomationToolParameters(BrowserAutomationToolConnectionParameters connection, IDictionary additionalBinaryDataProperties) + { + Connection = connection; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The project connection parameters associated with the Browser Automation Tool. + public BrowserAutomationToolConnectionParameters Connection { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/CaptureStructuredOutputsTool.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/CaptureStructuredOutputsTool.Serialization.cs new file mode 100644 index 000000000000..873ceb6ef323 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/CaptureStructuredOutputsTool.Serialization.cs @@ -0,0 +1,132 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// A tool for capturing structured outputs. + public partial class CaptureStructuredOutputsTool : AgentTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal CaptureStructuredOutputsTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CaptureStructuredOutputsTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("outputs"u8); + writer.WriteObjectValue(Outputs, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + CaptureStructuredOutputsTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (CaptureStructuredOutputsTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CaptureStructuredOutputsTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCaptureStructuredOutputsTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static CaptureStructuredOutputsTool DeserializeCaptureStructuredOutputsTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + StructuredOutputDefinition outputs = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("outputs"u8)) + { + outputs = StructuredOutputDefinition.DeserializeStructuredOutputDefinition(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new CaptureStructuredOutputsTool(@type, additionalBinaryDataProperties, outputs); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(CaptureStructuredOutputsTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + CaptureStructuredOutputsTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (CaptureStructuredOutputsTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeCaptureStructuredOutputsTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CaptureStructuredOutputsTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/CaptureStructuredOutputsTool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/CaptureStructuredOutputsTool.cs new file mode 100644 index 000000000000..151d48bd4178 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/CaptureStructuredOutputsTool.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// A tool for capturing structured outputs. + public partial class CaptureStructuredOutputsTool : AgentTool + { + /// Initializes a new instance of . + /// The structured outputs to capture from the model. + /// is null. + public CaptureStructuredOutputsTool(StructuredOutputDefinition outputs) : base(ToolType.CaptureStructuredOutputs) + { + Argument.AssertNotNull(outputs, nameof(outputs)); + + Outputs = outputs; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The structured outputs to capture from the model. + internal CaptureStructuredOutputsTool(ToolType @type, IDictionary additionalBinaryDataProperties, StructuredOutputDefinition outputs) : base(@type, additionalBinaryDataProperties) + { + Outputs = outputs; + } + + /// The structured outputs to capture from the model. + public StructuredOutputDefinition Outputs { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ChatSummaryMemoryItem.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ChatSummaryMemoryItem.Serialization.cs new file mode 100644 index 000000000000..6d120196ab5a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ChatSummaryMemoryItem.Serialization.cs @@ -0,0 +1,153 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// A memory item containing a summary extracted from conversations. + public partial class ChatSummaryMemoryItem : MemoryItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ChatSummaryMemoryItem() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ChatSummaryMemoryItem)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + ChatSummaryMemoryItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (ChatSummaryMemoryItem)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override MemoryItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ChatSummaryMemoryItem)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatSummaryMemoryItem(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ChatSummaryMemoryItem DeserializeChatSummaryMemoryItem(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string memoryId = default; + DateTimeOffset updatedAt = default; + string scope = default; + string content = default; + MemoryItemKind kind = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("memory_id"u8)) + { + memoryId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("updated_at"u8)) + { + updatedAt = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64()); + continue; + } + if (prop.NameEquals("scope"u8)) + { + scope = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("content"u8)) + { + content = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("kind"u8)) + { + kind = new MemoryItemKind(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ChatSummaryMemoryItem( + memoryId, + updatedAt, + scope, + content, + kind, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(ChatSummaryMemoryItem)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ChatSummaryMemoryItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (ChatSummaryMemoryItem)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override MemoryItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeChatSummaryMemoryItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatSummaryMemoryItem)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ChatSummaryMemoryItem.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ChatSummaryMemoryItem.cs new file mode 100644 index 000000000000..1f3ab3096f51 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ChatSummaryMemoryItem.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// A memory item containing a summary extracted from conversations. + public partial class ChatSummaryMemoryItem : MemoryItem + { + /// Initializes a new instance of . + /// The unique ID of the memory item. + /// The last update time of the memory item. + /// The namespace that logically groups and isolates memories, such as a user ID. + /// The content of the memory. + /// , or is null. + public ChatSummaryMemoryItem(string memoryId, DateTimeOffset updatedAt, string scope, string content) : base(memoryId, updatedAt, scope, content, MemoryItemKind.ChatSummary) + { + Argument.AssertNotNull(memoryId, nameof(memoryId)); + Argument.AssertNotNull(scope, nameof(scope)); + Argument.AssertNotNull(content, nameof(content)); + + } + + /// Initializes a new instance of . + /// The unique ID of the memory item. + /// The last update time of the memory item. + /// The namespace that logically groups and isolates memories, such as a user ID. + /// The content of the memory. + /// The kind of the memory item. + /// Keeps track of any properties unknown to the library. + internal ChatSummaryMemoryItem(string memoryId, DateTimeOffset updatedAt, string scope, string content, MemoryItemKind kind, IDictionary additionalBinaryDataProperties) : base(memoryId, updatedAt, scope, content, kind, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/CodeInterpreterOutputType.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/CodeInterpreterOutputType.Serialization.cs new file mode 100644 index 000000000000..7135b4f06aa0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/CodeInterpreterOutputType.Serialization.cs @@ -0,0 +1,33 @@ +// + +#nullable disable + +using System; + +namespace OpenAI +{ + internal static partial class CodeInterpreterOutputTypeExtensions + { + /// The value to serialize. + public static string ToSerialString(this CodeInterpreterOutputType value) => value switch + { + CodeInterpreterOutputType.Logs => "logs", + CodeInterpreterOutputType.Image => "image", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown CodeInterpreterOutputType value.") + }; + + /// The value to deserialize. + public static CodeInterpreterOutputType ToCodeInterpreterOutputType(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "logs")) + { + return CodeInterpreterOutputType.Logs; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "image")) + { + return CodeInterpreterOutputType.Image; + } + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown CodeInterpreterOutputType value."); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/CodeInterpreterOutputType.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/CodeInterpreterOutputType.cs new file mode 100644 index 000000000000..248d68672c81 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/CodeInterpreterOutputType.cs @@ -0,0 +1,15 @@ +// + +#nullable disable + +namespace OpenAI +{ + /// + internal enum CodeInterpreterOutputType + { + /// Logs. + Logs, + /// Image. + Image + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/CodeInterpreterToolCallItemResourceStatus.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/CodeInterpreterToolCallItemResourceStatus.cs new file mode 100644 index 000000000000..66f4c30a195b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/CodeInterpreterToolCallItemResourceStatus.cs @@ -0,0 +1,77 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct CodeInterpreterToolCallItemResourceStatus : IEquatable + { + private readonly string _value; + private const string InProgressValue = "in_progress"; + private const string CompletedValue = "completed"; + private const string IncompleteValue = "incomplete"; + private const string InterpretingValue = "interpreting"; + private const string FailedValue = "failed"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public CodeInterpreterToolCallItemResourceStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the InProgress. + public static CodeInterpreterToolCallItemResourceStatus InProgress { get; } = new CodeInterpreterToolCallItemResourceStatus(InProgressValue); + + /// Gets the Completed. + public static CodeInterpreterToolCallItemResourceStatus Completed { get; } = new CodeInterpreterToolCallItemResourceStatus(CompletedValue); + + /// Gets the Incomplete. + public static CodeInterpreterToolCallItemResourceStatus Incomplete { get; } = new CodeInterpreterToolCallItemResourceStatus(IncompleteValue); + + /// Gets the Interpreting. + public static CodeInterpreterToolCallItemResourceStatus Interpreting { get; } = new CodeInterpreterToolCallItemResourceStatus(InterpretingValue); + + /// Gets the Failed. + public static CodeInterpreterToolCallItemResourceStatus Failed { get; } = new CodeInterpreterToolCallItemResourceStatus(FailedValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(CodeInterpreterToolCallItemResourceStatus left, CodeInterpreterToolCallItemResourceStatus right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(CodeInterpreterToolCallItemResourceStatus left, CodeInterpreterToolCallItemResourceStatus right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator CodeInterpreterToolCallItemResourceStatus(string value) => new CodeInterpreterToolCallItemResourceStatus(value); + + /// Converts a string to a . + /// The value. + public static implicit operator CodeInterpreterToolCallItemResourceStatus?(string value) => value == null ? null : new CodeInterpreterToolCallItemResourceStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CodeInterpreterToolCallItemResourceStatus other && Equals(other); + + /// + public bool Equals(CodeInterpreterToolCallItemResourceStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ComparisonFilterType.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ComparisonFilterType.cs new file mode 100644 index 000000000000..501a02b8cae0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ComparisonFilterType.cs @@ -0,0 +1,81 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct ComparisonFilterType : IEquatable + { + private readonly string _value; + private const string EqValue = "eq"; + private const string NeValue = "ne"; + private const string GtValue = "gt"; + private const string GteValue = "gte"; + private const string LtValue = "lt"; + private const string LteValue = "lte"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ComparisonFilterType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Eq. + public static ComparisonFilterType Eq { get; } = new ComparisonFilterType(EqValue); + + /// Gets the Ne. + public static ComparisonFilterType Ne { get; } = new ComparisonFilterType(NeValue); + + /// Gets the Gt. + public static ComparisonFilterType Gt { get; } = new ComparisonFilterType(GtValue); + + /// Gets the Gte. + public static ComparisonFilterType Gte { get; } = new ComparisonFilterType(GteValue); + + /// Gets the Lt. + public static ComparisonFilterType Lt { get; } = new ComparisonFilterType(LtValue); + + /// Gets the Lte. + public static ComparisonFilterType Lte { get; } = new ComparisonFilterType(LteValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ComparisonFilterType left, ComparisonFilterType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ComparisonFilterType left, ComparisonFilterType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ComparisonFilterType(string value) => new ComparisonFilterType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ComparisonFilterType?(string value) => value == null ? null : new ComparisonFilterType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ComparisonFilterType other && Equals(other); + + /// + public bool Equals(ComparisonFilterType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/CompoundFilterType.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/CompoundFilterType.cs new file mode 100644 index 000000000000..f8d88edfcc6d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/CompoundFilterType.cs @@ -0,0 +1,65 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct CompoundFilterType : IEquatable + { + private readonly string _value; + private const string AndValue = "and"; + private const string OrValue = "or"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public CompoundFilterType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the And. + public static CompoundFilterType And { get; } = new CompoundFilterType(AndValue); + + /// Gets the Or. + public static CompoundFilterType Or { get; } = new CompoundFilterType(OrValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(CompoundFilterType left, CompoundFilterType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(CompoundFilterType left, CompoundFilterType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator CompoundFilterType(string value) => new CompoundFilterType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator CompoundFilterType?(string value) => value == null ? null : new CompoundFilterType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CompoundFilterType other && Equals(other); + + /// + public bool Equals(CompoundFilterType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ComputerActionClickButton.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ComputerActionClickButton.cs new file mode 100644 index 000000000000..a9a88f0e4f9e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ComputerActionClickButton.cs @@ -0,0 +1,77 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct ComputerActionClickButton : IEquatable + { + private readonly string _value; + private const string LeftValue = "left"; + private const string RightValue = "right"; + private const string WheelValue = "wheel"; + private const string BackValue = "back"; + private const string ForwardValue = "forward"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ComputerActionClickButton(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Left. + public static ComputerActionClickButton Left { get; } = new ComputerActionClickButton(LeftValue); + + /// Gets the Right. + public static ComputerActionClickButton Right { get; } = new ComputerActionClickButton(RightValue); + + /// Gets the Wheel. + public static ComputerActionClickButton Wheel { get; } = new ComputerActionClickButton(WheelValue); + + /// Gets the Back. + public static ComputerActionClickButton Back { get; } = new ComputerActionClickButton(BackValue); + + /// Gets the Forward. + public static ComputerActionClickButton Forward { get; } = new ComputerActionClickButton(ForwardValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ComputerActionClickButton left, ComputerActionClickButton right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ComputerActionClickButton left, ComputerActionClickButton right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ComputerActionClickButton(string value) => new ComputerActionClickButton(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ComputerActionClickButton?(string value) => value == null ? null : new ComputerActionClickButton(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ComputerActionClickButton other && Equals(other); + + /// + public bool Equals(ComputerActionClickButton other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ComputerActionType.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ComputerActionType.Serialization.cs new file mode 100644 index 000000000000..7d8320c8f191 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ComputerActionType.Serialization.cs @@ -0,0 +1,68 @@ +// + +#nullable disable + +using System; + +namespace OpenAI +{ + internal static partial class ComputerActionTypeExtensions + { + /// The value to serialize. + public static string ToSerialString(this ComputerActionType value) => value switch + { + ComputerActionType.Screenshot => "screenshot", + ComputerActionType.Click => "click", + ComputerActionType.DoubleClick => "double_click", + ComputerActionType.Scroll => "scroll", + ComputerActionType.Type => "type", + ComputerActionType.Wait => "wait", + ComputerActionType.Keypress => "keypress", + ComputerActionType.Drag => "drag", + ComputerActionType.Move => "move", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ComputerActionType value.") + }; + + /// The value to deserialize. + public static ComputerActionType ToComputerActionType(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "screenshot")) + { + return ComputerActionType.Screenshot; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "click")) + { + return ComputerActionType.Click; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "double_click")) + { + return ComputerActionType.DoubleClick; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "scroll")) + { + return ComputerActionType.Scroll; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "type")) + { + return ComputerActionType.Type; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "wait")) + { + return ComputerActionType.Wait; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "keypress")) + { + return ComputerActionType.Keypress; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "drag")) + { + return ComputerActionType.Drag; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "move")) + { + return ComputerActionType.Move; + } + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ComputerActionType value."); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ComputerActionType.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ComputerActionType.cs new file mode 100644 index 000000000000..658b1f92b8c2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ComputerActionType.cs @@ -0,0 +1,29 @@ +// + +#nullable disable + +namespace OpenAI +{ + /// + internal enum ComputerActionType + { + /// Screenshot. + Screenshot, + /// Click. + Click, + /// DoubleClick. + DoubleClick, + /// Scroll. + Scroll, + /// Type. + Type, + /// Wait. + Wait, + /// Keypress. + Keypress, + /// Drag. + Drag, + /// Move. + Move + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ComputerToolCallItemResourceStatus.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ComputerToolCallItemResourceStatus.cs new file mode 100644 index 000000000000..2ea352b2a11f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ComputerToolCallItemResourceStatus.cs @@ -0,0 +1,69 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct ComputerToolCallItemResourceStatus : IEquatable + { + private readonly string _value; + private const string InProgressValue = "in_progress"; + private const string CompletedValue = "completed"; + private const string IncompleteValue = "incomplete"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ComputerToolCallItemResourceStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the InProgress. + public static ComputerToolCallItemResourceStatus InProgress { get; } = new ComputerToolCallItemResourceStatus(InProgressValue); + + /// Gets the Completed. + public static ComputerToolCallItemResourceStatus Completed { get; } = new ComputerToolCallItemResourceStatus(CompletedValue); + + /// Gets the Incomplete. + public static ComputerToolCallItemResourceStatus Incomplete { get; } = new ComputerToolCallItemResourceStatus(IncompleteValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ComputerToolCallItemResourceStatus left, ComputerToolCallItemResourceStatus right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ComputerToolCallItemResourceStatus left, ComputerToolCallItemResourceStatus right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ComputerToolCallItemResourceStatus(string value) => new ComputerToolCallItemResourceStatus(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ComputerToolCallItemResourceStatus?(string value) => value == null ? null : new ComputerToolCallItemResourceStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ComputerToolCallItemResourceStatus other && Equals(other); + + /// + public bool Equals(ComputerToolCallItemResourceStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ComputerToolCallOutputItemOutputType.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ComputerToolCallOutputItemOutputType.cs new file mode 100644 index 000000000000..3e96ec4d4802 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ComputerToolCallOutputItemOutputType.cs @@ -0,0 +1,62 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + /// A computer screenshot image used with the computer use tool. + internal readonly partial struct ComputerToolCallOutputItemOutputType : IEquatable + { + private readonly string _value; + private const string ScreenshotValue = "computer_screenshot"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ComputerToolCallOutputItemOutputType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Screenshot. + public static ComputerToolCallOutputItemOutputType Screenshot { get; } = new ComputerToolCallOutputItemOutputType(ScreenshotValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ComputerToolCallOutputItemOutputType left, ComputerToolCallOutputItemOutputType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ComputerToolCallOutputItemOutputType left, ComputerToolCallOutputItemOutputType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ComputerToolCallOutputItemOutputType(string value) => new ComputerToolCallOutputItemOutputType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ComputerToolCallOutputItemOutputType?(string value) => value == null ? null : new ComputerToolCallOutputItemOutputType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ComputerToolCallOutputItemOutputType other && Equals(other); + + /// + public bool Equals(ComputerToolCallOutputItemOutputType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ComputerToolCallOutputItemResourceStatus.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ComputerToolCallOutputItemResourceStatus.cs new file mode 100644 index 000000000000..e6f5a58fc748 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ComputerToolCallOutputItemResourceStatus.cs @@ -0,0 +1,69 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct ComputerToolCallOutputItemResourceStatus : IEquatable + { + private readonly string _value; + private const string InProgressValue = "in_progress"; + private const string CompletedValue = "completed"; + private const string IncompleteValue = "incomplete"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ComputerToolCallOutputItemResourceStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the InProgress. + public static ComputerToolCallOutputItemResourceStatus InProgress { get; } = new ComputerToolCallOutputItemResourceStatus(InProgressValue); + + /// Gets the Completed. + public static ComputerToolCallOutputItemResourceStatus Completed { get; } = new ComputerToolCallOutputItemResourceStatus(CompletedValue); + + /// Gets the Incomplete. + public static ComputerToolCallOutputItemResourceStatus Incomplete { get; } = new ComputerToolCallOutputItemResourceStatus(IncompleteValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ComputerToolCallOutputItemResourceStatus left, ComputerToolCallOutputItemResourceStatus right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ComputerToolCallOutputItemResourceStatus left, ComputerToolCallOutputItemResourceStatus right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ComputerToolCallOutputItemResourceStatus(string value) => new ComputerToolCallOutputItemResourceStatus(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ComputerToolCallOutputItemResourceStatus?(string value) => value == null ? null : new ComputerToolCallOutputItemResourceStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ComputerToolCallOutputItemResourceStatus other && Equals(other); + + /// + public bool Equals(ComputerToolCallOutputItemResourceStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ComputerUsePreviewToolEnvironment.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ComputerUsePreviewToolEnvironment.cs new file mode 100644 index 000000000000..c8e454168b20 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ComputerUsePreviewToolEnvironment.cs @@ -0,0 +1,77 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct ComputerUsePreviewToolEnvironment : IEquatable + { + private readonly string _value; + private const string WindowsValue = "windows"; + private const string MacValue = "mac"; + private const string LinuxValue = "linux"; + private const string UbuntuValue = "ubuntu"; + private const string BrowserValue = "browser"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ComputerUsePreviewToolEnvironment(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Windows. + public static ComputerUsePreviewToolEnvironment Windows { get; } = new ComputerUsePreviewToolEnvironment(WindowsValue); + + /// Gets the Mac. + public static ComputerUsePreviewToolEnvironment Mac { get; } = new ComputerUsePreviewToolEnvironment(MacValue); + + /// Gets the Linux. + public static ComputerUsePreviewToolEnvironment Linux { get; } = new ComputerUsePreviewToolEnvironment(LinuxValue); + + /// Gets the Ubuntu. + public static ComputerUsePreviewToolEnvironment Ubuntu { get; } = new ComputerUsePreviewToolEnvironment(UbuntuValue); + + /// Gets the Browser. + public static ComputerUsePreviewToolEnvironment Browser { get; } = new ComputerUsePreviewToolEnvironment(BrowserValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ComputerUsePreviewToolEnvironment left, ComputerUsePreviewToolEnvironment right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ComputerUsePreviewToolEnvironment left, ComputerUsePreviewToolEnvironment right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ComputerUsePreviewToolEnvironment(string value) => new ComputerUsePreviewToolEnvironment(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ComputerUsePreviewToolEnvironment?(string value) => value == null ? null : new ComputerUsePreviewToolEnvironment(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ComputerUsePreviewToolEnvironment other && Equals(other); + + /// + public bool Equals(ComputerUsePreviewToolEnvironment other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ContainerApplicationAgentDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ContainerApplicationAgentDefinition.Serialization.cs new file mode 100644 index 000000000000..3ab89e27276a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ContainerApplicationAgentDefinition.Serialization.cs @@ -0,0 +1,173 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The container app agent definition. + public partial class ContainerApplicationAgentDefinition : AgentDefinition, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ContainerApplicationAgentDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ContainerApplicationAgentDefinition)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("container_protocol_versions"u8); + writer.WriteStartArray(); + foreach (ProtocolVersionRecord item in ContainerProtocolVersions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + writer.WritePropertyName("container_app_resource_id"u8); + writer.WriteStringValue(ContainerAppResourceId); + writer.WritePropertyName("ingress_subdomain_suffix"u8); + writer.WriteStringValue(IngressSubdomainSuffix); + } + + /// The JSON reader. + /// The client options for reading and writing models. + ContainerApplicationAgentDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (ContainerApplicationAgentDefinition)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ContainerApplicationAgentDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeContainerApplicationAgentDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ContainerApplicationAgentDefinition DeserializeContainerApplicationAgentDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentKind kind = default; + ContentFilterConfiguration contentFilterConfiguration = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList containerProtocolVersions = default; + string containerAppResourceId = default; + string ingressSubdomainSuffix = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("kind"u8)) + { + kind = new AgentKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("rai_config"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + contentFilterConfiguration = ContentFilterConfiguration.DeserializeContentFilterConfiguration(prop.Value, options); + continue; + } + if (prop.NameEquals("container_protocol_versions"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ProtocolVersionRecord.DeserializeProtocolVersionRecord(item, options)); + } + containerProtocolVersions = array; + continue; + } + if (prop.NameEquals("container_app_resource_id"u8)) + { + containerAppResourceId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("ingress_subdomain_suffix"u8)) + { + ingressSubdomainSuffix = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ContainerApplicationAgentDefinition( + kind, + contentFilterConfiguration, + additionalBinaryDataProperties, + containerProtocolVersions, + containerAppResourceId, + ingressSubdomainSuffix); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(ContainerApplicationAgentDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ContainerApplicationAgentDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (ContainerApplicationAgentDefinition)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeContainerApplicationAgentDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ContainerApplicationAgentDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ContainerApplicationAgentDefinition.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ContainerApplicationAgentDefinition.cs new file mode 100644 index 000000000000..de7838feb378 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ContainerApplicationAgentDefinition.cs @@ -0,0 +1,53 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects.OpenAI +{ + /// The container app agent definition. + public partial class ContainerApplicationAgentDefinition : AgentDefinition + { + /// Initializes a new instance of . + /// The protocols that the agent supports for ingress communication of the containers. + /// The resource ID of the Azure Container App that hosts this agent. Not mutable across versions. + /// The suffix to apply to the app subdomain when sending ingress to the agent. This can be a label (e.g., '---current'), a specific revision (e.g., '--0000001'), or empty to use the default endpoint for the container app. + /// , or is null. + public ContainerApplicationAgentDefinition(IEnumerable containerProtocolVersions, string containerAppResourceId, string ingressSubdomainSuffix) : base(AgentKind.ContainerApp) + { + Argument.AssertNotNull(containerProtocolVersions, nameof(containerProtocolVersions)); + Argument.AssertNotNull(containerAppResourceId, nameof(containerAppResourceId)); + Argument.AssertNotNull(ingressSubdomainSuffix, nameof(ingressSubdomainSuffix)); + + ContainerProtocolVersions = containerProtocolVersions.ToList(); + ContainerAppResourceId = containerAppResourceId; + IngressSubdomainSuffix = ingressSubdomainSuffix; + } + + /// Initializes a new instance of . + /// + /// Configuration for Responsible AI (RAI) content filtering and safety features. + /// Keeps track of any properties unknown to the library. + /// The protocols that the agent supports for ingress communication of the containers. + /// The resource ID of the Azure Container App that hosts this agent. Not mutable across versions. + /// The suffix to apply to the app subdomain when sending ingress to the agent. This can be a label (e.g., '---current'), a specific revision (e.g., '--0000001'), or empty to use the default endpoint for the container app. + internal ContainerApplicationAgentDefinition(AgentKind kind, ContentFilterConfiguration contentFilterConfiguration, IDictionary additionalBinaryDataProperties, IList containerProtocolVersions, string containerAppResourceId, string ingressSubdomainSuffix) : base(kind, contentFilterConfiguration, additionalBinaryDataProperties) + { + ContainerProtocolVersions = containerProtocolVersions; + ContainerAppResourceId = containerAppResourceId; + IngressSubdomainSuffix = ingressSubdomainSuffix; + } + + /// The protocols that the agent supports for ingress communication of the containers. + public IList ContainerProtocolVersions { get; } + + /// The resource ID of the Azure Container App that hosts this agent. Not mutable across versions. + public string ContainerAppResourceId { get; set; } + + /// The suffix to apply to the app subdomain when sending ingress to the agent. This can be a label (e.g., '---current'), a specific revision (e.g., '--0000001'), or empty to use the default endpoint for the container app. + public string IngressSubdomainSuffix { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ContentFilterConfiguration.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ContentFilterConfiguration.Serialization.cs new file mode 100644 index 000000000000..b286c52480a5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ContentFilterConfiguration.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// Configuration for Responsible AI (RAI) content filtering and safety features. + public partial class ContentFilterConfiguration : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ContentFilterConfiguration() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ContentFilterConfiguration)} does not support writing '{format}' format."); + } + writer.WritePropertyName("rai_policy_name"u8); + writer.WriteStringValue(PolicyName); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ContentFilterConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ContentFilterConfiguration JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ContentFilterConfiguration)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeContentFilterConfiguration(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ContentFilterConfiguration DeserializeContentFilterConfiguration(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string policyName = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("rai_policy_name"u8)) + { + policyName = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ContentFilterConfiguration(policyName, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(ContentFilterConfiguration)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ContentFilterConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ContentFilterConfiguration PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeContentFilterConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ContentFilterConfiguration)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ContentFilterConfiguration.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ContentFilterConfiguration.cs new file mode 100644 index 000000000000..afbf390bfeda --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ContentFilterConfiguration.cs @@ -0,0 +1,25 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// Configuration for Responsible AI (RAI) content filtering and safety features. + public partial class ContentFilterConfiguration + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The name of the RAI policy to apply. + /// Keeps track of any properties unknown to the library. + internal ContentFilterConfiguration(string policyName, IDictionary additionalBinaryDataProperties) + { + PolicyName = policyName; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/FabricDataAgentToolOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/FabricDataAgentToolOptions.Serialization.cs new file mode 100644 index 000000000000..57f2bd8b03ba --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/FabricDataAgentToolOptions.Serialization.cs @@ -0,0 +1,151 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The fabric data agent tool parameters. + public partial class FabricDataAgentToolOptions : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FabricDataAgentToolOptions)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(ProjectConnections)) + { + writer.WritePropertyName("project_connections"u8); + writer.WriteStartArray(); + foreach (ToolProjectConnection item in ProjectConnections) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + FabricDataAgentToolOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual FabricDataAgentToolOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FabricDataAgentToolOptions)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFabricDataAgentToolOptions(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static FabricDataAgentToolOptions DeserializeFabricDataAgentToolOptions(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList projectConnections = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("project_connections"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ToolProjectConnection.DeserializeToolProjectConnection(item, options)); + } + projectConnections = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new FabricDataAgentToolOptions(projectConnections ?? new ChangeTrackingList(), additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(FabricDataAgentToolOptions)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + FabricDataAgentToolOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual FabricDataAgentToolOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeFabricDataAgentToolOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FabricDataAgentToolOptions)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/FabricDataAgentToolOptions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/FabricDataAgentToolOptions.cs new file mode 100644 index 000000000000..3aeae0ea56dd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/FabricDataAgentToolOptions.cs @@ -0,0 +1,40 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// The fabric data agent tool parameters. + public partial class FabricDataAgentToolOptions + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public FabricDataAgentToolOptions() + { + ProjectConnections = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// The project connections attached to this tool. There can be a maximum of 1 connection + /// resource attached to the tool. + /// + /// Keeps track of any properties unknown to the library. + internal FabricDataAgentToolOptions(IList projectConnections, IDictionary additionalBinaryDataProperties) + { + ProjectConnections = projectConnections; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// The project connections attached to this tool. There can be a maximum of 1 connection + /// resource attached to the tool. + /// + public IList ProjectConnections { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/FileSearchToolCallItemResourceStatus.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/FileSearchToolCallItemResourceStatus.cs new file mode 100644 index 000000000000..aa3bed4e7b37 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/FileSearchToolCallItemResourceStatus.cs @@ -0,0 +1,77 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct FileSearchToolCallItemResourceStatus : IEquatable + { + private readonly string _value; + private const string InProgressValue = "in_progress"; + private const string SearchingValue = "searching"; + private const string CompletedValue = "completed"; + private const string IncompleteValue = "incomplete"; + private const string FailedValue = "failed"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public FileSearchToolCallItemResourceStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the InProgress. + public static FileSearchToolCallItemResourceStatus InProgress { get; } = new FileSearchToolCallItemResourceStatus(InProgressValue); + + /// Gets the Searching. + public static FileSearchToolCallItemResourceStatus Searching { get; } = new FileSearchToolCallItemResourceStatus(SearchingValue); + + /// Gets the Completed. + public static FileSearchToolCallItemResourceStatus Completed { get; } = new FileSearchToolCallItemResourceStatus(CompletedValue); + + /// Gets the Incomplete. + public static FileSearchToolCallItemResourceStatus Incomplete { get; } = new FileSearchToolCallItemResourceStatus(IncompleteValue); + + /// Gets the Failed. + public static FileSearchToolCallItemResourceStatus Failed { get; } = new FileSearchToolCallItemResourceStatus(FailedValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(FileSearchToolCallItemResourceStatus left, FileSearchToolCallItemResourceStatus right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(FileSearchToolCallItemResourceStatus left, FileSearchToolCallItemResourceStatus right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator FileSearchToolCallItemResourceStatus(string value) => new FileSearchToolCallItemResourceStatus(value); + + /// Converts a string to a . + /// The value. + public static implicit operator FileSearchToolCallItemResourceStatus?(string value) => value == null ? null : new FileSearchToolCallItemResourceStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is FileSearchToolCallItemResourceStatus other && Equals(other); + + /// + public bool Equals(FileSearchToolCallItemResourceStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/FoundryOpenAIError.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/FoundryOpenAIError.Serialization.cs new file mode 100644 index 000000000000..ff02ac9be9b4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/FoundryOpenAIError.Serialization.cs @@ -0,0 +1,309 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + internal partial class FoundryOpenAIError : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal FoundryOpenAIError() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FoundryOpenAIError)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Code)) + { + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code); + } + else + { + writer.WriteNull("code"u8); + } + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + if (Optional.IsDefined(Param)) + { + writer.WritePropertyName("param"u8); + writer.WriteStringValue(Param); + } + else + { + writer.WriteNull("param"u8); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (Optional.IsCollectionDefined(Details)) + { + writer.WritePropertyName("details"u8); + writer.WriteStartArray(); + foreach (FoundryOpenAIError item in Details) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(AdditionalInfo)) + { + writer.WritePropertyName("additionalInfo"u8); + writer.WriteStartObject(); + foreach (var item in AdditionalInfo) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#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(); + } + if (Optional.IsCollectionDefined(DebugInfo)) + { + writer.WritePropertyName("debugInfo"u8); + writer.WriteStartObject(); + foreach (var item in DebugInfo) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#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(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + FoundryOpenAIError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual FoundryOpenAIError JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FoundryOpenAIError)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFoundryOpenAIError(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static FoundryOpenAIError DeserializeFoundryOpenAIError(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string code = default; + string message = default; + string @param = default; + string @type = default; + IList details = default; + IDictionary additionalInfo = default; + IDictionary debugInfo = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("code"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + code = null; + continue; + } + code = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("message"u8)) + { + message = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("param"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + @param = null; + continue; + } + @param = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("details"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(DeserializeFoundryOpenAIError(item, options)); + } + details = array; + continue; + } + if (prop.NameEquals("additionalInfo"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + additionalInfo = dictionary; + continue; + } + if (prop.NameEquals("debugInfo"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + debugInfo = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new FoundryOpenAIError( + code, + message, + @param, + @type, + details ?? new ChangeTrackingList(), + additionalInfo ?? new ChangeTrackingDictionary(), + debugInfo ?? new ChangeTrackingDictionary(), + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(FoundryOpenAIError)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + FoundryOpenAIError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual FoundryOpenAIError PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeFoundryOpenAIError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FoundryOpenAIError)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/FoundryOpenAIError.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/FoundryOpenAIError.cs new file mode 100644 index 000000000000..cbce61cecde0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/FoundryOpenAIError.cs @@ -0,0 +1,124 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + internal partial class FoundryOpenAIError + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// + /// + /// + internal FoundryOpenAIError(string code, string message, string @param, string @type) + { + Code = code; + Message = message; + Param = @param; + Type = @type; + Details = new ChangeTrackingList(); + AdditionalInfo = new ChangeTrackingDictionary(); + DebugInfo = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// + /// + /// + /// + /// + /// + /// + /// Keeps track of any properties unknown to the library. + internal FoundryOpenAIError(string code, string message, string @param, string @type, IList details, IDictionary additionalInfo, IDictionary debugInfo, IDictionary additionalBinaryDataProperties) + { + Code = code; + Message = message; + Param = @param; + Type = @type; + Details = details; + AdditionalInfo = additionalInfo; + DebugInfo = debugInfo; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Code. + public string Code { get; } + + /// Gets the Message. + public string Message { get; } + + /// Gets the Param. + public string Param { get; } + + /// Gets the Type. + public string Type { get; } + + /// Gets the Details. + public IList Details { get; } + + /// + /// Gets the AdditionalInfo. + /// 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" }. + /// + /// + /// + /// + public IDictionary AdditionalInfo { get; } + + /// + /// Gets the DebugInfo. + /// 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" }. + /// + /// + /// + /// + public IDictionary DebugInfo { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/FunctionToolCallItemResourceStatus.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/FunctionToolCallItemResourceStatus.cs new file mode 100644 index 000000000000..693f94c1ce0b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/FunctionToolCallItemResourceStatus.cs @@ -0,0 +1,69 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct FunctionToolCallItemResourceStatus : IEquatable + { + private readonly string _value; + private const string InProgressValue = "in_progress"; + private const string CompletedValue = "completed"; + private const string IncompleteValue = "incomplete"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public FunctionToolCallItemResourceStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the InProgress. + public static FunctionToolCallItemResourceStatus InProgress { get; } = new FunctionToolCallItemResourceStatus(InProgressValue); + + /// Gets the Completed. + public static FunctionToolCallItemResourceStatus Completed { get; } = new FunctionToolCallItemResourceStatus(CompletedValue); + + /// Gets the Incomplete. + public static FunctionToolCallItemResourceStatus Incomplete { get; } = new FunctionToolCallItemResourceStatus(IncompleteValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(FunctionToolCallItemResourceStatus left, FunctionToolCallItemResourceStatus right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(FunctionToolCallItemResourceStatus left, FunctionToolCallItemResourceStatus right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator FunctionToolCallItemResourceStatus(string value) => new FunctionToolCallItemResourceStatus(value); + + /// Converts a string to a . + /// The value. + public static implicit operator FunctionToolCallItemResourceStatus?(string value) => value == null ? null : new FunctionToolCallItemResourceStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is FunctionToolCallItemResourceStatus other && Equals(other); + + /// + public bool Equals(FunctionToolCallItemResourceStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/FunctionToolCallOutputItemResourceStatus.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/FunctionToolCallOutputItemResourceStatus.cs new file mode 100644 index 000000000000..cccfa402b8a7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/FunctionToolCallOutputItemResourceStatus.cs @@ -0,0 +1,69 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct FunctionToolCallOutputItemResourceStatus : IEquatable + { + private readonly string _value; + private const string InProgressValue = "in_progress"; + private const string CompletedValue = "completed"; + private const string IncompleteValue = "incomplete"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public FunctionToolCallOutputItemResourceStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the InProgress. + public static FunctionToolCallOutputItemResourceStatus InProgress { get; } = new FunctionToolCallOutputItemResourceStatus(InProgressValue); + + /// Gets the Completed. + public static FunctionToolCallOutputItemResourceStatus Completed { get; } = new FunctionToolCallOutputItemResourceStatus(CompletedValue); + + /// Gets the Incomplete. + public static FunctionToolCallOutputItemResourceStatus Incomplete { get; } = new FunctionToolCallOutputItemResourceStatus(IncompleteValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(FunctionToolCallOutputItemResourceStatus left, FunctionToolCallOutputItemResourceStatus right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(FunctionToolCallOutputItemResourceStatus left, FunctionToolCallOutputItemResourceStatus right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator FunctionToolCallOutputItemResourceStatus(string value) => new FunctionToolCallOutputItemResourceStatus(value); + + /// Converts a string to a . + /// The value. + public static implicit operator FunctionToolCallOutputItemResourceStatus?(string value) => value == null ? null : new FunctionToolCallOutputItemResourceStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is FunctionToolCallOutputItemResourceStatus other && Equals(other); + + /// + public bool Equals(FunctionToolCallOutputItemResourceStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/HostedAgentDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/HostedAgentDefinition.Serialization.cs new file mode 100644 index 000000000000..ff613eb5a047 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/HostedAgentDefinition.Serialization.cs @@ -0,0 +1,145 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The hosted agent definition. + public partial class HostedAgentDefinition : AgentDefinition, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal HostedAgentDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(HostedAgentDefinition)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsCollectionDefined(Tools)) + { + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (AgentTool item in Tools) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + writer.WritePropertyName("container_protocol_versions"u8); + writer.WriteStartArray(); + foreach (ProtocolVersionRecord item in ContainerProtocolVersions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + writer.WritePropertyName("cpu"u8); + writer.WriteStringValue(Cpu); + writer.WritePropertyName("memory"u8); + writer.WriteStringValue(Memory); + if (Optional.IsCollectionDefined(EnvironmentVariables)) + { + writer.WritePropertyName("environment_variables"u8); + writer.WriteStartObject(); + foreach (var item in EnvironmentVariables) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + HostedAgentDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (HostedAgentDefinition)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(HostedAgentDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeHostedAgentDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static HostedAgentDefinition DeserializeHostedAgentDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + return UnknownHostedAgentDefinition.DeserializeUnknownHostedAgentDefinition(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(HostedAgentDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + HostedAgentDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (HostedAgentDefinition)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeHostedAgentDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(HostedAgentDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/HostedAgentDefinition.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/HostedAgentDefinition.cs new file mode 100644 index 000000000000..911ffd28dfc9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/HostedAgentDefinition.cs @@ -0,0 +1,71 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects.OpenAI +{ + /// The hosted agent definition. + public partial class HostedAgentDefinition : AgentDefinition + { + /// Initializes a new instance of . + /// The protocols that the agent supports for ingress communication of the containers. + /// The CPU configuration for the hosted agent. + /// The memory configuration for the hosted agent. + /// , or is null. + public HostedAgentDefinition(IEnumerable containerProtocolVersions, string cpu, string memory) : base(AgentKind.Hosted) + { + Argument.AssertNotNull(containerProtocolVersions, nameof(containerProtocolVersions)); + Argument.AssertNotNull(cpu, nameof(cpu)); + Argument.AssertNotNull(memory, nameof(memory)); + + Tools = new ChangeTrackingList(); + ContainerProtocolVersions = containerProtocolVersions.ToList(); + Cpu = cpu; + Memory = memory; + EnvironmentVariables = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// + /// Configuration for Responsible AI (RAI) content filtering and safety features. + /// Keeps track of any properties unknown to the library. + /// + /// An array of tools the hosted agent's model may call while generating a response. You + /// can specify which tool to use by setting the `tool_choice` parameter. + /// + /// The protocols that the agent supports for ingress communication of the containers. + /// The CPU configuration for the hosted agent. + /// The memory configuration for the hosted agent. + /// Environment variables to set in the hosted agent container. + internal HostedAgentDefinition(AgentKind kind, ContentFilterConfiguration contentFilterConfiguration, IDictionary additionalBinaryDataProperties, IList tools, IList containerProtocolVersions, string cpu, string memory, IDictionary environmentVariables) : base(kind, contentFilterConfiguration, additionalBinaryDataProperties) + { + Tools = tools; + ContainerProtocolVersions = containerProtocolVersions; + Cpu = cpu; + Memory = memory; + EnvironmentVariables = environmentVariables; + } + + /// + /// An array of tools the hosted agent's model may call while generating a response. You + /// can specify which tool to use by setting the `tool_choice` parameter. + /// + public IList Tools { get; } + + /// The protocols that the agent supports for ingress communication of the containers. + public IList ContainerProtocolVersions { get; } + + /// The CPU configuration for the hosted agent. + public string Cpu { get; set; } + + /// The memory configuration for the hosted agent. + public string Memory { get; set; } + + /// Environment variables to set in the hosted agent container. + public IDictionary EnvironmentVariables { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageBasedHostedAgentDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageBasedHostedAgentDefinition.Serialization.cs new file mode 100644 index 000000000000..3082e65e3a65 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageBasedHostedAgentDefinition.Serialization.cs @@ -0,0 +1,210 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The image-based deployment definition for a hosted agent. + public partial class ImageBasedHostedAgentDefinition : HostedAgentDefinition, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ImageBasedHostedAgentDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ImageBasedHostedAgentDefinition)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("image"u8); + writer.WriteStringValue(Image); + } + + /// The JSON reader. + /// The client options for reading and writing models. + ImageBasedHostedAgentDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (ImageBasedHostedAgentDefinition)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ImageBasedHostedAgentDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeImageBasedHostedAgentDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ImageBasedHostedAgentDefinition DeserializeImageBasedHostedAgentDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentKind kind = default; + ContentFilterConfiguration contentFilterConfiguration = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList tools = default; + IList containerProtocolVersions = default; + string cpu = default; + string memory = default; + IDictionary environmentVariables = default; + string image = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("kind"u8)) + { + kind = new AgentKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("rai_config"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + contentFilterConfiguration = ContentFilterConfiguration.DeserializeContentFilterConfiguration(prop.Value, options); + continue; + } + if (prop.NameEquals("tools"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(AgentTool.DeserializeAgentTool(item, options)); + } + tools = array; + continue; + } + if (prop.NameEquals("container_protocol_versions"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ProtocolVersionRecord.DeserializeProtocolVersionRecord(item, options)); + } + containerProtocolVersions = array; + continue; + } + if (prop.NameEquals("cpu"u8)) + { + cpu = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("memory"u8)) + { + memory = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("environment_variables"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + environmentVariables = dictionary; + continue; + } + if (prop.NameEquals("image"u8)) + { + image = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ImageBasedHostedAgentDefinition( + kind, + contentFilterConfiguration, + additionalBinaryDataProperties, + tools ?? new ChangeTrackingList(), + containerProtocolVersions, + cpu, + memory, + environmentVariables ?? new ChangeTrackingDictionary(), + image); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(ImageBasedHostedAgentDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ImageBasedHostedAgentDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (ImageBasedHostedAgentDefinition)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeImageBasedHostedAgentDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ImageBasedHostedAgentDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageBasedHostedAgentDefinition.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageBasedHostedAgentDefinition.cs new file mode 100644 index 000000000000..f9d908a0d617 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageBasedHostedAgentDefinition.cs @@ -0,0 +1,50 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// The image-based deployment definition for a hosted agent. + public partial class ImageBasedHostedAgentDefinition : HostedAgentDefinition + { + /// Initializes a new instance of . + /// The protocols that the agent supports for ingress communication of the containers. + /// The CPU configuration for the hosted agent. + /// The memory configuration for the hosted agent. + /// The image for the hosted agent. + /// , , or is null. + public ImageBasedHostedAgentDefinition(IEnumerable containerProtocolVersions, string cpu, string memory, string image) : base(containerProtocolVersions, cpu, memory) + { + Argument.AssertNotNull(containerProtocolVersions, nameof(containerProtocolVersions)); + Argument.AssertNotNull(cpu, nameof(cpu)); + Argument.AssertNotNull(memory, nameof(memory)); + Argument.AssertNotNull(image, nameof(image)); + + Image = image; + } + + /// Initializes a new instance of . + /// + /// Configuration for Responsible AI (RAI) content filtering and safety features. + /// Keeps track of any properties unknown to the library. + /// + /// An array of tools the hosted agent's model may call while generating a response. You + /// can specify which tool to use by setting the `tool_choice` parameter. + /// + /// The protocols that the agent supports for ingress communication of the containers. + /// The CPU configuration for the hosted agent. + /// The memory configuration for the hosted agent. + /// Environment variables to set in the hosted agent container. + /// The image for the hosted agent. + internal ImageBasedHostedAgentDefinition(AgentKind kind, ContentFilterConfiguration contentFilterConfiguration, IDictionary additionalBinaryDataProperties, IList tools, IList containerProtocolVersions, string cpu, string memory, IDictionary environmentVariables, string image) : base(kind, contentFilterConfiguration, additionalBinaryDataProperties, tools, containerProtocolVersions, cpu, memory, environmentVariables) + { + Image = image; + } + + /// The image for the hosted agent. + public string Image { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageGenToolBackground.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageGenToolBackground.cs new file mode 100644 index 000000000000..1855b3d9e79e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageGenToolBackground.cs @@ -0,0 +1,69 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct ImageGenToolBackground : IEquatable + { + private readonly string _value; + private const string TransparentValue = "transparent"; + private const string OpaqueValue = "opaque"; + private const string AutoValue = "auto"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ImageGenToolBackground(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Transparent. + public static ImageGenToolBackground Transparent { get; } = new ImageGenToolBackground(TransparentValue); + + /// Gets the Opaque. + public static ImageGenToolBackground Opaque { get; } = new ImageGenToolBackground(OpaqueValue); + + /// Gets the Auto. + public static ImageGenToolBackground Auto { get; } = new ImageGenToolBackground(AutoValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ImageGenToolBackground left, ImageGenToolBackground right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ImageGenToolBackground left, ImageGenToolBackground right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolBackground(string value) => new ImageGenToolBackground(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolBackground?(string value) => value == null ? null : new ImageGenToolBackground(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ImageGenToolBackground other && Equals(other); + + /// + public bool Equals(ImageGenToolBackground other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageGenToolCallItemResourceStatus.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageGenToolCallItemResourceStatus.cs new file mode 100644 index 000000000000..d96bcd03ecbd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageGenToolCallItemResourceStatus.cs @@ -0,0 +1,73 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct ImageGenToolCallItemResourceStatus : IEquatable + { + private readonly string _value; + private const string InProgressValue = "in_progress"; + private const string CompletedValue = "completed"; + private const string GeneratingValue = "generating"; + private const string FailedValue = "failed"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ImageGenToolCallItemResourceStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the InProgress. + public static ImageGenToolCallItemResourceStatus InProgress { get; } = new ImageGenToolCallItemResourceStatus(InProgressValue); + + /// Gets the Completed. + public static ImageGenToolCallItemResourceStatus Completed { get; } = new ImageGenToolCallItemResourceStatus(CompletedValue); + + /// Gets the Generating. + public static ImageGenToolCallItemResourceStatus Generating { get; } = new ImageGenToolCallItemResourceStatus(GeneratingValue); + + /// Gets the Failed. + public static ImageGenToolCallItemResourceStatus Failed { get; } = new ImageGenToolCallItemResourceStatus(FailedValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ImageGenToolCallItemResourceStatus left, ImageGenToolCallItemResourceStatus right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ImageGenToolCallItemResourceStatus left, ImageGenToolCallItemResourceStatus right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolCallItemResourceStatus(string value) => new ImageGenToolCallItemResourceStatus(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolCallItemResourceStatus?(string value) => value == null ? null : new ImageGenToolCallItemResourceStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ImageGenToolCallItemResourceStatus other && Equals(other); + + /// + public bool Equals(ImageGenToolCallItemResourceStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageGenToolModel.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageGenToolModel.cs new file mode 100644 index 000000000000..a5844db49d8e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageGenToolModel.cs @@ -0,0 +1,62 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + /// + internal readonly partial struct ImageGenToolModel : IEquatable + { + private readonly string _value; + private const string GptImage1Value = "gpt-image-1"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ImageGenToolModel(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the GptImage1. + public static ImageGenToolModel GptImage1 { get; } = new ImageGenToolModel(GptImage1Value); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ImageGenToolModel left, ImageGenToolModel right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ImageGenToolModel left, ImageGenToolModel right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolModel(string value) => new ImageGenToolModel(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolModel?(string value) => value == null ? null : new ImageGenToolModel(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ImageGenToolModel other && Equals(other); + + /// + public bool Equals(ImageGenToolModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageGenToolModeration.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageGenToolModeration.cs new file mode 100644 index 000000000000..24009bca6777 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageGenToolModeration.cs @@ -0,0 +1,65 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct ImageGenToolModeration : IEquatable + { + private readonly string _value; + private const string AutoValue = "auto"; + private const string LowValue = "low"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ImageGenToolModeration(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Auto. + public static ImageGenToolModeration Auto { get; } = new ImageGenToolModeration(AutoValue); + + /// Gets the Low. + public static ImageGenToolModeration Low { get; } = new ImageGenToolModeration(LowValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ImageGenToolModeration left, ImageGenToolModeration right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ImageGenToolModeration left, ImageGenToolModeration right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolModeration(string value) => new ImageGenToolModeration(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolModeration?(string value) => value == null ? null : new ImageGenToolModeration(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ImageGenToolModeration other && Equals(other); + + /// + public bool Equals(ImageGenToolModeration other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageGenToolOutputFormat.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageGenToolOutputFormat.cs new file mode 100644 index 000000000000..a5118ede9c17 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageGenToolOutputFormat.cs @@ -0,0 +1,69 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct ImageGenToolOutputFormat : IEquatable + { + private readonly string _value; + private const string PngValue = "png"; + private const string WebpValue = "webp"; + private const string JpegValue = "jpeg"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ImageGenToolOutputFormat(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Png. + public static ImageGenToolOutputFormat Png { get; } = new ImageGenToolOutputFormat(PngValue); + + /// Gets the Webp. + public static ImageGenToolOutputFormat Webp { get; } = new ImageGenToolOutputFormat(WebpValue); + + /// Gets the Jpeg. + public static ImageGenToolOutputFormat Jpeg { get; } = new ImageGenToolOutputFormat(JpegValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ImageGenToolOutputFormat left, ImageGenToolOutputFormat right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ImageGenToolOutputFormat left, ImageGenToolOutputFormat right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolOutputFormat(string value) => new ImageGenToolOutputFormat(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolOutputFormat?(string value) => value == null ? null : new ImageGenToolOutputFormat(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ImageGenToolOutputFormat other && Equals(other); + + /// + public bool Equals(ImageGenToolOutputFormat other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageGenToolQuality.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageGenToolQuality.cs new file mode 100644 index 000000000000..d3b9ecbbbb4b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageGenToolQuality.cs @@ -0,0 +1,73 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct ImageGenToolQuality : IEquatable + { + private readonly string _value; + private const string LowValue = "low"; + private const string MediumValue = "medium"; + private const string HighValue = "high"; + private const string AutoValue = "auto"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ImageGenToolQuality(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Low. + public static ImageGenToolQuality Low { get; } = new ImageGenToolQuality(LowValue); + + /// Gets the Medium. + public static ImageGenToolQuality Medium { get; } = new ImageGenToolQuality(MediumValue); + + /// Gets the High. + public static ImageGenToolQuality High { get; } = new ImageGenToolQuality(HighValue); + + /// Gets the Auto. + public static ImageGenToolQuality Auto { get; } = new ImageGenToolQuality(AutoValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ImageGenToolQuality left, ImageGenToolQuality right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ImageGenToolQuality left, ImageGenToolQuality right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolQuality(string value) => new ImageGenToolQuality(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolQuality?(string value) => value == null ? null : new ImageGenToolQuality(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ImageGenToolQuality other && Equals(other); + + /// + public bool Equals(ImageGenToolQuality other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageGenToolSize.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageGenToolSize.cs new file mode 100644 index 000000000000..3b5e1394cc8c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ImageGenToolSize.cs @@ -0,0 +1,73 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct ImageGenToolSize : IEquatable + { + private readonly string _value; + private const string _1024x1024Value = "1024x1024"; + private const string _1024x1536Value = "1024x1536"; + private const string _1536x1024Value = "1536x1024"; + private const string AutoValue = "auto"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ImageGenToolSize(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the _1024x1024. + public static ImageGenToolSize _1024x1024 { get; } = new ImageGenToolSize(_1024x1024Value); + + /// Gets the _1024x1536. + public static ImageGenToolSize _1024x1536 { get; } = new ImageGenToolSize(_1024x1536Value); + + /// Gets the _1536x1024. + public static ImageGenToolSize _1536x1024 { get; } = new ImageGenToolSize(_1536x1024Value); + + /// Gets the Auto. + public static ImageGenToolSize Auto { get; } = new ImageGenToolSize(AutoValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ImageGenToolSize left, ImageGenToolSize right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ImageGenToolSize left, ImageGenToolSize right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolSize(string value) => new ImageGenToolSize(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolSize?(string value) => value == null ? null : new ImageGenToolSize(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ImageGenToolSize other && Equals(other); + + /// + public bool Equals(ImageGenToolSize other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/Argument.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..0c1e1d2aeca2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/Argument.cs @@ -0,0 +1,71 @@ +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + internal static partial class Argument + { + /// The value. + /// The name. + public static void AssertNotNull(T value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + } + + /// The value. + /// The name. + public static void AssertNotNull(T? value, string name) + where T : struct + { + if (!value.HasValue) + { + throw new ArgumentNullException(name); + } + } + + /// The value. + /// The name. + public static void AssertNotNullOrEmpty(IEnumerable value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value is ICollection collectionOfT && collectionOfT.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + if (value is ICollection collection && collection.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + using IEnumerator e = value.GetEnumerator(); + if (!e.MoveNext()) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + } + + /// The value. + /// The name. + public static void AssertNotNullOrEmpty(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", name); + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/CancellationTokenExtensions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/CancellationTokenExtensions.cs new file mode 100644 index 000000000000..49673b218490 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/CancellationTokenExtensions.cs @@ -0,0 +1,10 @@ +// + +#nullable disable + +namespace Azure.AI.Projects.OpenAI +{ + internal static partial class CancellationTokenExtensions + { + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..22f0795b6e64 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -0,0 +1,186 @@ +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + internal partial class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary + where TKey : notnull + { + private IDictionary _innerDictionary; + + public ChangeTrackingDictionary() + { + } + + /// The inner dictionary. + public ChangeTrackingDictionary(IDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(dictionary); + } + + /// The inner dictionary. + public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(); + foreach (var pair in dictionary) + { + _innerDictionary.Add(pair); + } + } + + /// Gets the IsUndefined. + public bool IsUndefined => _innerDictionary == null; + + /// Gets the Count. + public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + + /// Gets the IsReadOnly. + public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + + /// Gets the Keys. + public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + + /// Gets the Values. + public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + + /// Gets or sets the value associated with the specified key. + public TValue this[TKey key] + { + get + { + if (IsUndefined) + { + throw new KeyNotFoundException(nameof(key)); + } + return EnsureDictionary()[key]; + } + set + { + EnsureDictionary()[key] = value; + } + } + + /// Gets the Keys. + IEnumerable IReadOnlyDictionary.Keys => Keys; + + /// Gets the Values. + IEnumerable IReadOnlyDictionary.Values => Values; + + public IEnumerator> GetEnumerator() + { + if (IsUndefined) + { + IEnumerator> enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureDictionary().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// The item to add. + public void Add(KeyValuePair item) + { + EnsureDictionary().Add(item); + } + + public void Clear() + { + EnsureDictionary().Clear(); + } + + /// The item to search for. + public bool Contains(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Contains(item); + } + + /// The array to copy. + /// The index. + public void CopyTo(KeyValuePair[] array, int index) + { + if (IsUndefined) + { + return; + } + EnsureDictionary().CopyTo(array, index); + } + + /// The item to remove. + public bool Remove(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(item); + } + + /// The key. + /// The value to add. + public void Add(TKey key, TValue value) + { + EnsureDictionary().Add(key, value); + } + + /// The key to search for. + public bool ContainsKey(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().ContainsKey(key); + } + + /// The key. + public bool Remove(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(key); + } + + /// The key to search for. + /// The value. + public bool TryGetValue(TKey key, out TValue value) + { + if (IsUndefined) + { + value = default; + return false; + } + return EnsureDictionary().TryGetValue(key, out value); + } + + public IDictionary EnsureDictionary() + { + return _innerDictionary ??= new Dictionary(); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/ChangeTrackingList.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..22793c1f3311 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/ChangeTrackingList.cs @@ -0,0 +1,165 @@ +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects.OpenAI +{ + internal partial class ChangeTrackingList : IList, IReadOnlyList + { + private IList _innerList; + + public ChangeTrackingList() + { + } + + /// The inner list. + public ChangeTrackingList(IList innerList) + { + if (innerList != null) + { + _innerList = innerList; + } + } + + /// The inner list. + public ChangeTrackingList(IReadOnlyList innerList) + { + if (innerList != null) + { + _innerList = innerList.ToList(); + } + } + + /// Gets the IsUndefined. + public bool IsUndefined => _innerList == null; + + /// Gets the Count. + public int Count => IsUndefined ? 0 : EnsureList().Count; + + /// Gets the IsReadOnly. + public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + + /// Gets or sets the value associated with the specified key. + public T this[int index] + { + get + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + return EnsureList()[index]; + } + set + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList()[index] = value; + } + } + + public void Reset() + { + _innerList = null; + } + + public IEnumerator GetEnumerator() + { + if (IsUndefined) + { + IEnumerator enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureList().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// The item to add. + public void Add(T item) + { + EnsureList().Add(item); + } + + public void Clear() + { + EnsureList().Clear(); + } + + /// The item. + public bool Contains(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Contains(item); + } + + /// The array to copy to. + /// The array index. + public void CopyTo(T[] array, int arrayIndex) + { + if (IsUndefined) + { + return; + } + EnsureList().CopyTo(array, arrayIndex); + } + + /// The item. + public bool Remove(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Remove(item); + } + + /// The item. + public int IndexOf(T item) + { + if (IsUndefined) + { + return -1; + } + return EnsureList().IndexOf(item); + } + + /// The inner list. + /// The item. + public void Insert(int index, T item) + { + EnsureList().Insert(index, item); + } + + /// The inner list. + public void RemoveAt(int index) + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList().RemoveAt(index); + } + + public IList EnsureList() + { + return _innerList ??= new List(); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/ClientPipelineExtensions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/ClientPipelineExtensions.cs new file mode 100644 index 000000000000..8f72b2bcf220 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/ClientPipelineExtensions.cs @@ -0,0 +1,41 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading.Tasks; + +namespace Azure.AI.Projects.OpenAI +{ + internal static partial class ClientPipelineExtensions + { + public static async ValueTask> ProcessHeadAsBoolMessageAsync(this ClientPipeline pipeline, PipelineMessage message, RequestOptions options) + { + PipelineResponse response = await pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false); + switch (response.Status) + { + case >= 200 and < 300: + return ClientResult.FromValue(true, response); + case >= 400 and < 500: + return ClientResult.FromValue(false, response); + default: + return new ErrorResult(response, new ClientResultException(response)); + } + } + + public static ClientResult ProcessHeadAsBoolMessage(this ClientPipeline pipeline, PipelineMessage message, RequestOptions options) + { + PipelineResponse response = pipeline.ProcessMessage(message, options); + switch (response.Status) + { + case >= 200 and < 300: + return ClientResult.FromValue(true, response); + case >= 400 and < 500: + return ClientResult.FromValue(false, response); + default: + return new ErrorResult(response, new ClientResultException(response)); + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/ClientUriBuilder.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/ClientUriBuilder.cs new file mode 100644 index 000000000000..f3786d9c0a3b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/ClientUriBuilder.cs @@ -0,0 +1,136 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Azure.AI.Projects.OpenAI +{ + internal partial class ClientUriBuilder + { + private UriBuilder _uriBuilder; + private StringBuilder _pathAndQuery; + private int _pathLength; + + public ClientUriBuilder() + { + } + + private UriBuilder UriBuilder => _uriBuilder ??= new UriBuilder(); + + private StringBuilder PathAndQuery => _pathAndQuery ??= new StringBuilder(); + + public void Reset(Uri uri) + { + _uriBuilder = new UriBuilder(uri); + PathAndQuery.Clear(); + PathAndQuery.Append(UriBuilder.Path); + _pathLength = PathAndQuery.Length; + } + + public void AppendPath(string value, bool escape) + { + if (escape) + { + value = Uri.EscapeDataString(value); + } + if (_pathLength > 0 && PathAndQuery[_pathLength - 1] == '/' && value[0] == '/') + { + PathAndQuery.Remove(_pathLength - 1, 1); + _pathLength = _pathLength - 1; + } + PathAndQuery.Insert(_pathLength, value); + _pathLength = _pathLength + value.Length; + } + + public void AppendPath(bool value, bool escape = false) => AppendPath(TypeFormatters.ConvertToString(value), escape); + + public void AppendPath(float value, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value), escape); + + public void AppendPath(double value, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value), escape); + + public void AppendPath(int value, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value), escape); + + public void AppendPath(byte[] value, SerializationFormat format = SerializationFormat.Default, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value, format), escape); + + public void AppendPath(DateTimeOffset value, SerializationFormat format = SerializationFormat.Default, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value, format), escape); + + public void AppendPath(TimeSpan value, SerializationFormat format = SerializationFormat.Default, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value, format), escape); + + public void AppendPath(Guid value, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value), escape); + + public void AppendPath(long value, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value), escape); + + public void AppendPathDelimited(IEnumerable value, string delimiter, SerializationFormat format = SerializationFormat.Default, bool escape = true) + { + delimiter ??= ","; + IEnumerable stringValues = value.Select(v => TypeFormatters.ConvertToString(v, format)); + AppendPath(string.Join(delimiter, stringValues), escape); + } + + public void AppendQuery(string name, string value, bool escape) + { + if (PathAndQuery.Length == _pathLength) + { + PathAndQuery.Append('?'); + } + if (PathAndQuery.Length > _pathLength && PathAndQuery[PathAndQuery.Length - 1] != '?') + { + PathAndQuery.Append('&'); + } + if (escape) + { + value = Uri.EscapeDataString(value); + } + PathAndQuery.Append(name); + PathAndQuery.Append('='); + PathAndQuery.Append(value); + } + + public void AppendQuery(string name, bool value, bool escape = false) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); + + public void AppendQuery(string name, float value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); + + public void AppendQuery(string name, DateTimeOffset value, SerializationFormat format = SerializationFormat.Default, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value, format), escape); + + public void AppendQuery(string name, TimeSpan value, SerializationFormat format = SerializationFormat.Default, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value, format), escape); + + public void AppendQuery(string name, double value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); + + public void AppendQuery(string name, decimal value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); + + public void AppendQuery(string name, int value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); + + public void AppendQuery(string name, long value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); + + public void AppendQuery(string name, TimeSpan value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); + + public void AppendQuery(string name, byte[] value, SerializationFormat format = SerializationFormat.Default, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value, format), escape); + + public void AppendQuery(string name, Guid value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); + + public void AppendQueryDelimited(string name, IEnumerable value, string delimiter, SerializationFormat format = SerializationFormat.Default, bool escape = true) + { + delimiter ??= ","; + IEnumerable stringValues = value.Select(v => TypeFormatters.ConvertToString(v, format)); + AppendQuery(name, string.Join(delimiter, stringValues), escape); + } + + public Uri ToUri() + { + UriBuilder.Path = PathAndQuery.ToString(0, _pathLength); + if (PathAndQuery.Length > _pathLength) + { + UriBuilder.Query = PathAndQuery.ToString(_pathLength + 1, PathAndQuery.Length - _pathLength - 1); + } + if (PathAndQuery.Length == _pathLength) + { + UriBuilder.Query = ""; + } + return UriBuilder.Uri; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/CodeGenMemberAttribute.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/CodeGenMemberAttribute.cs new file mode 100644 index 000000000000..a70de91f8325 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/CodeGenMemberAttribute.cs @@ -0,0 +1,17 @@ +// + +#nullable disable + +using System; + +namespace Azure.AI.Projects.OpenAI +{ + [AttributeUsage((AttributeTargets.Property | AttributeTargets.Field))] + internal partial class CodeGenMemberAttribute : CodeGenTypeAttribute + { + /// The original name of the member. + public CodeGenMemberAttribute(string originalName) : base(originalName) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/CodeGenSerializationAttribute.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/CodeGenSerializationAttribute.cs new file mode 100644 index 000000000000..826f664e096f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/CodeGenSerializationAttribute.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System; + +namespace Azure.AI.Projects.OpenAI +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Struct), AllowMultiple = true, Inherited = true)] + internal partial class CodeGenSerializationAttribute : Attribute + { + /// The property name which these hooks apply to. + public CodeGenSerializationAttribute(string propertyName) + { + PropertyName = propertyName; + } + + /// The property name which these hooks apply to. + /// The serialization name of the property. + public CodeGenSerializationAttribute(string propertyName, string serializationName) + { + PropertyName = propertyName; + SerializationName = serializationName; + } + + /// Gets or sets the property name which these hooks should apply to. + public string PropertyName { get; } + + /// Gets or sets the serialization name of the property. + public string SerializationName { get; set; } + + /// + /// Gets or sets the method name to use when serializing the property value (property name excluded). + /// The signature of the serialization hook method must be or compatible with when invoking: private void SerializeHook(Utf8JsonWriter writer); + /// + public string SerializationValueHook { get; set; } + + /// + /// Gets or sets the method name to use when deserializing the property value from the JSON. + /// private static void DeserializationHook(JsonProperty property, ref TypeOfTheProperty propertyValue); // if the property is required + /// private static void DeserializationHook(JsonProperty property, ref Optional<TypeOfTheProperty> propertyValue); // if the property is optional + /// + public string DeserializationValueHook { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/CodeGenSuppressAttribute.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/CodeGenSuppressAttribute.cs new file mode 100644 index 000000000000..0feb5980dce7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/CodeGenSuppressAttribute.cs @@ -0,0 +1,26 @@ +// + +#nullable disable + +using System; + +namespace Azure.AI.Projects.OpenAI +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct), AllowMultiple = true)] + internal partial class CodeGenSuppressAttribute : Attribute + { + /// The member to suppress. + /// The types of the parameters of the member. + public CodeGenSuppressAttribute(string member, params Type[] parameters) + { + Member = member; + Parameters = parameters; + } + + /// Gets the Member. + public string Member { get; } + + /// Gets the Parameters. + public Type[] Parameters { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/CodeGenTypeAttribute.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/CodeGenTypeAttribute.cs new file mode 100644 index 000000000000..e010148f2db7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/CodeGenTypeAttribute.cs @@ -0,0 +1,21 @@ +// + +#nullable disable + +using System; + +namespace Azure.AI.Projects.OpenAI +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct))] + internal partial class CodeGenTypeAttribute : Attribute + { + /// The original name of the type. + public CodeGenTypeAttribute(string originalName) + { + OriginalName = originalName; + } + + /// Gets the OriginalName. + public string OriginalName { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/ErrorResult.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/ErrorResult.cs new file mode 100644 index 000000000000..3a248cafb8aa --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/ErrorResult.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace Azure.AI.Projects.OpenAI +{ + internal partial class ErrorResult : ClientResult + { + private readonly PipelineResponse _response; + private readonly ClientResultException _exception; + + public ErrorResult(PipelineResponse response, ClientResultException exception) : base(default, response) + { + _response = response; + _exception = exception; + } + + /// Gets the Value. + public override T Value => throw _exception; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..c61dd3653095 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,255 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + internal static partial class ModelSerializationExtensions + { + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions + { + MaxDepth = 256 + }; + + public static object GetObject(this JsonElement element) + { + switch (element.ValueKind) + { + case JsonValueKind.String: + return element.GetString(); + case JsonValueKind.Number: + if (element.TryGetInt32(out int intValue)) + { + return intValue; + } + if (element.TryGetInt64(out long longValue)) + { + return longValue; + } + return element.GetDouble(); + case JsonValueKind.True: + return true; + case JsonValueKind.False: + return false; + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return null; + case JsonValueKind.Object: + Dictionary dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + List list = new List(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); + } + } + + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + + return format switch + { + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; + + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + { + string text = element.GetString(); + if (text == null || text.Length != 1) + { + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); + } + return text[0]; + } + else + { + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + } + } + + [Conditional("DEBUG")] + public static void ThrowNonNullablePropertyIsNull(this JsonProperty @property) + { + throw new JsonException($"A property '{@property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + } + + public static string GetRequiredString(this JsonElement element) + { + string value = element.GetString(); + if (value == null) + { + throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); + } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } + + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + switch (format) + { + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); + } + } + + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") + { + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); + } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) + { + case null: + writer.WriteNullValue(); + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); + } + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/Optional.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..2fea62af654c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/Optional.cs @@ -0,0 +1,48 @@ +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + internal static partial class Optional + { + public static bool IsCollectionDefined(IEnumerable collection) + { + return !(collection is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined); + } + + public static bool IsCollectionDefined(IDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsCollectionDefined(IReadOnlyDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsDefined(T? value) + where T : struct + { + return value.HasValue; + } + + public static bool IsDefined(object value) + { + return value != null; + } + + public static bool IsDefined(string value) + { + return value != null; + } + + public static bool IsDefined(JsonElement value) + { + return value.ValueKind != JsonValueKind.Undefined; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/SerializationFormat.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/SerializationFormat.cs new file mode 100644 index 000000000000..5f4ee6bf0632 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/SerializationFormat.cs @@ -0,0 +1,46 @@ +// + +#nullable disable + +namespace Azure.AI.Projects.OpenAI +{ + internal enum SerializationFormat + { + /// The default serialization format. + Default = 0, + /// The RFC1123 date time format. + DateTime_RFC1123 = 1, + /// The RFC3339 date time format. + DateTime_RFC3339 = 2, + /// The RFC7231 date time format. + DateTime_RFC7231 = 3, + /// The ISO8601 date time format. + DateTime_ISO8601 = 4, + /// The Unix date time format. + DateTime_Unix = 5, + /// The ISO8601 date format. + Date_ISO8601 = 6, + /// The ISO8601 duration format. + Duration_ISO8601 = 7, + /// The constant duration format. + Duration_Constant = 8, + /// The seconds duration format. + Duration_Seconds = 9, + /// The seconds duration format with float precision. + Duration_Seconds_Float = 10, + /// The seconds duration format with double precision. + Duration_Seconds_Double = 11, + /// The milliseconds duration format. + Duration_Milliseconds = 12, + /// The milliseconds duration format with float precision. + Duration_Milliseconds_Float = 13, + /// The milliseconds duration format with double precision. + Duration_Milliseconds_Double = 14, + /// The ISO8601 time format. + Time_ISO8601 = 15, + /// The Base64Url bytes format. + Bytes_Base64Url = 16, + /// The Base64 bytes format. + Bytes_Base64 = 17 + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/TypeFormatters.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/TypeFormatters.cs new file mode 100644 index 000000000000..3aa67cba476f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Internal/TypeFormatters.cs @@ -0,0 +1,177 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; + +namespace Azure.AI.Projects.OpenAI +{ + internal static partial class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Generated clients require it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => System.Xml.XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked (value.Length + 2) / 3; + int size = checked (numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => System.Xml.XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ToFormatSpecifier(SerializationFormat format) => format switch + { + SerializationFormat.DateTime_RFC1123 => "R", + SerializationFormat.DateTime_RFC3339 => "O", + SerializationFormat.DateTime_RFC7231 => "R", + SerializationFormat.DateTime_ISO8601 => "O", + SerializationFormat.Date_ISO8601 => "D", + SerializationFormat.DateTime_Unix => "U", + SerializationFormat.Bytes_Base64Url => "U", + SerializationFormat.Bytes_Base64 => "D", + SerializationFormat.Duration_ISO8601 => "P", + SerializationFormat.Duration_Constant => "c", + SerializationFormat.Duration_Seconds => "%s", + SerializationFormat.Duration_Seconds_Float => "s\\.FFF", + SerializationFormat.Duration_Seconds_Double => "s\\.FFFFFF", + SerializationFormat.Time_ISO8601 => "T", + _ => null + }; + + public static string ConvertToString(object value, SerializationFormat format = SerializationFormat.Default) + { + string formatSpecifier = ToFormatSpecifier(format); + + return value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when formatSpecifier != null => ToString(b0, formatSpecifier), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when formatSpecifier != null => ToString(dateTime, formatSpecifier), + TimeSpan timeSpan when format == SerializationFormat.Duration_Seconds => Convert.ToInt32(timeSpan.TotalSeconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan0 when format == SerializationFormat.Duration_Seconds_Float || format == SerializationFormat.Duration_Seconds_Double => timeSpan0.TotalSeconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan1 when format == SerializationFormat.Duration_Milliseconds => Convert.ToInt32(timeSpan1.TotalMilliseconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan2 when format == SerializationFormat.Duration_Milliseconds_Float || format == SerializationFormat.Duration_Milliseconds_Double => timeSpan2.TotalMilliseconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan3 when formatSpecifier != null => ToString(timeSpan3, formatSpecifier), + TimeSpan timeSpan4 => System.Xml.XmlConvert.ToString(timeSpan4), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAgentResponse.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAgentResponse.Serialization.cs new file mode 100644 index 000000000000..752b4a43d0aa --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAgentResponse.Serialization.cs @@ -0,0 +1,725 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalAgentResponse : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalAgentResponse() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAgentResponse)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"u8); + } + if (Optional.IsDefined(Temperature)) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + else + { + writer.WriteNull("temperature"u8); + } + if (Optional.IsDefined(TopP)) + { + writer.WritePropertyName("top_p"u8); + writer.WriteNumberValue(TopP.Value); + } + else + { + writer.WriteNull("top_p"u8); + } + if (Optional.IsDefined(User)) + { + writer.WritePropertyName("user"u8); + writer.WriteStringValue(User); + } + else + { + writer.WriteNull("user"u8); + } + if (Optional.IsDefined(ServiceTier)) + { + writer.WritePropertyName("service_tier"u8); + writer.WriteStringValue(ServiceTier.Value.ToSerialString()); + } + if (Optional.IsDefined(TopLogprobs)) + { + writer.WritePropertyName("top_logprobs"u8); + writer.WriteNumberValue(TopLogprobs.Value); + } + if (Optional.IsDefined(PreviousResponseId)) + { + writer.WritePropertyName("previous_response_id"u8); + writer.WriteStringValue(PreviousResponseId); + } + if (Optional.IsDefined(Model)) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model); + } + if (Optional.IsDefined(Reasoning)) + { + writer.WritePropertyName("reasoning"u8); + writer.WriteObjectValue(Reasoning, options); + } + if (Optional.IsDefined(Background)) + { + writer.WritePropertyName("background"u8); + writer.WriteBooleanValue(Background.Value); + } + if (Optional.IsDefined(MaxOutputTokens)) + { + writer.WritePropertyName("max_output_tokens"u8); + writer.WriteNumberValue(MaxOutputTokens.Value); + } + if (Optional.IsDefined(MaxToolCalls)) + { + writer.WritePropertyName("max_tool_calls"u8); + writer.WriteNumberValue(MaxToolCalls.Value); + } + if (Optional.IsDefined(Text)) + { + writer.WritePropertyName("text"u8); + writer.WriteObjectValue(Text, options); + } + if (Optional.IsCollectionDefined(Tools)) + { + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (AgentTool item in Tools) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(ToolChoice)) + { + writer.WritePropertyName("tool_choice"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(ToolChoice); +#else + using (JsonDocument document = JsonDocument.Parse(ToolChoice)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (Optional.IsDefined(Prompt)) + { + writer.WritePropertyName("prompt"u8); + writer.WriteObjectValue(Prompt, options); + } + if (Optional.IsDefined(Truncation)) + { + writer.WritePropertyName("truncation"u8); + writer.WriteStringValue(Truncation.Value.ToSerialString()); + } + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object); + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + if (Optional.IsDefined(Error)) + { + writer.WritePropertyName("error"u8); + writer.WriteObjectValue(Error, options); + } + else + { + writer.WriteNull("error"u8); + } + if (Optional.IsDefined(IncompleteDetails)) + { + writer.WritePropertyName("incomplete_details"u8); + writer.WriteObjectValue(IncompleteDetails, options); + } + else + { + writer.WriteNull("incomplete_details"u8); + } + writer.WritePropertyName("output"u8); + writer.WriteStartArray(); + foreach (AgentResponseItem item in Output) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(Instructions)) + { + writer.WritePropertyName("instructions"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Instructions); +#else + using (JsonDocument document = JsonDocument.Parse(Instructions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + else + { + writer.WriteNull("instructions"u8); + } + if (Optional.IsDefined(OutputText)) + { + writer.WritePropertyName("output_text"u8); + writer.WriteStringValue(OutputText); + } + if (Optional.IsDefined(Usage)) + { + writer.WritePropertyName("usage"u8); + writer.WriteObjectValue(Usage, options); + } + writer.WritePropertyName("parallel_tool_calls"u8); + writer.WriteBooleanValue(ParallelToolCalls); + if (Optional.IsDefined(Conversation)) + { + writer.WritePropertyName("conversation"u8); + writer.WriteObjectValue(Conversation, options); + } + else + { + writer.WriteNull("conversation"u8); + } + if (Optional.IsDefined(Agent)) + { + writer.WritePropertyName("agent"u8); + writer.WriteObjectValue(Agent, options); + } + if (Optional.IsCollectionDefined(StructuredInputs)) + { + writer.WritePropertyName("structured_inputs"u8); + writer.WriteStartObject(); + foreach (var item in StructuredInputs) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#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(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalAgentResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalAgentResponse JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAgentResponse)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAgentResponse(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalAgentResponse DeserializeInternalAgentResponse(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary metadata = default; + float? temperature = default; + float? topP = default; + string user = default; + ServiceTier? serviceTier = default; + int? topLogprobs = default; + string previousResponseId = default; + string model = default; + InternalReasoning reasoning = default; + bool? background = default; + int? maxOutputTokens = default; + int? maxToolCalls = default; + ResponseText text = default; + IList tools = default; + BinaryData toolChoice = default; + Prompt prompt = default; + ResponseTruncation? truncation = default; + string id = default; + string @object = default; + InternalAgentResponseStatus? status = default; + DateTimeOffset createdAt = default; + InternalAgentResponseError error = default; + ResponseIncompleteDetails1 incompleteDetails = default; + IList output = default; + BinaryData instructions = default; + string outputText = default; + ResponseUsage usage = default; + bool parallelToolCalls = default; + ResponseConversation1 conversation = default; + AgentInfo agent = default; + IDictionary structuredInputs = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("metadata"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + metadata = new ChangeTrackingDictionary(); + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + metadata = dictionary; + continue; + } + if (prop.NameEquals("temperature"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + temperature = null; + continue; + } + temperature = prop.Value.GetSingle(); + continue; + } + if (prop.NameEquals("top_p"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + topP = null; + continue; + } + topP = prop.Value.GetSingle(); + continue; + } + if (prop.NameEquals("user"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + user = null; + continue; + } + user = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("service_tier"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + serviceTier = prop.Value.GetString().ToServiceTier(); + continue; + } + if (prop.NameEquals("top_logprobs"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + topLogprobs = null; + continue; + } + topLogprobs = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("previous_response_id"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + previousResponseId = null; + continue; + } + previousResponseId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("model"u8)) + { + model = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("reasoning"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + reasoning = null; + continue; + } + reasoning = InternalReasoning.DeserializeInternalReasoning(prop.Value, options); + continue; + } + if (prop.NameEquals("background"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + background = null; + continue; + } + background = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("max_output_tokens"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + maxOutputTokens = null; + continue; + } + maxOutputTokens = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("max_tool_calls"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + maxToolCalls = null; + continue; + } + maxToolCalls = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("text"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + text = ResponseText.DeserializeResponseText(prop.Value, options); + continue; + } + if (prop.NameEquals("tools"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(AgentTool.DeserializeAgentTool(item, options)); + } + tools = array; + continue; + } + if (prop.NameEquals("tool_choice"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + toolChoice = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("prompt"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + prompt = null; + continue; + } + prompt = Prompt.DeserializePrompt(prop.Value, options); + continue; + } + if (prop.NameEquals("truncation"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + truncation = null; + continue; + } + truncation = prop.Value.GetString().ToResponseTruncation(); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("object"u8)) + { + @object = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("status"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new InternalAgentResponseStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("created_at"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64()); + continue; + } + if (prop.NameEquals("error"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + error = null; + continue; + } + error = InternalAgentResponseError.DeserializeInternalAgentResponseError(prop.Value, options); + continue; + } + if (prop.NameEquals("incomplete_details"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + incompleteDetails = null; + continue; + } + incompleteDetails = ResponseIncompleteDetails1.DeserializeResponseIncompleteDetails1(prop.Value, options); + continue; + } + if (prop.NameEquals("output"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(AgentResponseItem.DeserializeAgentResponseItem(item, options)); + } + output = array; + continue; + } + if (prop.NameEquals("instructions"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + instructions = null; + continue; + } + instructions = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("output_text"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + outputText = null; + continue; + } + outputText = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("usage"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + usage = ResponseUsage.DeserializeResponseUsage(prop.Value, options); + continue; + } + if (prop.NameEquals("parallel_tool_calls"u8)) + { + parallelToolCalls = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("conversation"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + conversation = null; + continue; + } + conversation = ResponseConversation1.DeserializeResponseConversation1(prop.Value, options); + continue; + } + if (prop.NameEquals("agent"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + agent = AgentInfo.DeserializeAgentInfo(prop.Value, options); + continue; + } + if (prop.NameEquals("structured_inputs"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + structuredInputs = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalAgentResponse( + metadata, + temperature, + topP, + user, + serviceTier, + topLogprobs, + previousResponseId, + model, + reasoning, + background, + maxOutputTokens, + maxToolCalls, + text, + tools ?? new ChangeTrackingList(), + toolChoice, + prompt, + truncation, + id, + @object, + status, + createdAt, + error, + incompleteDetails, + output, + instructions, + outputText, + usage, + parallelToolCalls, + conversation, + agent, + structuredInputs ?? new ChangeTrackingDictionary(), + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalAgentResponse)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalAgentResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalAgentResponse PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalAgentResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAgentResponse)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAgentResponse.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAgentResponse.cs new file mode 100644 index 000000000000..5bfe5b77bef6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAgentResponse.cs @@ -0,0 +1,492 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalAgentResponse + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + /// + /// 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. + /// We generally recommend altering this or `top_p` but not both. + /// + /// + /// 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. + /// + /// A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more about safety best practices](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids). + /// Unique identifier for this Response. + /// Unix timestamp (in seconds) of when this Response was created. + /// + /// Details about why the response is incomplete. + /// + /// An array of content items generated by the model. + /// + /// - The length and order of items in the `output` array is dependent + /// on the model's response. + /// - Rather than accessing the first item in the `output` array and + /// assuming it's an `assistant` message with the content generated by + /// the model, you might consider using the `output_text` property where + /// supported in SDKs. + /// + /// + /// A system (or developer) message inserted into the model's context. + /// + /// When using along with `previous_response_id`, the instructions from a previous + /// response will not be carried over to the next response. This makes it simple + /// to swap out system (or developer) messages in new responses. + /// + /// Whether to allow the model to run tool calls in parallel. + /// + internal InternalAgentResponse(IDictionary metadata, float? temperature, float? topP, string user, string id, DateTimeOffset createdAt, InternalAgentResponseError error, ResponseIncompleteDetails1 incompleteDetails, IEnumerable output, BinaryData instructions, bool parallelToolCalls, ResponseConversation1 conversation) + { + Metadata = metadata; + Temperature = temperature; + TopP = topP; + User = user; + Tools = new ChangeTrackingList(); + Id = id; + CreatedAt = createdAt; + Error = error; + IncompleteDetails = incompleteDetails; + Output = output.ToList(); + Instructions = instructions; + ParallelToolCalls = parallelToolCalls; + Conversation = conversation; + StructuredInputs = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + /// + /// 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. + /// We generally recommend altering this or `top_p` but not both. + /// + /// + /// 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. + /// + /// A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more about safety best practices](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids). + /// Note: service_tier is not applicable to Azure OpenAI. + /// An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. + /// + /// The unique ID of the previous response to the model. Use this to + /// create multi-turn conversations. Learn more about + /// [managing conversation state](https://platform.openai.com/docs/guides/conversation-state). + /// + /// The model deployment to use for the creation of this response. + /// + /// + /// Whether to run the model response in the background. + /// [Learn more about background responses](https://platform.openai.com/docs/guides/background). + /// + /// An upper bound for the number of tokens that can be generated for a response, including visible output tokens and [reasoning tokens](https://platform.openai.com/docs/guides/reasoning). + /// The maximum number of total calls to built-in tools that can be processed in a response. This maximum number applies across all built-in tool calls, not per individual tool. Any further attempts to call a tool by the model will be ignored. + /// + /// Configuration options for a text response from the model. Can be plain + /// text or structured JSON data. See [Text inputs and outputs](https://platform.openai.com/docs/guides/text) + /// and [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs) + /// + /// + /// An array of tools the model may call while generating a response. You + /// can specify which tool to use by setting the `tool_choice` parameter. + /// + /// The two categories of tools you can provide the model are: + /// + /// * **Built-in tools**: Tools that are provided by OpenAI that extend the + /// model's capabilities, like [web search](https://platform.openai.com/docs/guides/tools-web-search) + /// or [file search](https://platform.openai.com/docs/guides/tools-file-search). Learn more about + /// [built-in tools](https://platform.openai.com/docs/guides/tools). + /// * **Function calls (custom tools)**: Functions that are defined by you, + /// enabling the model to call your own code. Learn more about + /// [function calling](https://platform.openai.com/docs/guides/function-calling). + /// + /// + /// + /// How the model should select which tool (or tools) to use when generating + /// a response. See the `tools` parameter to see how to specify which tools + /// the model can call. + /// + /// + /// + /// The truncation strategy to use for the model response. + /// - `auto`: If the context of this response and previous ones exceeds + /// the model's context window size, the model will truncate the + /// response to fit the context window by dropping input items in the + /// middle of the conversation. + /// - `disabled` (default): If a model response will exceed the context window + /// size for a model, the request will fail with a 400 error. + /// + /// Unique identifier for this Response. + /// The object type of this resource - always set to `response`. + /// + /// The status of the response generation. One of `completed`, `failed`, + /// `in_progress`, `cancelled`, `queued`, or `incomplete`. + /// + /// Unix timestamp (in seconds) of when this Response was created. + /// + /// Details about why the response is incomplete. + /// + /// An array of content items generated by the model. + /// + /// - The length and order of items in the `output` array is dependent + /// on the model's response. + /// - Rather than accessing the first item in the `output` array and + /// assuming it's an `assistant` message with the content generated by + /// the model, you might consider using the `output_text` property where + /// supported in SDKs. + /// + /// + /// A system (or developer) message inserted into the model's context. + /// + /// When using along with `previous_response_id`, the instructions from a previous + /// response will not be carried over to the next response. This makes it simple + /// to swap out system (or developer) messages in new responses. + /// + /// + /// SDK-only convenience property that contains the aggregated text output + /// from all `output_text` items in the `output` array, if any are present. + /// Supported in the Python and JavaScript SDKs. + /// + /// + /// Whether to allow the model to run tool calls in parallel. + /// + /// The agent used for this response. + /// The structured inputs to the response that can participate in prompt template substitution or tool argument bindings. + /// Keeps track of any properties unknown to the library. + internal InternalAgentResponse(IDictionary metadata, float? temperature, float? topP, string user, ServiceTier? serviceTier, int? topLogprobs, string previousResponseId, string model, InternalReasoning reasoning, bool? background, int? maxOutputTokens, int? maxToolCalls, ResponseText text, IList tools, BinaryData toolChoice, Prompt prompt, ResponseTruncation? truncation, string id, string @object, InternalAgentResponseStatus? status, DateTimeOffset createdAt, InternalAgentResponseError error, ResponseIncompleteDetails1 incompleteDetails, IList output, BinaryData instructions, string outputText, ResponseUsage usage, bool parallelToolCalls, ResponseConversation1 conversation, AgentInfo agent, IDictionary structuredInputs, IDictionary additionalBinaryDataProperties) + { + Metadata = metadata; + Temperature = temperature; + TopP = topP; + User = user; + ServiceTier = serviceTier; + TopLogprobs = topLogprobs; + PreviousResponseId = previousResponseId; + Model = model; + Reasoning = reasoning; + Background = background; + MaxOutputTokens = maxOutputTokens; + MaxToolCalls = maxToolCalls; + Text = text; + Tools = tools; + ToolChoice = toolChoice; + Prompt = prompt; + Truncation = truncation; + Id = id; + Object = @object; + Status = status; + CreatedAt = createdAt; + Error = error; + IncompleteDetails = incompleteDetails; + Output = output; + Instructions = instructions; + OutputText = outputText; + Usage = usage; + ParallelToolCalls = parallelToolCalls; + Conversation = conversation; + Agent = agent; + StructuredInputs = structuredInputs; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + public IDictionary Metadata { get; } + + /// + /// 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. + /// We generally recommend altering this or `top_p` but not both. + /// + public float? Temperature { get; } + + /// + /// 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. + /// + public float? TopP { get; } + + /// A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more about safety best practices](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids). + public string User { get; } + + /// Note: service_tier is not applicable to Azure OpenAI. + public ServiceTier? ServiceTier { get; } + + /// An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. + public int? TopLogprobs { get; } + + /// + /// The unique ID of the previous response to the model. Use this to + /// create multi-turn conversations. Learn more about + /// [managing conversation state](https://platform.openai.com/docs/guides/conversation-state). + /// + public string PreviousResponseId { get; } + + /// The model deployment to use for the creation of this response. + public string Model { get; } + + /// Gets the Reasoning. + public InternalReasoning Reasoning { get; } + + /// + /// Whether to run the model response in the background. + /// [Learn more about background responses](https://platform.openai.com/docs/guides/background). + /// + public bool? Background { get; } + + /// An upper bound for the number of tokens that can be generated for a response, including visible output tokens and [reasoning tokens](https://platform.openai.com/docs/guides/reasoning). + public int? MaxOutputTokens { get; } + + /// The maximum number of total calls to built-in tools that can be processed in a response. This maximum number applies across all built-in tool calls, not per individual tool. Any further attempts to call a tool by the model will be ignored. + public int? MaxToolCalls { get; } + + /// + /// Configuration options for a text response from the model. Can be plain + /// text or structured JSON data. See [Text inputs and outputs](https://platform.openai.com/docs/guides/text) + /// and [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs) + /// + public ResponseText Text { get; } + + /// + /// An array of tools the model may call while generating a response. You + /// can specify which tool to use by setting the `tool_choice` parameter. + /// + /// The two categories of tools you can provide the model are: + /// + /// * **Built-in tools**: Tools that are provided by OpenAI that extend the + /// model's capabilities, like [web search](https://platform.openai.com/docs/guides/tools-web-search) + /// or [file search](https://platform.openai.com/docs/guides/tools-file-search). Learn more about + /// [built-in tools](https://platform.openai.com/docs/guides/tools). + /// * **Function calls (custom tools)**: Functions that are defined by you, + /// enabling the model to call your own code. Learn more about + /// [function calling](https://platform.openai.com/docs/guides/function-calling). + /// + /// + public IList Tools { get; } + + /// + /// How the model should select which tool (or tools) to use when generating + /// a response. See the `tools` parameter to see how to specify which tools + /// the model can call. + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// . + /// + /// + /// + /// + /// + /// 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" }. + /// + /// + /// + /// + public BinaryData ToolChoice { get; } + + /// Gets the Prompt. + public Prompt Prompt { get; } + + /// + /// The truncation strategy to use for the model response. + /// - `auto`: If the context of this response and previous ones exceeds + /// the model's context window size, the model will truncate the + /// response to fit the context window by dropping input items in the + /// middle of the conversation. + /// - `disabled` (default): If a model response will exceed the context window + /// size for a model, the request will fail with a 400 error. + /// + public ResponseTruncation? Truncation { get; } + + /// Unique identifier for this Response. + public string Id { get; } + + /// The object type of this resource - always set to `response`. + internal string Object { get; } = "response"; + + /// + /// The status of the response generation. One of `completed`, `failed`, + /// `in_progress`, `cancelled`, `queued`, or `incomplete`. + /// + public InternalAgentResponseStatus? Status { get; } + + /// Unix timestamp (in seconds) of when this Response was created. + public DateTimeOffset CreatedAt { get; } + + /// Gets the Error. + public InternalAgentResponseError Error { get; } + + /// Details about why the response is incomplete. + public ResponseIncompleteDetails1 IncompleteDetails { get; } + + /// + /// An array of content items generated by the model. + /// + /// - The length and order of items in the `output` array is dependent + /// on the model's response. + /// - Rather than accessing the first item in the `output` array and + /// assuming it's an `assistant` message with the content generated by + /// the model, you might consider using the `output_text` property where + /// supported in SDKs. + /// + public IList Output { get; } + + /// + /// A system (or developer) message inserted into the model's context. + /// + /// When using along with `previous_response_id`, the instructions from a previous + /// response will not be carried over to the next response. This makes it simple + /// to swap out system (or developer) messages in new responses. + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// where T is of type . + /// + /// + /// + /// + /// + /// 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" }. + /// + /// + /// + /// + public BinaryData Instructions { get; } + + /// + /// SDK-only convenience property that contains the aggregated text output + /// from all `output_text` items in the `output` array, if any are present. + /// Supported in the Python and JavaScript SDKs. + /// + public string OutputText { get; } + + /// Gets the Usage. + public ResponseUsage Usage { get; } + + /// Whether to allow the model to run tool calls in parallel. + public bool ParallelToolCalls { get; } + + /// Gets the Conversation. + public ResponseConversation1 Conversation { get; } + + /// The agent used for this response. + public AgentInfo Agent { get; } + + /// + /// The structured inputs to the response that can participate in prompt template substitution or tool argument bindings. + /// 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" }. + /// + /// + /// + /// + public IDictionary StructuredInputs { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAgentResponseError.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAgentResponseError.Serialization.cs new file mode 100644 index 000000000000..5125c813fe46 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAgentResponseError.Serialization.cs @@ -0,0 +1,147 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalAgentResponseError : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalAgentResponseError() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAgentResponseError)} does not support writing '{format}' format."); + } + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code.ToSerialString()); + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalAgentResponseError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalAgentResponseError JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAgentResponseError)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAgentResponseError(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalAgentResponseError DeserializeInternalAgentResponseError(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResponseErrorCode code = default; + string message = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("code"u8)) + { + code = prop.Value.GetString().ToResponseErrorCode(); + continue; + } + if (prop.NameEquals("message"u8)) + { + message = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalAgentResponseError(code, message, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalAgentResponseError)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalAgentResponseError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalAgentResponseError PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalAgentResponseError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAgentResponseError)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAgentResponseError.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAgentResponseError.cs new file mode 100644 index 000000000000..1b65b0e291e1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAgentResponseError.cs @@ -0,0 +1,41 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalAgentResponseError + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// A human-readable description of the error. + internal InternalAgentResponseError(ResponseErrorCode code, string message) + { + Code = code; + Message = message; + } + + /// Initializes a new instance of . + /// + /// A human-readable description of the error. + /// Keeps track of any properties unknown to the library. + internal InternalAgentResponseError(ResponseErrorCode code, string message, IDictionary additionalBinaryDataProperties) + { + Code = code; + Message = message; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Code. + public ResponseErrorCode Code { get; } + + /// A human-readable description of the error. + public string Message { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAgentResponseStatus.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAgentResponseStatus.cs new file mode 100644 index 000000000000..dc6b11868d6f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAgentResponseStatus.cs @@ -0,0 +1,81 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct InternalAgentResponseStatus : IEquatable + { + private readonly string _value; + private const string CompletedValue = "completed"; + private const string FailedValue = "failed"; + private const string InProgressValue = "in_progress"; + private const string CancelledValue = "cancelled"; + private const string QueuedValue = "queued"; + private const string IncompleteValue = "incomplete"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public InternalAgentResponseStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Completed. + public static InternalAgentResponseStatus Completed { get; } = new InternalAgentResponseStatus(CompletedValue); + + /// Gets the Failed. + public static InternalAgentResponseStatus Failed { get; } = new InternalAgentResponseStatus(FailedValue); + + /// Gets the InProgress. + public static InternalAgentResponseStatus InProgress { get; } = new InternalAgentResponseStatus(InProgressValue); + + /// Gets the Cancelled. + public static InternalAgentResponseStatus Cancelled { get; } = new InternalAgentResponseStatus(CancelledValue); + + /// Gets the Queued. + public static InternalAgentResponseStatus Queued { get; } = new InternalAgentResponseStatus(QueuedValue); + + /// Gets the Incomplete. + public static InternalAgentResponseStatus Incomplete { get; } = new InternalAgentResponseStatus(IncompleteValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(InternalAgentResponseStatus left, InternalAgentResponseStatus right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(InternalAgentResponseStatus left, InternalAgentResponseStatus right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator InternalAgentResponseStatus(string value) => new InternalAgentResponseStatus(value); + + /// Converts a string to a . + /// The value. + public static implicit operator InternalAgentResponseStatus?(string value) => value == null ? null : new InternalAgentResponseStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalAgentResponseStatus other && Equals(other); + + /// + public bool Equals(InternalAgentResponseStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAnnotation.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAnnotation.Serialization.cs new file mode 100644 index 000000000000..e432ccd08e46 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAnnotation.Serialization.cs @@ -0,0 +1,137 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + [PersistableModelProxy(typeof(UnknownAnnotation))] + internal abstract partial class InternalAnnotation : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalAnnotation() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAnnotation)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalAnnotation JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAnnotation)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAnnotation(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalAnnotation DeserializeInternalAnnotation(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "file_citation": + return InternalAnnotationFileCitation.DeserializeInternalAnnotationFileCitation(element, options); + case "url_citation": + return InternalAnnotationUrlCitation.DeserializeInternalAnnotationUrlCitation(element, options); + case "file_path": + return InternalAnnotationFilePath.DeserializeInternalAnnotationFilePath(element, options); + } + } + return UnknownAnnotation.DeserializeUnknownAnnotation(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalAnnotation)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalAnnotation PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAnnotation)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAnnotation.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAnnotation.cs new file mode 100644 index 000000000000..74f39a9c6058 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAnnotation.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal abstract partial class InternalAnnotation + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + private protected InternalAnnotation(AnnotationType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalAnnotation(AnnotationType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Type. + internal AnnotationType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAnnotationFileCitation.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAnnotationFileCitation.Serialization.cs new file mode 100644 index 000000000000..80630fdc7996 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAnnotationFileCitation.Serialization.cs @@ -0,0 +1,147 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalAnnotationFileCitation : InternalAnnotation, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalAnnotationFileCitation() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAnnotationFileCitation)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("filename"u8); + writer.WriteStringValue(Filename); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalAnnotationFileCitation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalAnnotationFileCitation)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalAnnotation JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAnnotationFileCitation)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAnnotationFileCitation(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalAnnotationFileCitation DeserializeInternalAnnotationFileCitation(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AnnotationType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string fileId = default; + int index = default; + string filename = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AnnotationType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("file_id"u8)) + { + fileId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("index"u8)) + { + index = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("filename"u8)) + { + filename = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalAnnotationFileCitation(@type, additionalBinaryDataProperties, fileId, index, filename); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalAnnotationFileCitation)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalAnnotationFileCitation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalAnnotationFileCitation)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalAnnotation PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalAnnotationFileCitation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAnnotationFileCitation)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAnnotationFileCitation.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAnnotationFileCitation.cs new file mode 100644 index 000000000000..b71358003bb3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAnnotationFileCitation.cs @@ -0,0 +1,50 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalAnnotationFileCitation : InternalAnnotation + { + /// Initializes a new instance of . + /// The ID of the file. + /// The index of the file in the list of files. + /// The filename of the file cited. + /// or is null. + public InternalAnnotationFileCitation(string fileId, int index, string filename) : base(AnnotationType.FileCitation) + { + Argument.AssertNotNull(fileId, nameof(fileId)); + Argument.AssertNotNull(filename, nameof(filename)); + + FileId = fileId; + Index = index; + Filename = filename; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The ID of the file. + /// The index of the file in the list of files. + /// The filename of the file cited. + internal InternalAnnotationFileCitation(AnnotationType @type, IDictionary additionalBinaryDataProperties, string fileId, int index, string filename) : base(@type, additionalBinaryDataProperties) + { + FileId = fileId; + Index = index; + Filename = filename; + } + + /// The ID of the file. + public string FileId { get; } + + /// The index of the file in the list of files. + public int Index { get; } + + /// The filename of the file cited. + public string Filename { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAnnotationFilePath.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAnnotationFilePath.Serialization.cs new file mode 100644 index 000000000000..bcf7f09c8d3e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAnnotationFilePath.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalAnnotationFilePath : InternalAnnotation, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalAnnotationFilePath() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAnnotationFilePath)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalAnnotationFilePath IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalAnnotationFilePath)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalAnnotation JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAnnotationFilePath)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAnnotationFilePath(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalAnnotationFilePath DeserializeInternalAnnotationFilePath(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AnnotationType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string fileId = default; + int index = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AnnotationType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("file_id"u8)) + { + fileId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("index"u8)) + { + index = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalAnnotationFilePath(@type, additionalBinaryDataProperties, fileId, index); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalAnnotationFilePath)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalAnnotationFilePath IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalAnnotationFilePath)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalAnnotation PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalAnnotationFilePath(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAnnotationFilePath)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAnnotationFilePath.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAnnotationFilePath.cs new file mode 100644 index 000000000000..660378239688 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAnnotationFilePath.cs @@ -0,0 +1,42 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalAnnotationFilePath : InternalAnnotation + { + /// Initializes a new instance of . + /// The ID of the file. + /// The index of the file in the list of files. + /// is null. + public InternalAnnotationFilePath(string fileId, int index) : base(AnnotationType.FilePath) + { + Argument.AssertNotNull(fileId, nameof(fileId)); + + FileId = fileId; + Index = index; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The ID of the file. + /// The index of the file in the list of files. + internal InternalAnnotationFilePath(AnnotationType @type, IDictionary additionalBinaryDataProperties, string fileId, int index) : base(@type, additionalBinaryDataProperties) + { + FileId = fileId; + Index = index; + } + + /// The ID of the file. + public string FileId { get; } + + /// The index of the file in the list of files. + public int Index { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAnnotationUrlCitation.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAnnotationUrlCitation.Serialization.cs new file mode 100644 index 000000000000..4a706a5c7c3f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAnnotationUrlCitation.Serialization.cs @@ -0,0 +1,161 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalAnnotationUrlCitation : InternalAnnotation, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalAnnotationUrlCitation() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAnnotationUrlCitation)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Url.AbsoluteUri); + writer.WritePropertyName("start_index"u8); + writer.WriteNumberValue(StartIndex); + writer.WritePropertyName("end_index"u8); + writer.WriteNumberValue(EndIndex); + writer.WritePropertyName("title"u8); + writer.WriteStringValue(Title); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalAnnotationUrlCitation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalAnnotationUrlCitation)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalAnnotation JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAnnotationUrlCitation)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAnnotationUrlCitation(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalAnnotationUrlCitation DeserializeInternalAnnotationUrlCitation(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AnnotationType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + Uri url = default; + int startIndex = default; + int endIndex = default; + string title = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AnnotationType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("url"u8)) + { + url = new Uri(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("start_index"u8)) + { + startIndex = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("end_index"u8)) + { + endIndex = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("title"u8)) + { + title = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalAnnotationUrlCitation( + @type, + additionalBinaryDataProperties, + url, + startIndex, + endIndex, + title); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalAnnotationUrlCitation)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalAnnotationUrlCitation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalAnnotationUrlCitation)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalAnnotation PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalAnnotationUrlCitation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAnnotationUrlCitation)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAnnotationUrlCitation.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAnnotationUrlCitation.cs new file mode 100644 index 000000000000..2b5333e52502 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalAnnotationUrlCitation.cs @@ -0,0 +1,57 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalAnnotationUrlCitation : InternalAnnotation + { + /// Initializes a new instance of . + /// The URL of the web resource. + /// The index of the first character of the URL citation in the message. + /// The index of the last character of the URL citation in the message. + /// The title of the web resource. + /// or is null. + public InternalAnnotationUrlCitation(Uri url, int startIndex, int endIndex, string title) : base(AnnotationType.UrlCitation) + { + Argument.AssertNotNull(url, nameof(url)); + Argument.AssertNotNull(title, nameof(title)); + + Url = url; + StartIndex = startIndex; + EndIndex = endIndex; + Title = title; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The URL of the web resource. + /// The index of the first character of the URL citation in the message. + /// The index of the last character of the URL citation in the message. + /// The title of the web resource. + internal InternalAnnotationUrlCitation(AnnotationType @type, IDictionary additionalBinaryDataProperties, Uri url, int startIndex, int endIndex, string title) : base(@type, additionalBinaryDataProperties) + { + Url = url; + StartIndex = startIndex; + EndIndex = endIndex; + Title = title; + } + + /// The URL of the web resource. + public Uri Url { get; } + + /// The index of the first character of the URL citation in the message. + public int StartIndex { get; } + + /// The index of the last character of the URL citation in the message. + public int EndIndex { get; } + + /// The title of the web resource. + public string Title { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalApproximateLocation.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalApproximateLocation.Serialization.cs new file mode 100644 index 000000000000..b823bb604bfa --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalApproximateLocation.Serialization.cs @@ -0,0 +1,188 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalApproximateLocation : InternalLocation, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalApproximateLocation)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Country)) + { + writer.WritePropertyName("country"u8); + writer.WriteStringValue(Country); + } + if (Optional.IsDefined(Region)) + { + writer.WritePropertyName("region"u8); + writer.WriteStringValue(Region); + } + if (Optional.IsDefined(City)) + { + writer.WritePropertyName("city"u8); + writer.WriteStringValue(City); + } + if (Optional.IsDefined(Timezone)) + { + writer.WritePropertyName("timezone"u8); + writer.WriteStringValue(Timezone); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalApproximateLocation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalApproximateLocation)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalLocation JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalApproximateLocation)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalApproximateLocation(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalApproximateLocation DeserializeInternalApproximateLocation(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + LocationType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string country = default; + string region = default; + string city = default; + string timezone = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new LocationType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("country"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + country = null; + continue; + } + country = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("region"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + region = null; + continue; + } + region = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("city"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + city = null; + continue; + } + city = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("timezone"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + timezone = null; + continue; + } + timezone = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalApproximateLocation( + @type, + additionalBinaryDataProperties, + country, + region, + city, + timezone); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalApproximateLocation)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalApproximateLocation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalApproximateLocation)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalLocation PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalApproximateLocation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalApproximateLocation)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalApproximateLocation.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalApproximateLocation.cs new file mode 100644 index 000000000000..c7622fa98475 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalApproximateLocation.cs @@ -0,0 +1,44 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalApproximateLocation : InternalLocation + { + /// Initializes a new instance of . + public InternalApproximateLocation() : base(LocationType.Approximate) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// + /// + /// + /// + internal InternalApproximateLocation(LocationType @type, IDictionary additionalBinaryDataProperties, string country, string region, string city, string timezone) : base(@type, additionalBinaryDataProperties) + { + Country = country; + Region = region; + City = city; + Timezone = timezone; + } + + /// Gets or sets the Country. + public string Country { get; set; } + + /// Gets or sets the Region. + public string Region { get; set; } + + /// Gets or sets the City. + public string City { get; set; } + + /// Gets or sets the Timezone. + public string Timezone { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterOutput.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterOutput.Serialization.cs new file mode 100644 index 000000000000..0f3f171f82a9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterOutput.Serialization.cs @@ -0,0 +1,135 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + [PersistableModelProxy(typeof(UnknownCodeInterpreterOutput))] + internal abstract partial class InternalCodeInterpreterOutput : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalCodeInterpreterOutput() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutput)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToSerialString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalCodeInterpreterOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalCodeInterpreterOutput JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutput)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCodeInterpreterOutput(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalCodeInterpreterOutput DeserializeInternalCodeInterpreterOutput(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "image": + return InternalCodeInterpreterOutputImage.DeserializeInternalCodeInterpreterOutputImage(element, options); + case "logs": + return InternalCodeInterpreterOutputLogs.DeserializeInternalCodeInterpreterOutputLogs(element, options); + } + } + return UnknownCodeInterpreterOutput.DeserializeUnknownCodeInterpreterOutput(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutput)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalCodeInterpreterOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalCodeInterpreterOutput PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalCodeInterpreterOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutput)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterOutput.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterOutput.cs new file mode 100644 index 000000000000..2765697f41dd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterOutput.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal abstract partial class InternalCodeInterpreterOutput + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + private protected InternalCodeInterpreterOutput(CodeInterpreterOutputType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalCodeInterpreterOutput(CodeInterpreterOutputType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Type. + internal CodeInterpreterOutputType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterOutputImage.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterOutputImage.Serialization.cs new file mode 100644 index 000000000000..e36d03a71579 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterOutputImage.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalCodeInterpreterOutputImage : InternalCodeInterpreterOutput, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalCodeInterpreterOutputImage() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutputImage)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Url.AbsoluteUri); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalCodeInterpreterOutputImage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalCodeInterpreterOutputImage)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalCodeInterpreterOutput JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutputImage)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCodeInterpreterOutputImage(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalCodeInterpreterOutputImage DeserializeInternalCodeInterpreterOutputImage(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CodeInterpreterOutputType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + Uri url = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToCodeInterpreterOutputType(); + continue; + } + if (prop.NameEquals("url"u8)) + { + url = new Uri(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalCodeInterpreterOutputImage(@type, additionalBinaryDataProperties, url); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutputImage)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalCodeInterpreterOutputImage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalCodeInterpreterOutputImage)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalCodeInterpreterOutput PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalCodeInterpreterOutputImage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutputImage)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterOutputImage.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterOutputImage.cs new file mode 100644 index 000000000000..e07e0422ac85 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterOutputImage.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalCodeInterpreterOutputImage : InternalCodeInterpreterOutput + { + /// Initializes a new instance of . + /// The URL of the image output from the code interpreter. + /// is null. + public InternalCodeInterpreterOutputImage(Uri url) : base(CodeInterpreterOutputType.Image) + { + Argument.AssertNotNull(url, nameof(url)); + + Url = url; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The URL of the image output from the code interpreter. + internal InternalCodeInterpreterOutputImage(CodeInterpreterOutputType @type, IDictionary additionalBinaryDataProperties, Uri url) : base(@type, additionalBinaryDataProperties) + { + Url = url; + } + + /// The URL of the image output from the code interpreter. + public Uri Url { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterOutputLogs.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterOutputLogs.Serialization.cs new file mode 100644 index 000000000000..15d8c83605f3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterOutputLogs.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalCodeInterpreterOutputLogs : InternalCodeInterpreterOutput, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalCodeInterpreterOutputLogs() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutputLogs)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("logs"u8); + writer.WriteStringValue(Logs); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalCodeInterpreterOutputLogs IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalCodeInterpreterOutputLogs)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalCodeInterpreterOutput JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutputLogs)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCodeInterpreterOutputLogs(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalCodeInterpreterOutputLogs DeserializeInternalCodeInterpreterOutputLogs(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CodeInterpreterOutputType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string logs = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToCodeInterpreterOutputType(); + continue; + } + if (prop.NameEquals("logs"u8)) + { + logs = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalCodeInterpreterOutputLogs(@type, additionalBinaryDataProperties, logs); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutputLogs)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalCodeInterpreterOutputLogs IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalCodeInterpreterOutputLogs)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalCodeInterpreterOutput PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalCodeInterpreterOutputLogs(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutputLogs)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterOutputLogs.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterOutputLogs.cs new file mode 100644 index 000000000000..1b7f2d6f8bb2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterOutputLogs.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalCodeInterpreterOutputLogs : InternalCodeInterpreterOutput + { + /// Initializes a new instance of . + /// The logs output from the code interpreter. + /// is null. + public InternalCodeInterpreterOutputLogs(string logs) : base(CodeInterpreterOutputType.Logs) + { + Argument.AssertNotNull(logs, nameof(logs)); + + Logs = logs; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The logs output from the code interpreter. + internal InternalCodeInterpreterOutputLogs(CodeInterpreterOutputType @type, IDictionary additionalBinaryDataProperties, string logs) : base(@type, additionalBinaryDataProperties) + { + Logs = logs; + } + + /// The logs output from the code interpreter. + public string Logs { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterTool.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterTool.Serialization.cs new file mode 100644 index 000000000000..8ef402fbd856 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterTool.Serialization.cs @@ -0,0 +1,138 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalCodeInterpreterTool : AgentTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalCodeInterpreterTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("container"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Container); +#else + using (JsonDocument document = JsonDocument.Parse(Container)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalCodeInterpreterTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalCodeInterpreterTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCodeInterpreterTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalCodeInterpreterTool DeserializeInternalCodeInterpreterTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + BinaryData container = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("container"u8)) + { + container = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalCodeInterpreterTool(@type, additionalBinaryDataProperties, container); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalCodeInterpreterTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalCodeInterpreterTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalCodeInterpreterTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterTool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterTool.cs new file mode 100644 index 000000000000..36ff789bb001 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterTool.cs @@ -0,0 +1,81 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalCodeInterpreterTool : AgentTool + { + /// Initializes a new instance of . + /// + /// The code interpreter container. Can be a container ID or an object that + /// specifies uploaded file IDs to make available to your code. + /// + /// is null. + public InternalCodeInterpreterTool(BinaryData container) : base(ToolType.CodeInterpreter) + { + Argument.AssertNotNull(container, nameof(container)); + + Container = container; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// + /// The code interpreter container. Can be a container ID or an object that + /// specifies uploaded file IDs to make available to your code. + /// + internal InternalCodeInterpreterTool(ToolType @type, IDictionary additionalBinaryDataProperties, BinaryData container) : base(@type, additionalBinaryDataProperties) + { + Container = container; + } + + /// + /// The code interpreter container. Can be a container ID or an object that + /// specifies uploaded file IDs to make available to your code. + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// . + /// + /// + /// + /// + /// + /// 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" }. + /// + /// + /// + /// + public BinaryData Container { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterToolAuto.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterToolAuto.Serialization.cs new file mode 100644 index 000000000000..23710ff6f7c2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterToolAuto.Serialization.cs @@ -0,0 +1,171 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalCodeInterpreterToolAuto : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolAuto)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (Optional.IsCollectionDefined(FileIds)) + { + writer.WritePropertyName("file_ids"u8); + writer.WriteStartArray(); + foreach (string item in FileIds) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalCodeInterpreterToolAuto IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalCodeInterpreterToolAuto JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolAuto)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCodeInterpreterToolAuto(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalCodeInterpreterToolAuto DeserializeInternalCodeInterpreterToolAuto(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = default; + IList fileIds = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("file_ids"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + fileIds = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalCodeInterpreterToolAuto(@type, fileIds ?? new ChangeTrackingList(), additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolAuto)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalCodeInterpreterToolAuto IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalCodeInterpreterToolAuto PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalCodeInterpreterToolAuto(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolAuto)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterToolAuto.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterToolAuto.cs new file mode 100644 index 000000000000..61c0b26c5bdf --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterToolAuto.cs @@ -0,0 +1,39 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalCodeInterpreterToolAuto + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public InternalCodeInterpreterToolAuto() + { + FileIds = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Always `auto`. + /// An optional list of uploaded files to make available to your code. + /// Keeps track of any properties unknown to the library. + internal InternalCodeInterpreterToolAuto(string @type, IList fileIds, IDictionary additionalBinaryDataProperties) + { + Type = @type; + FileIds = fileIds; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Always `auto`. + public string Type { get; } = "auto"; + + /// An optional list of uploaded files to make available to your code. + public IList FileIds { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterToolCallItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterToolCallItemParam.Serialization.cs new file mode 100644 index 000000000000..543b17fef35b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterToolCallItemParam.Serialization.cs @@ -0,0 +1,181 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalCodeInterpreterToolCallItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalCodeInterpreterToolCallItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolCallItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("container_id"u8); + writer.WriteStringValue(ContainerId); + if (Optional.IsDefined(Code)) + { + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code); + } + else + { + writer.WriteNull("code"u8); + } + if (Optional.IsCollectionDefined(Outputs)) + { + writer.WritePropertyName("outputs"u8); + writer.WriteStartArray(); + foreach (InternalCodeInterpreterOutput item in Outputs) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + else + { + writer.WriteNull("outputs"u8); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalCodeInterpreterToolCallItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalCodeInterpreterToolCallItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolCallItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCodeInterpreterToolCallItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalCodeInterpreterToolCallItemParam DeserializeInternalCodeInterpreterToolCallItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string containerId = default; + string code = default; + IList outputs = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("container_id"u8)) + { + containerId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("code"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + code = null; + continue; + } + code = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("outputs"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + outputs = new ChangeTrackingList(); + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalCodeInterpreterOutput.DeserializeInternalCodeInterpreterOutput(item, options)); + } + outputs = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalCodeInterpreterToolCallItemParam(@type, additionalBinaryDataProperties, containerId, code, outputs); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolCallItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalCodeInterpreterToolCallItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalCodeInterpreterToolCallItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalCodeInterpreterToolCallItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolCallItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterToolCallItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterToolCallItemParam.cs new file mode 100644 index 000000000000..fe75f147da01 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterToolCallItemParam.cs @@ -0,0 +1,59 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalCodeInterpreterToolCallItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The ID of the container used to run the code. + /// The code to run, or null if not available. + /// + /// The outputs generated by the code interpreter, such as logs or images. + /// Can be null if no outputs are available. + /// + /// is null. + public InternalCodeInterpreterToolCallItemParam(string containerId, string code, IEnumerable outputs) : base(AgentResponseItemKind.CodeInterpreterCall) + { + Argument.AssertNotNull(containerId, nameof(containerId)); + + ContainerId = containerId; + Code = code; + Outputs = outputs?.ToList(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The ID of the container used to run the code. + /// The code to run, or null if not available. + /// + /// The outputs generated by the code interpreter, such as logs or images. + /// Can be null if no outputs are available. + /// + internal InternalCodeInterpreterToolCallItemParam(AgentResponseItemKind @type, IDictionary additionalBinaryDataProperties, string containerId, string code, IList outputs) : base(@type, additionalBinaryDataProperties) + { + ContainerId = containerId; + Code = code; + Outputs = outputs; + } + + /// The ID of the container used to run the code. + public string ContainerId { get; } + + /// The code to run, or null if not available. + public string Code { get; } + + /// + /// The outputs generated by the code interpreter, such as logs or images. + /// Can be null if no outputs are available. + /// + public IList Outputs { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterToolCallItemResource.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterToolCallItemResource.Serialization.cs new file mode 100644 index 000000000000..fa3f653dcf7a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterToolCallItemResource.Serialization.cs @@ -0,0 +1,213 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalCodeInterpreterToolCallItemResource : AgentResponseItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalCodeInterpreterToolCallItemResource() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolCallItemResource)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + writer.WritePropertyName("container_id"u8); + writer.WriteStringValue(ContainerId); + if (Optional.IsDefined(Code)) + { + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code); + } + else + { + writer.WriteNull("code"u8); + } + if (Optional.IsCollectionDefined(Outputs)) + { + writer.WritePropertyName("outputs"u8); + writer.WriteStartArray(); + foreach (InternalCodeInterpreterOutput item in Outputs) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + else + { + writer.WriteNull("outputs"u8); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalCodeInterpreterToolCallItemResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalCodeInterpreterToolCallItemResource)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolCallItemResource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCodeInterpreterToolCallItemResource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalCodeInterpreterToolCallItemResource DeserializeInternalCodeInterpreterToolCallItemResource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + string id = default; + AgentResponseItemSource createdBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + CodeInterpreterToolCallItemResourceStatus status = default; + string containerId = default; + string code = default; + IList outputs = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdBy = AgentResponseItemSource.DeserializeAgentResponseItemSource(prop.Value, options); + continue; + } + if (prop.NameEquals("status"u8)) + { + status = new CodeInterpreterToolCallItemResourceStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("container_id"u8)) + { + containerId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("code"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + code = null; + continue; + } + code = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("outputs"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + outputs = new ChangeTrackingList(); + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalCodeInterpreterOutput.DeserializeInternalCodeInterpreterOutput(item, options)); + } + outputs = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalCodeInterpreterToolCallItemResource( + @type, + id, + createdBy, + additionalBinaryDataProperties, + status, + containerId, + code, + outputs); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolCallItemResource)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalCodeInterpreterToolCallItemResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalCodeInterpreterToolCallItemResource)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalCodeInterpreterToolCallItemResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolCallItemResource)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterToolCallItemResource.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterToolCallItemResource.cs new file mode 100644 index 000000000000..fc92e5fb0bf2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCodeInterpreterToolCallItemResource.cs @@ -0,0 +1,66 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalCodeInterpreterToolCallItemResource : AgentResponseItem + { + /// Initializes a new instance of . + /// + /// + /// The ID of the container used to run the code. + /// The code to run, or null if not available. + /// + /// The outputs generated by the code interpreter, such as logs or images. + /// Can be null if no outputs are available. + /// + internal InternalCodeInterpreterToolCallItemResource(string id, CodeInterpreterToolCallItemResourceStatus status, string containerId, string code, IEnumerable outputs) : base(AgentResponseItemKind.CodeInterpreterCall, id) + { + Status = status; + ContainerId = containerId; + Code = code; + Outputs = outputs?.ToList(); + } + + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + /// + /// The ID of the container used to run the code. + /// The code to run, or null if not available. + /// + /// The outputs generated by the code interpreter, such as logs or images. + /// Can be null if no outputs are available. + /// + internal InternalCodeInterpreterToolCallItemResource(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties, CodeInterpreterToolCallItemResourceStatus status, string containerId, string code, IList outputs) : base(@type, id, createdBy, additionalBinaryDataProperties) + { + Status = status; + ContainerId = containerId; + Code = code; + Outputs = outputs; + } + + /// Gets the Status. + public CodeInterpreterToolCallItemResourceStatus Status { get; } + + /// The ID of the container used to run the code. + public string ContainerId { get; } + + /// The code to run, or null if not available. + public string Code { get; } + + /// + /// The outputs generated by the code interpreter, such as logs or images. + /// Can be null if no outputs are available. + /// + public IList Outputs { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComparisonFilter.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComparisonFilter.Serialization.cs new file mode 100644 index 000000000000..cf36977e183c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComparisonFilter.Serialization.cs @@ -0,0 +1,162 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComparisonFilter : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComparisonFilter() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComparisonFilter)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + writer.WritePropertyName("key"u8); + writer.WriteStringValue(Key); + writer.WritePropertyName("value"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Value); +#else + using (JsonDocument document = JsonDocument.Parse(Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComparisonFilter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalComparisonFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComparisonFilter)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComparisonFilter(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComparisonFilter DeserializeInternalComparisonFilter(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComparisonFilterType @type = default; + string key = default; + BinaryData value = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ComparisonFilterType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("key"u8)) + { + key = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("value"u8)) + { + value = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComparisonFilter(@type, key, value, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComparisonFilter)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComparisonFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalComparisonFilter PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComparisonFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComparisonFilter)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComparisonFilter.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComparisonFilter.cs new file mode 100644 index 000000000000..74dc304bd7e5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComparisonFilter.cs @@ -0,0 +1,104 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComparisonFilter + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// Specifies the comparison operator: + /// `eq` (equal), `ne` (not equal), `gt` (greater than), `gte` (greater than or equal), `lt` (less than), `lte` (less than or equal). + /// + /// The key to compare against the value. + /// The value to compare against the attribute key; supports string, number, or boolean types. + /// or is null. + public InternalComparisonFilter(ComparisonFilterType @type, string key, BinaryData value) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + Type = @type; + Key = key; + Value = value; + } + + /// Initializes a new instance of . + /// + /// Specifies the comparison operator: + /// `eq` (equal), `ne` (not equal), `gt` (greater than), `gte` (greater than or equal), `lt` (less than), `lte` (less than or equal). + /// + /// The key to compare against the value. + /// The value to compare against the attribute key; supports string, number, or boolean types. + /// Keeps track of any properties unknown to the library. + internal InternalComparisonFilter(ComparisonFilterType @type, string key, BinaryData value, IDictionary additionalBinaryDataProperties) + { + Type = @type; + Key = key; + Value = value; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// Specifies the comparison operator: + /// `eq` (equal), `ne` (not equal), `gt` (greater than), `gte` (greater than or equal), `lt` (less than), `lte` (less than or equal). + /// + public ComparisonFilterType Type { get; set; } + + /// The key to compare against the value. + public string Key { get; set; } + + /// + /// The value to compare against the attribute key; supports string, number, or boolean types. + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// . + /// + /// + /// . + /// + /// + /// + /// + /// + /// 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" }. + /// + /// + /// + /// + public BinaryData Value { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCompoundFilter.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCompoundFilter.Serialization.cs new file mode 100644 index 000000000000..4950a849e9f1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCompoundFilter.Serialization.cs @@ -0,0 +1,176 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalCompoundFilter : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalCompoundFilter() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCompoundFilter)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + writer.WritePropertyName("filters"u8); + writer.WriteStartArray(); + foreach (BinaryData item in Filters) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item); +#else + using (JsonDocument document = JsonDocument.Parse(item)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndArray(); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalCompoundFilter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalCompoundFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCompoundFilter)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCompoundFilter(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalCompoundFilter DeserializeInternalCompoundFilter(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CompoundFilterType @type = default; + IList filters = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new CompoundFilterType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("filters"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(BinaryData.FromString(item.GetRawText())); + } + } + filters = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalCompoundFilter(@type, filters, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalCompoundFilter)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalCompoundFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalCompoundFilter PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalCompoundFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCompoundFilter)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCompoundFilter.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCompoundFilter.cs new file mode 100644 index 000000000000..1119df82820c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCompoundFilter.cs @@ -0,0 +1,85 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalCompoundFilter + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Type of operation: `and` or `or`. + /// Array of filters to combine. Items can be `ComparisonFilter` or `CompoundFilter`. + /// is null. + public InternalCompoundFilter(CompoundFilterType @type, IEnumerable filters) + { + Argument.AssertNotNull(filters, nameof(filters)); + + Type = @type; + Filters = filters.ToList(); + } + + /// Initializes a new instance of . + /// Type of operation: `and` or `or`. + /// Array of filters to combine. Items can be `ComparisonFilter` or `CompoundFilter`. + /// Keeps track of any properties unknown to the library. + internal InternalCompoundFilter(CompoundFilterType @type, IList filters, IDictionary additionalBinaryDataProperties) + { + Type = @type; + Filters = filters; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Type of operation: `and` or `or`. + public CompoundFilterType Type { get; set; } + + /// + /// Array of filters to combine. Items can be `ComparisonFilter` or `CompoundFilter`. + /// To assign an object to the element of this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// . + /// + /// + /// + /// + /// + /// 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" }. + /// + /// + /// + /// + public IList Filters { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerAction.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerAction.Serialization.cs new file mode 100644 index 000000000000..ad7fa206d6ce --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerAction.Serialization.cs @@ -0,0 +1,149 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + [PersistableModelProxy(typeof(UnknownComputerAction))] + internal abstract partial class InternalComputerAction : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerAction() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerAction)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToSerialString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalComputerAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerAction)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerAction(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerAction DeserializeInternalComputerAction(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "click": + return InternalComputerActionClick.DeserializeInternalComputerActionClick(element, options); + case "double_click": + return InternalComputerActionDoubleClick.DeserializeInternalComputerActionDoubleClick(element, options); + case "drag": + return InternalComputerActionDrag.DeserializeInternalComputerActionDrag(element, options); + case "move": + return InternalComputerActionMove.DeserializeInternalComputerActionMove(element, options); + case "screenshot": + return InternalComputerActionScreenshot.DeserializeInternalComputerActionScreenshot(element, options); + case "scroll": + return InternalComputerActionScroll.DeserializeInternalComputerActionScroll(element, options); + case "type": + return InternalComputerActionTypeKeys.DeserializeInternalComputerActionTypeKeys(element, options); + case "wait": + return InternalComputerActionWait.DeserializeInternalComputerActionWait(element, options); + case "keypress": + return InternalComputerActionKeyPress.DeserializeInternalComputerActionKeyPress(element, options); + } + } + return UnknownComputerAction.DeserializeUnknownComputerAction(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerAction)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalComputerAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerAction)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerAction.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerAction.cs new file mode 100644 index 000000000000..d1d1c81c85b4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerAction.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal abstract partial class InternalComputerAction + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + private protected InternalComputerAction(ComputerActionType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalComputerAction(ComputerActionType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Type. + internal ComputerActionType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionClick.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionClick.Serialization.cs new file mode 100644 index 000000000000..28759684c4f9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionClick.Serialization.cs @@ -0,0 +1,147 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComputerActionClick : InternalComputerAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerActionClick() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionClick)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("button"u8); + writer.WriteStringValue(Button.ToString()); + writer.WritePropertyName("x"u8); + writer.WriteNumberValue(X); + writer.WritePropertyName("y"u8); + writer.WriteNumberValue(Y); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerActionClick IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerActionClick)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalComputerAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionClick)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerActionClick(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerActionClick DeserializeInternalComputerActionClick(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComputerActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ComputerActionClickButton button = default; + int x = default; + int y = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToComputerActionType(); + continue; + } + if (prop.NameEquals("button"u8)) + { + button = new ComputerActionClickButton(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("x"u8)) + { + x = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("y"u8)) + { + y = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerActionClick(@type, additionalBinaryDataProperties, button, x, y); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerActionClick)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerActionClick IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerActionClick)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalComputerAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerActionClick(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerActionClick)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionClick.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionClick.cs new file mode 100644 index 000000000000..a5d8f0b777aa --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionClick.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalComputerActionClick : InternalComputerAction + { + /// Initializes a new instance of . + /// Indicates which mouse button was pressed during the click. One of `left`, `right`, `wheel`, `back`, or `forward`. + /// The x-coordinate where the click occurred. + /// The y-coordinate where the click occurred. + public InternalComputerActionClick(ComputerActionClickButton button, int x, int y) : base(ComputerActionType.Click) + { + Button = button; + X = x; + Y = y; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// Indicates which mouse button was pressed during the click. One of `left`, `right`, `wheel`, `back`, or `forward`. + /// The x-coordinate where the click occurred. + /// The y-coordinate where the click occurred. + internal InternalComputerActionClick(ComputerActionType @type, IDictionary additionalBinaryDataProperties, ComputerActionClickButton button, int x, int y) : base(@type, additionalBinaryDataProperties) + { + Button = button; + X = x; + Y = y; + } + + /// Indicates which mouse button was pressed during the click. One of `left`, `right`, `wheel`, `back`, or `forward`. + public ComputerActionClickButton Button { get; } + + /// The x-coordinate where the click occurred. + public int X { get; } + + /// The y-coordinate where the click occurred. + public int Y { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionDoubleClick.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionDoubleClick.Serialization.cs new file mode 100644 index 000000000000..381e38080553 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionDoubleClick.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComputerActionDoubleClick : InternalComputerAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerActionDoubleClick() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionDoubleClick)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("x"u8); + writer.WriteNumberValue(X); + writer.WritePropertyName("y"u8); + writer.WriteNumberValue(Y); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerActionDoubleClick IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerActionDoubleClick)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalComputerAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionDoubleClick)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerActionDoubleClick(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerActionDoubleClick DeserializeInternalComputerActionDoubleClick(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComputerActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + int x = default; + int y = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToComputerActionType(); + continue; + } + if (prop.NameEquals("x"u8)) + { + x = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("y"u8)) + { + y = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerActionDoubleClick(@type, additionalBinaryDataProperties, x, y); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerActionDoubleClick)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerActionDoubleClick IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerActionDoubleClick)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalComputerAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerActionDoubleClick(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerActionDoubleClick)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionDoubleClick.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionDoubleClick.cs new file mode 100644 index 000000000000..4d83bf7a0125 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionDoubleClick.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalComputerActionDoubleClick : InternalComputerAction + { + /// Initializes a new instance of . + /// The x-coordinate where the double click occurred. + /// The y-coordinate where the double click occurred. + public InternalComputerActionDoubleClick(int x, int y) : base(ComputerActionType.DoubleClick) + { + X = x; + Y = y; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The x-coordinate where the double click occurred. + /// The y-coordinate where the double click occurred. + internal InternalComputerActionDoubleClick(ComputerActionType @type, IDictionary additionalBinaryDataProperties, int x, int y) : base(@type, additionalBinaryDataProperties) + { + X = x; + Y = y; + } + + /// The x-coordinate where the double click occurred. + public int X { get; } + + /// The y-coordinate where the double click occurred. + public int Y { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionDrag.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionDrag.Serialization.cs new file mode 100644 index 000000000000..b20e938fae3c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionDrag.Serialization.cs @@ -0,0 +1,141 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComputerActionDrag : InternalComputerAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerActionDrag() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionDrag)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("path"u8); + writer.WriteStartArray(); + foreach (InternalCoordinate item in Path) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerActionDrag IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerActionDrag)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalComputerAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionDrag)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerActionDrag(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerActionDrag DeserializeInternalComputerActionDrag(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComputerActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList path = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToComputerActionType(); + continue; + } + if (prop.NameEquals("path"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalCoordinate.DeserializeInternalCoordinate(item, options)); + } + path = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerActionDrag(@type, additionalBinaryDataProperties, path); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerActionDrag)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerActionDrag IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerActionDrag)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalComputerAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerActionDrag(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerActionDrag)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionDrag.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionDrag.cs new file mode 100644 index 000000000000..532ea0fc7dde --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionDrag.cs @@ -0,0 +1,63 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComputerActionDrag : InternalComputerAction + { + /// Initializes a new instance of . + /// + /// An array of coordinates representing the path of the drag action. Coordinates will appear as an array + /// of objects, eg + /// ``` + /// [ + /// { x: 100, y: 200 }, + /// { x: 200, y: 300 } + /// ] + /// ``` + /// + /// is null. + public InternalComputerActionDrag(IEnumerable path) : base(ComputerActionType.Drag) + { + Argument.AssertNotNull(path, nameof(path)); + + Path = path.ToList(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// + /// An array of coordinates representing the path of the drag action. Coordinates will appear as an array + /// of objects, eg + /// ``` + /// [ + /// { x: 100, y: 200 }, + /// { x: 200, y: 300 } + /// ] + /// ``` + /// + internal InternalComputerActionDrag(ComputerActionType @type, IDictionary additionalBinaryDataProperties, IList path) : base(@type, additionalBinaryDataProperties) + { + Path = path; + } + + /// + /// An array of coordinates representing the path of the drag action. Coordinates will appear as an array + /// of objects, eg + /// ``` + /// [ + /// { x: 100, y: 200 }, + /// { x: 200, y: 300 } + /// ] + /// ``` + /// + public IList Path { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionKeyPress.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionKeyPress.Serialization.cs new file mode 100644 index 000000000000..440ee1f62b09 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionKeyPress.Serialization.cs @@ -0,0 +1,153 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComputerActionKeyPress : InternalComputerAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerActionKeyPress() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionKeyPress)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("keys"u8); + writer.WriteStartArray(); + foreach (string item in Keys) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerActionKeyPress IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerActionKeyPress)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalComputerAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionKeyPress)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerActionKeyPress(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerActionKeyPress DeserializeInternalComputerActionKeyPress(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComputerActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList keys = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToComputerActionType(); + continue; + } + if (prop.NameEquals("keys"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + keys = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerActionKeyPress(@type, additionalBinaryDataProperties, keys); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerActionKeyPress)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerActionKeyPress IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerActionKeyPress)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalComputerAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerActionKeyPress(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerActionKeyPress)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionKeyPress.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionKeyPress.cs new file mode 100644 index 000000000000..00e6fe9ef48f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionKeyPress.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComputerActionKeyPress : InternalComputerAction + { + /// Initializes a new instance of . + /// + /// The combination of keys the model is requesting to be pressed. This is an + /// array of strings, each representing a key. + /// + /// is null. + public InternalComputerActionKeyPress(IEnumerable keys) : base(ComputerActionType.Keypress) + { + Argument.AssertNotNull(keys, nameof(keys)); + + Keys = keys.ToList(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// + /// The combination of keys the model is requesting to be pressed. This is an + /// array of strings, each representing a key. + /// + internal InternalComputerActionKeyPress(ComputerActionType @type, IDictionary additionalBinaryDataProperties, IList keys) : base(@type, additionalBinaryDataProperties) + { + Keys = keys; + } + + /// + /// The combination of keys the model is requesting to be pressed. This is an + /// array of strings, each representing a key. + /// + public IList Keys { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionMove.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionMove.Serialization.cs new file mode 100644 index 000000000000..d429420d13af --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionMove.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComputerActionMove : InternalComputerAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerActionMove() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionMove)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("x"u8); + writer.WriteNumberValue(X); + writer.WritePropertyName("y"u8); + writer.WriteNumberValue(Y); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerActionMove IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerActionMove)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalComputerAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionMove)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerActionMove(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerActionMove DeserializeInternalComputerActionMove(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComputerActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + int x = default; + int y = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToComputerActionType(); + continue; + } + if (prop.NameEquals("x"u8)) + { + x = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("y"u8)) + { + y = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerActionMove(@type, additionalBinaryDataProperties, x, y); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerActionMove)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerActionMove IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerActionMove)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalComputerAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerActionMove(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerActionMove)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionMove.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionMove.cs new file mode 100644 index 000000000000..657fdc975cc4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionMove.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalComputerActionMove : InternalComputerAction + { + /// Initializes a new instance of . + /// The x-coordinate to move to. + /// The y-coordinate to move to. + public InternalComputerActionMove(int x, int y) : base(ComputerActionType.Move) + { + X = x; + Y = y; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The x-coordinate to move to. + /// The y-coordinate to move to. + internal InternalComputerActionMove(ComputerActionType @type, IDictionary additionalBinaryDataProperties, int x, int y) : base(@type, additionalBinaryDataProperties) + { + X = x; + Y = y; + } + + /// The x-coordinate to move to. + public int X { get; } + + /// The y-coordinate to move to. + public int Y { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionScreenshot.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionScreenshot.Serialization.cs new file mode 100644 index 000000000000..3e5b78ae3a5a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionScreenshot.Serialization.cs @@ -0,0 +1,118 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComputerActionScreenshot : InternalComputerAction, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionScreenshot)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerActionScreenshot IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerActionScreenshot)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalComputerAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionScreenshot)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerActionScreenshot(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerActionScreenshot DeserializeInternalComputerActionScreenshot(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComputerActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToComputerActionType(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerActionScreenshot(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerActionScreenshot)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerActionScreenshot IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerActionScreenshot)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalComputerAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerActionScreenshot(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerActionScreenshot)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionScreenshot.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionScreenshot.cs new file mode 100644 index 000000000000..844dbc5dc7b0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionScreenshot.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalComputerActionScreenshot : InternalComputerAction + { + /// Initializes a new instance of . + public InternalComputerActionScreenshot() : base(ComputerActionType.Screenshot) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalComputerActionScreenshot(ComputerActionType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionScroll.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionScroll.Serialization.cs new file mode 100644 index 000000000000..a865c3769331 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionScroll.Serialization.cs @@ -0,0 +1,161 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComputerActionScroll : InternalComputerAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerActionScroll() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionScroll)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("x"u8); + writer.WriteNumberValue(X); + writer.WritePropertyName("y"u8); + writer.WriteNumberValue(Y); + writer.WritePropertyName("scroll_x"u8); + writer.WriteNumberValue(ScrollX); + writer.WritePropertyName("scroll_y"u8); + writer.WriteNumberValue(ScrollY); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerActionScroll IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerActionScroll)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalComputerAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionScroll)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerActionScroll(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerActionScroll DeserializeInternalComputerActionScroll(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComputerActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + int x = default; + int y = default; + int scrollX = default; + int scrollY = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToComputerActionType(); + continue; + } + if (prop.NameEquals("x"u8)) + { + x = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("y"u8)) + { + y = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("scroll_x"u8)) + { + scrollX = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("scroll_y"u8)) + { + scrollY = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerActionScroll( + @type, + additionalBinaryDataProperties, + x, + y, + scrollX, + scrollY); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerActionScroll)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerActionScroll IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerActionScroll)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalComputerAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerActionScroll(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerActionScroll)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionScroll.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionScroll.cs new file mode 100644 index 000000000000..2babaf589794 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionScroll.cs @@ -0,0 +1,52 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalComputerActionScroll : InternalComputerAction + { + /// Initializes a new instance of . + /// The x-coordinate where the scroll occurred. + /// The y-coordinate where the scroll occurred. + /// The horizontal scroll distance. + /// The vertical scroll distance. + public InternalComputerActionScroll(int x, int y, int scrollX, int scrollY) : base(ComputerActionType.Scroll) + { + X = x; + Y = y; + ScrollX = scrollX; + ScrollY = scrollY; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The x-coordinate where the scroll occurred. + /// The y-coordinate where the scroll occurred. + /// The horizontal scroll distance. + /// The vertical scroll distance. + internal InternalComputerActionScroll(ComputerActionType @type, IDictionary additionalBinaryDataProperties, int x, int y, int scrollX, int scrollY) : base(@type, additionalBinaryDataProperties) + { + X = x; + Y = y; + ScrollX = scrollX; + ScrollY = scrollY; + } + + /// The x-coordinate where the scroll occurred. + public int X { get; } + + /// The y-coordinate where the scroll occurred. + public int Y { get; } + + /// The horizontal scroll distance. + public int ScrollX { get; } + + /// The vertical scroll distance. + public int ScrollY { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionTypeKeys.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionTypeKeys.Serialization.cs new file mode 100644 index 000000000000..bfef5fa75065 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionTypeKeys.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComputerActionTypeKeys : InternalComputerAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerActionTypeKeys() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionTypeKeys)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerActionTypeKeys IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerActionTypeKeys)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalComputerAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionTypeKeys)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerActionTypeKeys(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerActionTypeKeys DeserializeInternalComputerActionTypeKeys(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComputerActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string text = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToComputerActionType(); + continue; + } + if (prop.NameEquals("text"u8)) + { + text = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerActionTypeKeys(@type, additionalBinaryDataProperties, text); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerActionTypeKeys)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerActionTypeKeys IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerActionTypeKeys)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalComputerAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerActionTypeKeys(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerActionTypeKeys)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionTypeKeys.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionTypeKeys.cs new file mode 100644 index 000000000000..f9869abcf2e0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionTypeKeys.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComputerActionTypeKeys : InternalComputerAction + { + /// Initializes a new instance of . + /// The text to type. + /// is null. + public InternalComputerActionTypeKeys(string text) : base(ComputerActionType.Type) + { + Argument.AssertNotNull(text, nameof(text)); + + Text = text; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The text to type. + internal InternalComputerActionTypeKeys(ComputerActionType @type, IDictionary additionalBinaryDataProperties, string text) : base(@type, additionalBinaryDataProperties) + { + Text = text; + } + + /// The text to type. + public string Text { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionWait.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionWait.Serialization.cs new file mode 100644 index 000000000000..5daabca35e3f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionWait.Serialization.cs @@ -0,0 +1,118 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComputerActionWait : InternalComputerAction, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionWait)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerActionWait IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerActionWait)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalComputerAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionWait)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerActionWait(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerActionWait DeserializeInternalComputerActionWait(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComputerActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToComputerActionType(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerActionWait(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerActionWait)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerActionWait IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerActionWait)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalComputerAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerActionWait(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerActionWait)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionWait.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionWait.cs new file mode 100644 index 000000000000..f465b777fdc1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerActionWait.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalComputerActionWait : InternalComputerAction + { + /// Initializes a new instance of . + public InternalComputerActionWait() : base(ComputerActionType.Wait) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalComputerActionWait(ComputerActionType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallItemParam.Serialization.cs new file mode 100644 index 000000000000..4286a42f59e1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallItemParam.Serialization.cs @@ -0,0 +1,157 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComputerToolCallItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerToolCallItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("call_id"u8); + writer.WriteStringValue(CallId); + writer.WritePropertyName("action"u8); + writer.WriteObjectValue(Action, options); + writer.WritePropertyName("pending_safety_checks"u8); + writer.WriteStartArray(); + foreach (InternalComputerToolCallSafetyCheck item in PendingSafetyChecks) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerToolCallItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerToolCallItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerToolCallItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerToolCallItemParam DeserializeInternalComputerToolCallItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string callId = default; + InternalComputerAction action = default; + IList pendingSafetyChecks = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("call_id"u8)) + { + callId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("action"u8)) + { + action = InternalComputerAction.DeserializeInternalComputerAction(prop.Value, options); + continue; + } + if (prop.NameEquals("pending_safety_checks"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalComputerToolCallSafetyCheck.DeserializeInternalComputerToolCallSafetyCheck(item, options)); + } + pendingSafetyChecks = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerToolCallItemParam(@type, additionalBinaryDataProperties, callId, action, pendingSafetyChecks); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerToolCallItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerToolCallItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerToolCallItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallItemParam.cs new file mode 100644 index 000000000000..bff524a88ca7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallItemParam.cs @@ -0,0 +1,52 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComputerToolCallItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// An identifier used when responding to the tool call with output. + /// + /// The pending safety checks for the computer call. + /// , or is null. + public InternalComputerToolCallItemParam(string callId, InternalComputerAction action, IEnumerable pendingSafetyChecks) : base(AgentResponseItemKind.ComputerCall) + { + Argument.AssertNotNull(callId, nameof(callId)); + Argument.AssertNotNull(action, nameof(action)); + Argument.AssertNotNull(pendingSafetyChecks, nameof(pendingSafetyChecks)); + + CallId = callId; + Action = action; + PendingSafetyChecks = pendingSafetyChecks.ToList(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// An identifier used when responding to the tool call with output. + /// + /// The pending safety checks for the computer call. + internal InternalComputerToolCallItemParam(AgentResponseItemKind @type, IDictionary additionalBinaryDataProperties, string callId, InternalComputerAction action, IList pendingSafetyChecks) : base(@type, additionalBinaryDataProperties) + { + CallId = callId; + Action = action; + PendingSafetyChecks = pendingSafetyChecks; + } + + /// An identifier used when responding to the tool call with output. + public string CallId { get; } + + /// Gets the Action. + public InternalComputerAction Action { get; } + + /// The pending safety checks for the computer call. + public IList PendingSafetyChecks { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallItemResource.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallItemResource.Serialization.cs new file mode 100644 index 000000000000..e8451f6b1868 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallItemResource.Serialization.cs @@ -0,0 +1,189 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComputerToolCallItemResource : AgentResponseItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerToolCallItemResource() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallItemResource)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + writer.WritePropertyName("call_id"u8); + writer.WriteStringValue(CallId); + writer.WritePropertyName("action"u8); + writer.WriteObjectValue(Action, options); + writer.WritePropertyName("pending_safety_checks"u8); + writer.WriteStartArray(); + foreach (InternalComputerToolCallSafetyCheck item in PendingSafetyChecks) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerToolCallItemResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerToolCallItemResource)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallItemResource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerToolCallItemResource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerToolCallItemResource DeserializeInternalComputerToolCallItemResource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + string id = default; + AgentResponseItemSource createdBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ComputerToolCallItemResourceStatus status = default; + string callId = default; + InternalComputerAction action = default; + IList pendingSafetyChecks = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdBy = AgentResponseItemSource.DeserializeAgentResponseItemSource(prop.Value, options); + continue; + } + if (prop.NameEquals("status"u8)) + { + status = new ComputerToolCallItemResourceStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("call_id"u8)) + { + callId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("action"u8)) + { + action = InternalComputerAction.DeserializeInternalComputerAction(prop.Value, options); + continue; + } + if (prop.NameEquals("pending_safety_checks"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalComputerToolCallSafetyCheck.DeserializeInternalComputerToolCallSafetyCheck(item, options)); + } + pendingSafetyChecks = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerToolCallItemResource( + @type, + id, + createdBy, + additionalBinaryDataProperties, + status, + callId, + action, + pendingSafetyChecks); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallItemResource)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerToolCallItemResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerToolCallItemResource)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerToolCallItemResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallItemResource)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallItemResource.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallItemResource.cs new file mode 100644 index 000000000000..28a772ab5bf6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallItemResource.cs @@ -0,0 +1,66 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComputerToolCallItemResource : AgentResponseItem + { + /// Initializes a new instance of . + /// + /// + /// The status of the item. One of `in_progress`, `completed`, or + /// `incomplete`. Populated when items are returned via API. + /// + /// An identifier used when responding to the tool call with output. + /// + /// The pending safety checks for the computer call. + internal InternalComputerToolCallItemResource(string id, ComputerToolCallItemResourceStatus status, string callId, InternalComputerAction action, IEnumerable pendingSafetyChecks) : base(AgentResponseItemKind.ComputerCall, id) + { + Status = status; + CallId = callId; + Action = action; + PendingSafetyChecks = pendingSafetyChecks.ToList(); + } + + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + /// + /// The status of the item. One of `in_progress`, `completed`, or + /// `incomplete`. Populated when items are returned via API. + /// + /// An identifier used when responding to the tool call with output. + /// + /// The pending safety checks for the computer call. + internal InternalComputerToolCallItemResource(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties, ComputerToolCallItemResourceStatus status, string callId, InternalComputerAction action, IList pendingSafetyChecks) : base(@type, id, createdBy, additionalBinaryDataProperties) + { + Status = status; + CallId = callId; + Action = action; + PendingSafetyChecks = pendingSafetyChecks; + } + + /// + /// The status of the item. One of `in_progress`, `completed`, or + /// `incomplete`. Populated when items are returned via API. + /// + public ComputerToolCallItemResourceStatus Status { get; } + + /// An identifier used when responding to the tool call with output. + public string CallId { get; } + + /// Gets the Action. + public InternalComputerAction Action { get; } + + /// The pending safety checks for the computer call. + public IList PendingSafetyChecks { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallOutputItemOutput.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallOutputItemOutput.Serialization.cs new file mode 100644 index 000000000000..f4a409e0e10d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallOutputItemOutput.Serialization.cs @@ -0,0 +1,133 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + [PersistableModelProxy(typeof(UnknownComputerToolCallOutputItemOutput))] + internal abstract partial class InternalComputerToolCallOutputItemOutput : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerToolCallOutputItemOutput() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemOutput)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerToolCallOutputItemOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalComputerToolCallOutputItemOutput JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemOutput)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerToolCallOutputItemOutput(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerToolCallOutputItemOutput DeserializeInternalComputerToolCallOutputItemOutput(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "computer_screenshot": + return InternalComputerToolCallOutputItemOutputComputerScreenshot.DeserializeInternalComputerToolCallOutputItemOutputComputerScreenshot(element, options); + } + } + return UnknownComputerToolCallOutputItemOutput.DeserializeUnknownComputerToolCallOutputItemOutput(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemOutput)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerToolCallOutputItemOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalComputerToolCallOutputItemOutput PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerToolCallOutputItemOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemOutput)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallOutputItemOutput.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallOutputItemOutput.cs new file mode 100644 index 000000000000..31524a00f895 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallOutputItemOutput.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal abstract partial class InternalComputerToolCallOutputItemOutput + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + private protected InternalComputerToolCallOutputItemOutput(ComputerToolCallOutputItemOutputType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalComputerToolCallOutputItemOutput(ComputerToolCallOutputItemOutputType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Type. + internal ComputerToolCallOutputItemOutputType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallOutputItemOutputComputerScreenshot.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallOutputItemOutputComputerScreenshot.Serialization.cs new file mode 100644 index 000000000000..3a2819e21a7d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallOutputItemOutputComputerScreenshot.Serialization.cs @@ -0,0 +1,140 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComputerToolCallOutputItemOutputComputerScreenshot : InternalComputerToolCallOutputItemOutput, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemOutputComputerScreenshot)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(ImageUrl)) + { + writer.WritePropertyName("image_url"u8); + writer.WriteStringValue(ImageUrl); + } + if (Optional.IsDefined(FileId)) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerToolCallOutputItemOutputComputerScreenshot IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerToolCallOutputItemOutputComputerScreenshot)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalComputerToolCallOutputItemOutput JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemOutputComputerScreenshot)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerToolCallOutputItemOutputComputerScreenshot(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerToolCallOutputItemOutputComputerScreenshot DeserializeInternalComputerToolCallOutputItemOutputComputerScreenshot(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComputerToolCallOutputItemOutputType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string imageUrl = default; + string fileId = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ComputerToolCallOutputItemOutputType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("image_url"u8)) + { + imageUrl = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("file_id"u8)) + { + fileId = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerToolCallOutputItemOutputComputerScreenshot(@type, additionalBinaryDataProperties, imageUrl, fileId); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemOutputComputerScreenshot)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerToolCallOutputItemOutputComputerScreenshot IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerToolCallOutputItemOutputComputerScreenshot)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalComputerToolCallOutputItemOutput PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerToolCallOutputItemOutputComputerScreenshot(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemOutputComputerScreenshot)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallOutputItemOutputComputerScreenshot.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallOutputItemOutputComputerScreenshot.cs new file mode 100644 index 000000000000..4ef6b0c3511c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallOutputItemOutputComputerScreenshot.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalComputerToolCallOutputItemOutputComputerScreenshot : InternalComputerToolCallOutputItemOutput + { + /// Initializes a new instance of . + public InternalComputerToolCallOutputItemOutputComputerScreenshot() : base(ComputerToolCallOutputItemOutputType.Screenshot) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// + /// + internal InternalComputerToolCallOutputItemOutputComputerScreenshot(ComputerToolCallOutputItemOutputType @type, IDictionary additionalBinaryDataProperties, string imageUrl, string fileId) : base(@type, additionalBinaryDataProperties) + { + ImageUrl = imageUrl; + FileId = fileId; + } + + /// Gets or sets the ImageUrl. + public string ImageUrl { get; set; } + + /// Gets or sets the FileId. + public string FileId { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallOutputItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallOutputItemParam.Serialization.cs new file mode 100644 index 000000000000..d4abaf7bb7b6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallOutputItemParam.Serialization.cs @@ -0,0 +1,164 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComputerToolCallOutputItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerToolCallOutputItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("call_id"u8); + writer.WriteStringValue(CallId); + if (Optional.IsCollectionDefined(AcknowledgedSafetyChecks)) + { + writer.WritePropertyName("acknowledged_safety_checks"u8); + writer.WriteStartArray(); + foreach (InternalComputerToolCallSafetyCheck item in AcknowledgedSafetyChecks) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + writer.WritePropertyName("output"u8); + writer.WriteObjectValue(Output, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerToolCallOutputItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerToolCallOutputItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerToolCallOutputItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerToolCallOutputItemParam DeserializeInternalComputerToolCallOutputItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string callId = default; + IList acknowledgedSafetyChecks = default; + InternalComputerToolCallOutputItemOutput output = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("call_id"u8)) + { + callId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("acknowledged_safety_checks"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalComputerToolCallSafetyCheck.DeserializeInternalComputerToolCallSafetyCheck(item, options)); + } + acknowledgedSafetyChecks = array; + continue; + } + if (prop.NameEquals("output"u8)) + { + output = InternalComputerToolCallOutputItemOutput.DeserializeInternalComputerToolCallOutputItemOutput(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerToolCallOutputItemParam(@type, additionalBinaryDataProperties, callId, acknowledgedSafetyChecks ?? new ChangeTrackingList(), output); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerToolCallOutputItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerToolCallOutputItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerToolCallOutputItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallOutputItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallOutputItemParam.cs new file mode 100644 index 000000000000..f9f8d0bb0394 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallOutputItemParam.cs @@ -0,0 +1,55 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComputerToolCallOutputItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The ID of the computer tool call that produced the output. + /// + /// or is null. + public InternalComputerToolCallOutputItemParam(string callId, InternalComputerToolCallOutputItemOutput output) : base(AgentResponseItemKind.ComputerCallOutput) + { + Argument.AssertNotNull(callId, nameof(callId)); + Argument.AssertNotNull(output, nameof(output)); + + CallId = callId; + AcknowledgedSafetyChecks = new ChangeTrackingList(); + Output = output; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The ID of the computer tool call that produced the output. + /// + /// The safety checks reported by the API that have been acknowledged by the + /// developer. + /// + /// + internal InternalComputerToolCallOutputItemParam(AgentResponseItemKind @type, IDictionary additionalBinaryDataProperties, string callId, IList acknowledgedSafetyChecks, InternalComputerToolCallOutputItemOutput output) : base(@type, additionalBinaryDataProperties) + { + CallId = callId; + AcknowledgedSafetyChecks = acknowledgedSafetyChecks; + Output = output; + } + + /// The ID of the computer tool call that produced the output. + public string CallId { get; } + + /// + /// The safety checks reported by the API that have been acknowledged by the + /// developer. + /// + public IList AcknowledgedSafetyChecks { get; } + + /// Gets the Output. + public InternalComputerToolCallOutputItemOutput Output { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallOutputItemResource.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallOutputItemResource.Serialization.cs new file mode 100644 index 000000000000..677954729426 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallOutputItemResource.Serialization.cs @@ -0,0 +1,196 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComputerToolCallOutputItemResource : AgentResponseItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerToolCallOutputItemResource() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemResource)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + writer.WritePropertyName("call_id"u8); + writer.WriteStringValue(CallId); + if (Optional.IsCollectionDefined(AcknowledgedSafetyChecks)) + { + writer.WritePropertyName("acknowledged_safety_checks"u8); + writer.WriteStartArray(); + foreach (InternalComputerToolCallSafetyCheck item in AcknowledgedSafetyChecks) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + writer.WritePropertyName("output"u8); + writer.WriteObjectValue(Output, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerToolCallOutputItemResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerToolCallOutputItemResource)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemResource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerToolCallOutputItemResource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerToolCallOutputItemResource DeserializeInternalComputerToolCallOutputItemResource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + string id = default; + AgentResponseItemSource createdBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ComputerToolCallOutputItemResourceStatus status = default; + string callId = default; + IList acknowledgedSafetyChecks = default; + InternalComputerToolCallOutputItemOutput output = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdBy = AgentResponseItemSource.DeserializeAgentResponseItemSource(prop.Value, options); + continue; + } + if (prop.NameEquals("status"u8)) + { + status = new ComputerToolCallOutputItemResourceStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("call_id"u8)) + { + callId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("acknowledged_safety_checks"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalComputerToolCallSafetyCheck.DeserializeInternalComputerToolCallSafetyCheck(item, options)); + } + acknowledgedSafetyChecks = array; + continue; + } + if (prop.NameEquals("output"u8)) + { + output = InternalComputerToolCallOutputItemOutput.DeserializeInternalComputerToolCallOutputItemOutput(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerToolCallOutputItemResource( + @type, + id, + createdBy, + additionalBinaryDataProperties, + status, + callId, + acknowledgedSafetyChecks ?? new ChangeTrackingList(), + output); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemResource)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerToolCallOutputItemResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerToolCallOutputItemResource)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerToolCallOutputItemResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemResource)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallOutputItemResource.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallOutputItemResource.cs new file mode 100644 index 000000000000..4bb988fcd240 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallOutputItemResource.cs @@ -0,0 +1,70 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComputerToolCallOutputItemResource : AgentResponseItem + { + /// Initializes a new instance of . + /// + /// + /// The status of the item. One of `in_progress`, `completed`, or + /// `incomplete`. Populated when items are returned via API. + /// + /// The ID of the computer tool call that produced the output. + /// + internal InternalComputerToolCallOutputItemResource(string id, ComputerToolCallOutputItemResourceStatus status, string callId, InternalComputerToolCallOutputItemOutput output) : base(AgentResponseItemKind.ComputerCallOutput, id) + { + Status = status; + CallId = callId; + AcknowledgedSafetyChecks = new ChangeTrackingList(); + Output = output; + } + + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + /// + /// The status of the item. One of `in_progress`, `completed`, or + /// `incomplete`. Populated when items are returned via API. + /// + /// The ID of the computer tool call that produced the output. + /// + /// The safety checks reported by the API that have been acknowledged by the + /// developer. + /// + /// + internal InternalComputerToolCallOutputItemResource(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties, ComputerToolCallOutputItemResourceStatus status, string callId, IList acknowledgedSafetyChecks, InternalComputerToolCallOutputItemOutput output) : base(@type, id, createdBy, additionalBinaryDataProperties) + { + Status = status; + CallId = callId; + AcknowledgedSafetyChecks = acknowledgedSafetyChecks; + Output = output; + } + + /// + /// The status of the item. One of `in_progress`, `completed`, or + /// `incomplete`. Populated when items are returned via API. + /// + public ComputerToolCallOutputItemResourceStatus Status { get; } + + /// The ID of the computer tool call that produced the output. + public string CallId { get; } + + /// + /// The safety checks reported by the API that have been acknowledged by the + /// developer. + /// + public IList AcknowledgedSafetyChecks { get; } + + /// Gets the Output. + public InternalComputerToolCallOutputItemOutput Output { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallSafetyCheck.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallSafetyCheck.Serialization.cs new file mode 100644 index 000000000000..bf79f2bba8b2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallSafetyCheck.Serialization.cs @@ -0,0 +1,155 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComputerToolCallSafetyCheck : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerToolCallSafetyCheck() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallSafetyCheck)} does not support writing '{format}' format."); + } + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code); + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerToolCallSafetyCheck IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalComputerToolCallSafetyCheck JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallSafetyCheck)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerToolCallSafetyCheck(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerToolCallSafetyCheck DeserializeInternalComputerToolCallSafetyCheck(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string code = default; + string message = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("code"u8)) + { + code = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("message"u8)) + { + message = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerToolCallSafetyCheck(id, code, message, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallSafetyCheck)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerToolCallSafetyCheck IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalComputerToolCallSafetyCheck PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerToolCallSafetyCheck(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallSafetyCheck)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallSafetyCheck.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallSafetyCheck.cs new file mode 100644 index 000000000000..abd593285047 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerToolCallSafetyCheck.cs @@ -0,0 +1,54 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComputerToolCallSafetyCheck + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The ID of the pending safety check. + /// The type of the pending safety check. + /// Details about the pending safety check. + /// , or is null. + public InternalComputerToolCallSafetyCheck(string id, string code, string message) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(code, nameof(code)); + Argument.AssertNotNull(message, nameof(message)); + + Id = id; + Code = code; + Message = message; + } + + /// Initializes a new instance of . + /// The ID of the pending safety check. + /// The type of the pending safety check. + /// Details about the pending safety check. + /// Keeps track of any properties unknown to the library. + internal InternalComputerToolCallSafetyCheck(string id, string code, string message, IDictionary additionalBinaryDataProperties) + { + Id = id; + Code = code; + Message = message; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The ID of the pending safety check. + public string Id { get; } + + /// The type of the pending safety check. + public string Code { get; } + + /// Details about the pending safety check. + public string Message { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerUsePreviewTool.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerUsePreviewTool.Serialization.cs new file mode 100644 index 000000000000..5da46aea9ed8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerUsePreviewTool.Serialization.cs @@ -0,0 +1,147 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComputerUsePreviewTool : AgentTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerUsePreviewTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerUsePreviewTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("environment"u8); + writer.WriteStringValue(Environment.ToString()); + writer.WritePropertyName("display_width"u8); + writer.WriteNumberValue(DisplayWidth); + writer.WritePropertyName("display_height"u8); + writer.WriteNumberValue(DisplayHeight); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerUsePreviewTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerUsePreviewTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerUsePreviewTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerUsePreviewTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerUsePreviewTool DeserializeInternalComputerUsePreviewTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ComputerUsePreviewToolEnvironment environment = default; + int displayWidth = default; + int displayHeight = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("environment"u8)) + { + environment = new ComputerUsePreviewToolEnvironment(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("display_width"u8)) + { + displayWidth = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("display_height"u8)) + { + displayHeight = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerUsePreviewTool(@type, additionalBinaryDataProperties, environment, displayWidth, displayHeight); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerUsePreviewTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerUsePreviewTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerUsePreviewTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerUsePreviewTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerUsePreviewTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerUsePreviewTool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerUsePreviewTool.cs new file mode 100644 index 000000000000..9e31f17b23d7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalComputerUsePreviewTool.cs @@ -0,0 +1,46 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalComputerUsePreviewTool : AgentTool + { + /// Initializes a new instance of . + /// The type of computer environment to control. + /// The width of the computer display. + /// The height of the computer display. + public InternalComputerUsePreviewTool(ComputerUsePreviewToolEnvironment environment, int displayWidth, int displayHeight) : base(ToolType.ComputerUsePreview) + { + Environment = environment; + DisplayWidth = displayWidth; + DisplayHeight = displayHeight; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The type of computer environment to control. + /// The width of the computer display. + /// The height of the computer display. + internal InternalComputerUsePreviewTool(ToolType @type, IDictionary additionalBinaryDataProperties, ComputerUsePreviewToolEnvironment environment, int displayWidth, int displayHeight) : base(@type, additionalBinaryDataProperties) + { + Environment = environment; + DisplayWidth = displayWidth; + DisplayHeight = displayHeight; + } + + /// The type of computer environment to control. + public ComputerUsePreviewToolEnvironment Environment { get; set; } + + /// The width of the computer display. + public int DisplayWidth { get; set; } + + /// The height of the computer display. + public int DisplayHeight { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalConversationList.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalConversationList.Serialization.cs new file mode 100644 index 000000000000..46c529231f41 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalConversationList.Serialization.cs @@ -0,0 +1,187 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace Azure.AI.Projects +{ + internal partial class InternalConversationList : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalConversationList() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalConversationList)} does not support writing '{format}' format."); + } + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (ProjectConversation item in Data) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object); + writer.WritePropertyName("first_id"u8); + writer.WriteStringValue(FirstId); + writer.WritePropertyName("last_id"u8); + writer.WriteStringValue(LastId); + writer.WritePropertyName("has_more"u8); + writer.WriteBooleanValue(HasMore); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalConversationList IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalConversationList JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalConversationList)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalConversationList(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalConversationList DeserializeInternalConversationList(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList data = default; + string @object = default; + string firstId = default; + string lastId = default; + bool hasMore = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("data"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ProjectConversation.DeserializeProjectConversation(item, options)); + } + data = array; + continue; + } + if (prop.NameEquals("object"u8)) + { + @object = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("first_id"u8)) + { + firstId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("last_id"u8)) + { + lastId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("has_more"u8)) + { + hasMore = prop.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalConversationList( + data, + @object, + firstId, + lastId, + hasMore, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalConversationList)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalConversationList IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalConversationList PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalConversationList(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalConversationList)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalConversationList.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalConversationList.cs new file mode 100644 index 000000000000..97f41bd2e791 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalConversationList.cs @@ -0,0 +1,62 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects.OpenAI; + +namespace Azure.AI.Projects +{ + internal partial class InternalConversationList + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// A list of items used to generate this response. + /// ID of the first item in the returned page. + /// ID of the last item in the returned page. + /// Whether more items are available after this page. + internal InternalConversationList(IEnumerable data, string firstId, string lastId, bool hasMore) + { + Data = data.ToList(); + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + } + + /// Initializes a new instance of . + /// A list of items used to generate this response. + /// The object type. Always 'list'. + /// ID of the first item in the returned page. + /// ID of the last item in the returned page. + /// Whether more items are available after this page. + /// Keeps track of any properties unknown to the library. + internal InternalConversationList(IList data, string @object, string firstId, string lastId, bool hasMore, IDictionary additionalBinaryDataProperties) + { + Data = data; + Object = @object; + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// A list of items used to generate this response. + public IList Data { get; } + + /// The object type. Always 'list'. + public string Object { get; } = "list"; + + /// ID of the first item in the returned page. + public string FirstId { get; } + + /// ID of the last item in the returned page. + public string LastId { get; } + + /// Whether more items are available after this page. + public bool HasMore { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCoordinate.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCoordinate.Serialization.cs new file mode 100644 index 000000000000..ef7e178ed198 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCoordinate.Serialization.cs @@ -0,0 +1,147 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalCoordinate : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalCoordinate() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCoordinate)} does not support writing '{format}' format."); + } + writer.WritePropertyName("x"u8); + writer.WriteNumberValue(X); + writer.WritePropertyName("y"u8); + writer.WriteNumberValue(Y); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalCoordinate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalCoordinate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCoordinate)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCoordinate(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalCoordinate DeserializeInternalCoordinate(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int x = default; + int y = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("x"u8)) + { + x = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("y"u8)) + { + y = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalCoordinate(x, y, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalCoordinate)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalCoordinate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalCoordinate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalCoordinate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCoordinate)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCoordinate.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCoordinate.cs new file mode 100644 index 000000000000..57ffeb0aa353 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalCoordinate.cs @@ -0,0 +1,41 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalCoordinate + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The x-coordinate. + /// The y-coordinate. + public InternalCoordinate(int x, int y) + { + X = x; + Y = y; + } + + /// Initializes a new instance of . + /// The x-coordinate. + /// The y-coordinate. + /// Keeps track of any properties unknown to the library. + internal InternalCoordinate(int x, int y, IDictionary additionalBinaryDataProperties) + { + X = x; + Y = y; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The x-coordinate. + public int X { get; } + + /// The y-coordinate. + public int Y { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalEasyInputMessage.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalEasyInputMessage.Serialization.cs new file mode 100644 index 000000000000..ef2ac05896e2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalEasyInputMessage.Serialization.cs @@ -0,0 +1,154 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalEasyInputMessage : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalEasyInputMessage() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalEasyInputMessage)} does not support writing '{format}' format."); + } + writer.WritePropertyName("role"u8); + writer.WriteStringValue(Role); + writer.WritePropertyName("content"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Content); +#else + using (JsonDocument document = JsonDocument.Parse(Content)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalEasyInputMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalEasyInputMessage JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalEasyInputMessage)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalEasyInputMessage(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalEasyInputMessage DeserializeInternalEasyInputMessage(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string role = default; + BinaryData content = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("role"u8)) + { + role = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("content"u8)) + { + content = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalEasyInputMessage(role, content, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalEasyInputMessage)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalEasyInputMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalEasyInputMessage PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalEasyInputMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalEasyInputMessage)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalEasyInputMessage.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalEasyInputMessage.cs new file mode 100644 index 000000000000..6153ef4ac0b6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalEasyInputMessage.cs @@ -0,0 +1,85 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalEasyInputMessage + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// + /// or is null. + public InternalEasyInputMessage(string role, BinaryData content) + { + Argument.AssertNotNull(role, nameof(role)); + Argument.AssertNotNull(content, nameof(content)); + + Role = role; + Content = content; + } + + /// Initializes a new instance of . + /// + /// + /// Keeps track of any properties unknown to the library. + internal InternalEasyInputMessage(string role, BinaryData content, IDictionary additionalBinaryDataProperties) + { + Role = role; + Content = content; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Role. + public string Role { get; } + + /// + /// Gets the Content. + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// where T is of type . + /// + /// + /// + /// + /// + /// 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" }. + /// + /// + /// + /// + public BinaryData Content { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFileSearchTool.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFileSearchTool.Serialization.cs new file mode 100644 index 000000000000..62ff67f23076 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFileSearchTool.Serialization.cs @@ -0,0 +1,212 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalFileSearchTool : AgentTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalFileSearchTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFileSearchTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("vector_store_ids"u8); + writer.WriteStartArray(); + foreach (string item in VectorStoreIds) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + if (Optional.IsDefined(MaxNumResults)) + { + writer.WritePropertyName("max_num_results"u8); + writer.WriteNumberValue(MaxNumResults.Value); + } + if (Optional.IsDefined(RankingOptions)) + { + writer.WritePropertyName("ranking_options"u8); + writer.WriteObjectValue(RankingOptions, options); + } + if (Optional.IsDefined(Filters)) + { + writer.WritePropertyName("filters"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Filters); +#else + using (JsonDocument document = JsonDocument.Parse(Filters)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalFileSearchTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalFileSearchTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFileSearchTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFileSearchTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalFileSearchTool DeserializeInternalFileSearchTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList vectorStoreIds = default; + int? maxNumResults = default; + InternalRankingOptions rankingOptions = default; + BinaryData filters = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("vector_store_ids"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + vectorStoreIds = array; + continue; + } + if (prop.NameEquals("max_num_results"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxNumResults = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("ranking_options"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + rankingOptions = InternalRankingOptions.DeserializeInternalRankingOptions(prop.Value, options); + continue; + } + if (prop.NameEquals("filters"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + filters = null; + continue; + } + filters = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalFileSearchTool( + @type, + additionalBinaryDataProperties, + vectorStoreIds, + maxNumResults, + rankingOptions, + filters); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalFileSearchTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalFileSearchTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalFileSearchTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalFileSearchTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFileSearchTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFileSearchTool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFileSearchTool.cs new file mode 100644 index 000000000000..b91cf3db38f1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFileSearchTool.cs @@ -0,0 +1,90 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalFileSearchTool : AgentTool + { + /// Initializes a new instance of . + /// The IDs of the vector stores to search. + /// is null. + public InternalFileSearchTool(IEnumerable vectorStoreIds) : base(ToolType.FileSearch) + { + Argument.AssertNotNull(vectorStoreIds, nameof(vectorStoreIds)); + + VectorStoreIds = vectorStoreIds.ToList(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The IDs of the vector stores to search. + /// The maximum number of results to return. This number should be between 1 and 50 inclusive. + /// Ranking options for search. + /// A filter to apply. + internal InternalFileSearchTool(ToolType @type, IDictionary additionalBinaryDataProperties, IList vectorStoreIds, int? maxNumResults, InternalRankingOptions rankingOptions, BinaryData filters) : base(@type, additionalBinaryDataProperties) + { + VectorStoreIds = vectorStoreIds; + MaxNumResults = maxNumResults; + RankingOptions = rankingOptions; + Filters = filters; + } + + /// The IDs of the vector stores to search. + public IList VectorStoreIds { get; } + + /// The maximum number of results to return. This number should be between 1 and 50 inclusive. + public int? MaxNumResults { get; set; } + + /// Ranking options for search. + public InternalRankingOptions RankingOptions { get; set; } + + /// + /// A filter to apply. + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// . + /// + /// + /// + /// + /// + /// 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" }. + /// + /// + /// + /// + public BinaryData Filters { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFileSearchToolCallItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFileSearchToolCallItemParam.Serialization.cs new file mode 100644 index 000000000000..52116984d27f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFileSearchToolCallItemParam.Serialization.cs @@ -0,0 +1,178 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalFileSearchToolCallItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalFileSearchToolCallItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFileSearchToolCallItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("queries"u8); + writer.WriteStartArray(); + foreach (string item in Queries) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + if (Optional.IsCollectionDefined(Results)) + { + writer.WritePropertyName("results"u8); + writer.WriteStartArray(); + foreach (InternalFileSearchToolCallItemParamResult item in Results) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalFileSearchToolCallItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalFileSearchToolCallItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFileSearchToolCallItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFileSearchToolCallItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalFileSearchToolCallItemParam DeserializeInternalFileSearchToolCallItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList queries = default; + IList results = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("queries"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + queries = array; + continue; + } + if (prop.NameEquals("results"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalFileSearchToolCallItemParamResult.DeserializeInternalFileSearchToolCallItemParamResult(item, options)); + } + results = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalFileSearchToolCallItemParam(@type, additionalBinaryDataProperties, queries, results ?? new ChangeTrackingList()); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalFileSearchToolCallItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalFileSearchToolCallItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalFileSearchToolCallItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalFileSearchToolCallItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFileSearchToolCallItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFileSearchToolCallItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFileSearchToolCallItemParam.cs new file mode 100644 index 000000000000..cc315ebf5de8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFileSearchToolCallItemParam.cs @@ -0,0 +1,42 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalFileSearchToolCallItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The queries used to search for files. + /// is null. + public InternalFileSearchToolCallItemParam(IEnumerable queries) : base(AgentResponseItemKind.FileSearchCall) + { + Argument.AssertNotNull(queries, nameof(queries)); + + Queries = queries.ToList(); + Results = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The queries used to search for files. + /// The results of the file search tool call. + internal InternalFileSearchToolCallItemParam(AgentResponseItemKind @type, IDictionary additionalBinaryDataProperties, IList queries, IList results) : base(@type, additionalBinaryDataProperties) + { + Queries = queries; + Results = results; + } + + /// The queries used to search for files. + public IList Queries { get; } + + /// The results of the file search tool call. + public IList Results { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFileSearchToolCallItemParamResult.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFileSearchToolCallItemParamResult.Serialization.cs new file mode 100644 index 000000000000..8c7618605556 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFileSearchToolCallItemParamResult.Serialization.cs @@ -0,0 +1,195 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalFileSearchToolCallItemParamResult : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFileSearchToolCallItemParamResult)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(FileId)) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + if (Optional.IsDefined(Text)) + { + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + if (Optional.IsDefined(Filename)) + { + writer.WritePropertyName("filename"u8); + writer.WriteStringValue(Filename); + } + if (Optional.IsDefined(Attributes)) + { + writer.WritePropertyName("attributes"u8); + writer.WriteObjectValue(Attributes, options); + } + if (Optional.IsDefined(Score)) + { + writer.WritePropertyName("score"u8); + writer.WriteNumberValue(Score.Value); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalFileSearchToolCallItemParamResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalFileSearchToolCallItemParamResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFileSearchToolCallItemParamResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFileSearchToolCallItemParamResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalFileSearchToolCallItemParamResult DeserializeInternalFileSearchToolCallItemParamResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + string text = default; + string filename = default; + InternalVectorStoreFileAttributes attributes = default; + float? score = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("file_id"u8)) + { + fileId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("text"u8)) + { + text = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("filename"u8)) + { + filename = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("attributes"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + attributes = InternalVectorStoreFileAttributes.DeserializeInternalVectorStoreFileAttributes(prop.Value, options); + continue; + } + if (prop.NameEquals("score"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + score = prop.Value.GetSingle(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalFileSearchToolCallItemParamResult( + fileId, + text, + filename, + attributes, + score, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalFileSearchToolCallItemParamResult)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalFileSearchToolCallItemParamResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalFileSearchToolCallItemParamResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalFileSearchToolCallItemParamResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFileSearchToolCallItemParamResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFileSearchToolCallItemParamResult.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFileSearchToolCallItemParamResult.cs new file mode 100644 index 000000000000..b2408da8496a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFileSearchToolCallItemParamResult.cs @@ -0,0 +1,52 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalFileSearchToolCallItemParamResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public InternalFileSearchToolCallItemParamResult() + { + } + + /// Initializes a new instance of . + /// The unique ID of the file. + /// The text that was retrieved from the file. + /// The name of the file. + /// + /// The relevance score of the file - a value between 0 and 1. + /// Keeps track of any properties unknown to the library. + internal InternalFileSearchToolCallItemParamResult(string fileId, string text, string filename, InternalVectorStoreFileAttributes attributes, float? score, IDictionary additionalBinaryDataProperties) + { + FileId = fileId; + Text = text; + Filename = filename; + Attributes = attributes; + Score = score; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The unique ID of the file. + public string FileId { get; set; } + + /// The text that was retrieved from the file. + public string Text { get; set; } + + /// The name of the file. + public string Filename { get; set; } + + /// Gets or sets the Attributes. + public InternalVectorStoreFileAttributes Attributes { get; set; } + + /// The relevance score of the file - a value between 0 and 1. + public float? Score { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFileSearchToolCallItemResource.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFileSearchToolCallItemResource.Serialization.cs new file mode 100644 index 000000000000..e0e4a7a247db --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFileSearchToolCallItemResource.Serialization.cs @@ -0,0 +1,209 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalFileSearchToolCallItemResource : AgentResponseItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalFileSearchToolCallItemResource() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFileSearchToolCallItemResource)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + writer.WritePropertyName("queries"u8); + writer.WriteStartArray(); + foreach (string item in Queries) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + if (Optional.IsCollectionDefined(Results)) + { + writer.WritePropertyName("results"u8); + writer.WriteStartArray(); + foreach (InternalFileSearchToolCallItemParamResult item in Results) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalFileSearchToolCallItemResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalFileSearchToolCallItemResource)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFileSearchToolCallItemResource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFileSearchToolCallItemResource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalFileSearchToolCallItemResource DeserializeInternalFileSearchToolCallItemResource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + string id = default; + AgentResponseItemSource createdBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + FileSearchToolCallItemResourceStatus status = default; + IList queries = default; + IList results = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdBy = AgentResponseItemSource.DeserializeAgentResponseItemSource(prop.Value, options); + continue; + } + if (prop.NameEquals("status"u8)) + { + status = new FileSearchToolCallItemResourceStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("queries"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + queries = array; + continue; + } + if (prop.NameEquals("results"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalFileSearchToolCallItemParamResult.DeserializeInternalFileSearchToolCallItemParamResult(item, options)); + } + results = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalFileSearchToolCallItemResource( + @type, + id, + createdBy, + additionalBinaryDataProperties, + status, + queries, + results ?? new ChangeTrackingList()); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalFileSearchToolCallItemResource)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalFileSearchToolCallItemResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalFileSearchToolCallItemResource)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalFileSearchToolCallItemResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFileSearchToolCallItemResource)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFileSearchToolCallItemResource.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFileSearchToolCallItemResource.cs new file mode 100644 index 000000000000..c36eb7178971 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFileSearchToolCallItemResource.cs @@ -0,0 +1,58 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalFileSearchToolCallItemResource : AgentResponseItem + { + /// Initializes a new instance of . + /// + /// + /// The status of the file search tool call. One of `in_progress`, + /// `searching`, `incomplete` or `failed`, + /// + /// The queries used to search for files. + internal InternalFileSearchToolCallItemResource(string id, FileSearchToolCallItemResourceStatus status, IEnumerable queries) : base(AgentResponseItemKind.FileSearchCall, id) + { + Status = status; + Queries = queries.ToList(); + Results = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + /// + /// The status of the file search tool call. One of `in_progress`, + /// `searching`, `incomplete` or `failed`, + /// + /// The queries used to search for files. + /// The results of the file search tool call. + internal InternalFileSearchToolCallItemResource(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties, FileSearchToolCallItemResourceStatus status, IList queries, IList results) : base(@type, id, createdBy, additionalBinaryDataProperties) + { + Status = status; + Queries = queries; + Results = results; + } + + /// + /// The status of the file search tool call. One of `in_progress`, + /// `searching`, `incomplete` or `failed`, + /// + public FileSearchToolCallItemResourceStatus Status { get; } + + /// The queries used to search for files. + public IList Queries { get; } + + /// The results of the file search tool call. + public IList Results { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionTool.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionTool.Serialization.cs new file mode 100644 index 000000000000..fd350c60855c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionTool.Serialization.cs @@ -0,0 +1,200 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalFunctionTool : AgentTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalFunctionTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFunctionTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(Parameters)) + { + writer.WritePropertyName("parameters"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Parameters); +#else + using (JsonDocument document = JsonDocument.Parse(Parameters)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + else + { + writer.WriteNull("parameters"u8); + } + if (Optional.IsDefined(Strict)) + { + writer.WritePropertyName("strict"u8); + writer.WriteBooleanValue(Strict.Value); + } + else + { + writer.WriteNull("strict"u8); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalFunctionTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalFunctionTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFunctionTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFunctionTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalFunctionTool DeserializeInternalFunctionTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string name = default; + string description = default; + BinaryData parameters = default; + bool? strict = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("description"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + description = null; + continue; + } + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("parameters"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + parameters = null; + continue; + } + parameters = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("strict"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + strict = null; + continue; + } + strict = prop.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalFunctionTool( + @type, + additionalBinaryDataProperties, + name, + description, + parameters, + strict); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalFunctionTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalFunctionTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalFunctionTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalFunctionTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFunctionTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionTool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionTool.cs new file mode 100644 index 000000000000..2d166a09a6fd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionTool.cs @@ -0,0 +1,80 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalFunctionTool : AgentTool + { + /// Initializes a new instance of . + /// The name of the function to call. + /// A JSON schema object describing the parameters of the function. + /// Whether to enforce strict parameter validation. Default `true`. + /// is null. + public InternalFunctionTool(string name, BinaryData parameters, bool? strict) : base(ToolType.Function) + { + Argument.AssertNotNull(name, nameof(name)); + + Name = name; + Parameters = parameters; + Strict = strict; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The name of the function to call. + /// A description of the function. Used by the model to determine whether or not to call the function. + /// A JSON schema object describing the parameters of the function. + /// Whether to enforce strict parameter validation. Default `true`. + internal InternalFunctionTool(ToolType @type, IDictionary additionalBinaryDataProperties, string name, string description, BinaryData parameters, bool? strict) : base(@type, additionalBinaryDataProperties) + { + Name = name; + Description = description; + Parameters = parameters; + Strict = strict; + } + + /// The name of the function to call. + public string Name { get; set; } + + /// A description of the function. Used by the model to determine whether or not to call the function. + public string Description { get; set; } + + /// + /// A JSON schema object describing the parameters of the function. + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData Parameters { get; set; } + + /// Whether to enforce strict parameter validation. Default `true`. + public bool? Strict { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionToolCallItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionToolCallItemParam.Serialization.cs new file mode 100644 index 000000000000..681e528d18a8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionToolCallItemParam.Serialization.cs @@ -0,0 +1,147 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalFunctionToolCallItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalFunctionToolCallItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFunctionToolCallItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("call_id"u8); + writer.WriteStringValue(CallId); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("arguments"u8); + writer.WriteStringValue(Arguments); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalFunctionToolCallItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalFunctionToolCallItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFunctionToolCallItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFunctionToolCallItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalFunctionToolCallItemParam DeserializeInternalFunctionToolCallItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string callId = default; + string name = default; + string arguments = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("call_id"u8)) + { + callId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("arguments"u8)) + { + arguments = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalFunctionToolCallItemParam(@type, additionalBinaryDataProperties, callId, name, arguments); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalFunctionToolCallItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalFunctionToolCallItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalFunctionToolCallItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalFunctionToolCallItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFunctionToolCallItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionToolCallItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionToolCallItemParam.cs new file mode 100644 index 000000000000..1aa7dad61f9e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionToolCallItemParam.cs @@ -0,0 +1,51 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalFunctionToolCallItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The unique ID of the function tool call generated by the model. + /// The name of the function to run. + /// A JSON string of the arguments to pass to the function. + /// , or is null. + public InternalFunctionToolCallItemParam(string callId, string name, string arguments) : base(AgentResponseItemKind.FunctionCall) + { + Argument.AssertNotNull(callId, nameof(callId)); + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(arguments, nameof(arguments)); + + CallId = callId; + Name = name; + Arguments = arguments; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The unique ID of the function tool call generated by the model. + /// The name of the function to run. + /// A JSON string of the arguments to pass to the function. + internal InternalFunctionToolCallItemParam(AgentResponseItemKind @type, IDictionary additionalBinaryDataProperties, string callId, string name, string arguments) : base(@type, additionalBinaryDataProperties) + { + CallId = callId; + Name = name; + Arguments = arguments; + } + + /// The unique ID of the function tool call generated by the model. + public string CallId { get; } + + /// The name of the function to run. + public string Name { get; } + + /// A JSON string of the arguments to pass to the function. + public string Arguments { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionToolCallItemResource.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionToolCallItemResource.Serialization.cs new file mode 100644 index 000000000000..10068c978dab --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionToolCallItemResource.Serialization.cs @@ -0,0 +1,179 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalFunctionToolCallItemResource : AgentResponseItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalFunctionToolCallItemResource() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFunctionToolCallItemResource)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + writer.WritePropertyName("call_id"u8); + writer.WriteStringValue(CallId); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("arguments"u8); + writer.WriteStringValue(Arguments); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalFunctionToolCallItemResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalFunctionToolCallItemResource)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFunctionToolCallItemResource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFunctionToolCallItemResource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalFunctionToolCallItemResource DeserializeInternalFunctionToolCallItemResource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + string id = default; + AgentResponseItemSource createdBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + FunctionToolCallItemResourceStatus status = default; + string callId = default; + string name = default; + string arguments = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdBy = AgentResponseItemSource.DeserializeAgentResponseItemSource(prop.Value, options); + continue; + } + if (prop.NameEquals("status"u8)) + { + status = new FunctionToolCallItemResourceStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("call_id"u8)) + { + callId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("arguments"u8)) + { + arguments = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalFunctionToolCallItemResource( + @type, + id, + createdBy, + additionalBinaryDataProperties, + status, + callId, + name, + arguments); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalFunctionToolCallItemResource)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalFunctionToolCallItemResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalFunctionToolCallItemResource)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalFunctionToolCallItemResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFunctionToolCallItemResource)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionToolCallItemResource.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionToolCallItemResource.cs new file mode 100644 index 000000000000..b000b60cc112 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionToolCallItemResource.cs @@ -0,0 +1,65 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalFunctionToolCallItemResource : AgentResponseItem + { + /// Initializes a new instance of . + /// + /// + /// The status of the item. One of `in_progress`, `completed`, or + /// `incomplete`. Populated when items are returned via API. + /// + /// The unique ID of the function tool call generated by the model. + /// The name of the function to run. + /// A JSON string of the arguments to pass to the function. + internal InternalFunctionToolCallItemResource(string id, FunctionToolCallItemResourceStatus status, string callId, string name, string arguments) : base(AgentResponseItemKind.FunctionCall, id) + { + Status = status; + CallId = callId; + Name = name; + Arguments = arguments; + } + + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + /// + /// The status of the item. One of `in_progress`, `completed`, or + /// `incomplete`. Populated when items are returned via API. + /// + /// The unique ID of the function tool call generated by the model. + /// The name of the function to run. + /// A JSON string of the arguments to pass to the function. + internal InternalFunctionToolCallItemResource(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties, FunctionToolCallItemResourceStatus status, string callId, string name, string arguments) : base(@type, id, createdBy, additionalBinaryDataProperties) + { + Status = status; + CallId = callId; + Name = name; + Arguments = arguments; + } + + /// + /// The status of the item. One of `in_progress`, `completed`, or + /// `incomplete`. Populated when items are returned via API. + /// + public FunctionToolCallItemResourceStatus Status { get; } + + /// The unique ID of the function tool call generated by the model. + public string CallId { get; } + + /// The name of the function to run. + public string Name { get; } + + /// A JSON string of the arguments to pass to the function. + public string Arguments { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionToolCallOutputItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionToolCallOutputItemParam.Serialization.cs new file mode 100644 index 000000000000..579fa0496731 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionToolCallOutputItemParam.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalFunctionToolCallOutputItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalFunctionToolCallOutputItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFunctionToolCallOutputItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("call_id"u8); + writer.WriteStringValue(CallId); + writer.WritePropertyName("output"u8); + writer.WriteStringValue(Output); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalFunctionToolCallOutputItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalFunctionToolCallOutputItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFunctionToolCallOutputItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFunctionToolCallOutputItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalFunctionToolCallOutputItemParam DeserializeInternalFunctionToolCallOutputItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string callId = default; + string output = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("call_id"u8)) + { + callId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("output"u8)) + { + output = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalFunctionToolCallOutputItemParam(@type, additionalBinaryDataProperties, callId, output); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalFunctionToolCallOutputItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalFunctionToolCallOutputItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalFunctionToolCallOutputItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalFunctionToolCallOutputItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFunctionToolCallOutputItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionToolCallOutputItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionToolCallOutputItemParam.cs new file mode 100644 index 000000000000..7f6279aba246 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionToolCallOutputItemParam.cs @@ -0,0 +1,43 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalFunctionToolCallOutputItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The unique ID of the function tool call generated by the model. + /// A JSON string of the output of the function tool call. + /// or is null. + public InternalFunctionToolCallOutputItemParam(string callId, string output) : base(AgentResponseItemKind.FunctionCallOutput) + { + Argument.AssertNotNull(callId, nameof(callId)); + Argument.AssertNotNull(output, nameof(output)); + + CallId = callId; + Output = output; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The unique ID of the function tool call generated by the model. + /// A JSON string of the output of the function tool call. + internal InternalFunctionToolCallOutputItemParam(AgentResponseItemKind @type, IDictionary additionalBinaryDataProperties, string callId, string output) : base(@type, additionalBinaryDataProperties) + { + CallId = callId; + Output = output; + } + + /// The unique ID of the function tool call generated by the model. + public string CallId { get; } + + /// A JSON string of the output of the function tool call. + public string Output { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionToolCallOutputItemResource.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionToolCallOutputItemResource.Serialization.cs new file mode 100644 index 000000000000..657d40dbf9e1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionToolCallOutputItemResource.Serialization.cs @@ -0,0 +1,170 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalFunctionToolCallOutputItemResource : AgentResponseItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalFunctionToolCallOutputItemResource() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFunctionToolCallOutputItemResource)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + writer.WritePropertyName("call_id"u8); + writer.WriteStringValue(CallId); + writer.WritePropertyName("output"u8); + writer.WriteStringValue(Output); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalFunctionToolCallOutputItemResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalFunctionToolCallOutputItemResource)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFunctionToolCallOutputItemResource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFunctionToolCallOutputItemResource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalFunctionToolCallOutputItemResource DeserializeInternalFunctionToolCallOutputItemResource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + string id = default; + AgentResponseItemSource createdBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + FunctionToolCallOutputItemResourceStatus status = default; + string callId = default; + string output = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdBy = AgentResponseItemSource.DeserializeAgentResponseItemSource(prop.Value, options); + continue; + } + if (prop.NameEquals("status"u8)) + { + status = new FunctionToolCallOutputItemResourceStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("call_id"u8)) + { + callId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("output"u8)) + { + output = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalFunctionToolCallOutputItemResource( + @type, + id, + createdBy, + additionalBinaryDataProperties, + status, + callId, + output); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalFunctionToolCallOutputItemResource)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalFunctionToolCallOutputItemResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalFunctionToolCallOutputItemResource)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalFunctionToolCallOutputItemResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFunctionToolCallOutputItemResource)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionToolCallOutputItemResource.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionToolCallOutputItemResource.cs new file mode 100644 index 000000000000..4f8733657bb2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalFunctionToolCallOutputItemResource.cs @@ -0,0 +1,58 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalFunctionToolCallOutputItemResource : AgentResponseItem + { + /// Initializes a new instance of . + /// + /// + /// The status of the item. One of `in_progress`, `completed`, or + /// `incomplete`. Populated when items are returned via API. + /// + /// The unique ID of the function tool call generated by the model. + /// A JSON string of the output of the function tool call. + internal InternalFunctionToolCallOutputItemResource(string id, FunctionToolCallOutputItemResourceStatus status, string callId, string output) : base(AgentResponseItemKind.FunctionCallOutput, id) + { + Status = status; + CallId = callId; + Output = output; + } + + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + /// + /// The status of the item. One of `in_progress`, `completed`, or + /// `incomplete`. Populated when items are returned via API. + /// + /// The unique ID of the function tool call generated by the model. + /// A JSON string of the output of the function tool call. + internal InternalFunctionToolCallOutputItemResource(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties, FunctionToolCallOutputItemResourceStatus status, string callId, string output) : base(@type, id, createdBy, additionalBinaryDataProperties) + { + Status = status; + CallId = callId; + Output = output; + } + + /// + /// The status of the item. One of `in_progress`, `completed`, or + /// `incomplete`. Populated when items are returned via API. + /// + public FunctionToolCallOutputItemResourceStatus Status { get; } + + /// The unique ID of the function tool call generated by the model. + public string CallId { get; } + + /// A JSON string of the output of the function tool call. + public string Output { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalImageGenTool.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalImageGenTool.Serialization.cs new file mode 100644 index 000000000000..81e6a9fbcd16 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalImageGenTool.Serialization.cs @@ -0,0 +1,264 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalImageGenTool : AgentTool, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalImageGenTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Model)) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model.Value.ToString()); + } + if (Optional.IsDefined(Quality)) + { + writer.WritePropertyName("quality"u8); + writer.WriteStringValue(Quality.Value.ToString()); + } + if (Optional.IsDefined(Size)) + { + writer.WritePropertyName("size"u8); + writer.WriteStringValue(Size.Value.ToString()); + } + if (Optional.IsDefined(OutputFormat)) + { + writer.WritePropertyName("output_format"u8); + writer.WriteStringValue(OutputFormat.Value.ToString()); + } + if (Optional.IsDefined(OutputCompression)) + { + writer.WritePropertyName("output_compression"u8); + writer.WriteNumberValue(OutputCompression.Value); + } + if (Optional.IsDefined(Moderation)) + { + writer.WritePropertyName("moderation"u8); + writer.WriteStringValue(Moderation.Value.ToString()); + } + if (Optional.IsDefined(Background)) + { + writer.WritePropertyName("background"u8); + writer.WriteStringValue(Background.Value.ToString()); + } + if (Optional.IsDefined(InputImageMask)) + { + writer.WritePropertyName("input_image_mask"u8); + writer.WriteObjectValue(InputImageMask, options); + } + if (Optional.IsDefined(PartialImages)) + { + writer.WritePropertyName("partial_images"u8); + writer.WriteNumberValue(PartialImages.Value); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalImageGenTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalImageGenTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalImageGenTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalImageGenTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalImageGenTool DeserializeInternalImageGenTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ImageGenToolModel? model = default; + ImageGenToolQuality? quality = default; + ImageGenToolSize? size = default; + ImageGenToolOutputFormat? outputFormat = default; + int? outputCompression = default; + ImageGenToolModeration? moderation = default; + ImageGenToolBackground? background = default; + InternalImageGenToolInputImageMask inputImageMask = default; + int? partialImages = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("model"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + model = new ImageGenToolModel(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("quality"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + quality = new ImageGenToolQuality(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("size"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + size = new ImageGenToolSize(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("output_format"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + outputFormat = new ImageGenToolOutputFormat(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("output_compression"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + outputCompression = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("moderation"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + moderation = new ImageGenToolModeration(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("background"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + background = new ImageGenToolBackground(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("input_image_mask"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + inputImageMask = InternalImageGenToolInputImageMask.DeserializeInternalImageGenToolInputImageMask(prop.Value, options); + continue; + } + if (prop.NameEquals("partial_images"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + partialImages = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalImageGenTool( + @type, + additionalBinaryDataProperties, + model, + quality, + size, + outputFormat, + outputCompression, + moderation, + background, + inputImageMask, + partialImages); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalImageGenTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalImageGenTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalImageGenTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalImageGenTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalImageGenTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalImageGenTool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalImageGenTool.cs new file mode 100644 index 000000000000..2352f7be3256 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalImageGenTool.cs @@ -0,0 +1,100 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalImageGenTool : AgentTool + { + /// Initializes a new instance of . + public InternalImageGenTool() : base(ToolType.ImageGeneration) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The image generation model to use. Default: `gpt-image-1`. + /// + /// The quality of the generated image. One of `low`, `medium`, `high`, + /// or `auto`. Default: `auto`. + /// + /// + /// The size of the generated image. One of `1024x1024`, `1024x1536`, + /// `1536x1024`, or `auto`. Default: `auto`. + /// + /// + /// The output format of the generated image. One of `png`, `webp`, or + /// `jpeg`. Default: `png`. + /// + /// Compression level for the output image. Default: 100. + /// Moderation level for the generated image. Default: `auto`. + /// + /// Background type for the generated image. One of `transparent`, + /// `opaque`, or `auto`. Default: `auto`. + /// + /// + /// Optional mask for inpainting. Contains `image_url` + /// (string, optional) and `file_id` (string, optional). + /// + /// Number of partial images to generate in streaming mode, from 0 (default value) to 3. + internal InternalImageGenTool(ToolType @type, IDictionary additionalBinaryDataProperties, ImageGenToolModel? model, ImageGenToolQuality? quality, ImageGenToolSize? size, ImageGenToolOutputFormat? outputFormat, int? outputCompression, ImageGenToolModeration? moderation, ImageGenToolBackground? background, InternalImageGenToolInputImageMask inputImageMask, int? partialImages) : base(@type, additionalBinaryDataProperties) + { + Model = model; + Quality = quality; + Size = size; + OutputFormat = outputFormat; + OutputCompression = outputCompression; + Moderation = moderation; + Background = background; + InputImageMask = inputImageMask; + PartialImages = partialImages; + } + + /// The image generation model to use. Default: `gpt-image-1`. + public ImageGenToolModel? Model { get; set; } + + /// + /// The quality of the generated image. One of `low`, `medium`, `high`, + /// or `auto`. Default: `auto`. + /// + public ImageGenToolQuality? Quality { get; set; } + + /// + /// The size of the generated image. One of `1024x1024`, `1024x1536`, + /// `1536x1024`, or `auto`. Default: `auto`. + /// + public ImageGenToolSize? Size { get; set; } + + /// + /// The output format of the generated image. One of `png`, `webp`, or + /// `jpeg`. Default: `png`. + /// + public ImageGenToolOutputFormat? OutputFormat { get; set; } + + /// Compression level for the output image. Default: 100. + public int? OutputCompression { get; set; } + + /// Moderation level for the generated image. Default: `auto`. + public ImageGenToolModeration? Moderation { get; set; } + + /// + /// Background type for the generated image. One of `transparent`, + /// `opaque`, or `auto`. Default: `auto`. + /// + public ImageGenToolBackground? Background { get; set; } + + /// + /// Optional mask for inpainting. Contains `image_url` + /// (string, optional) and `file_id` (string, optional). + /// + public InternalImageGenToolInputImageMask InputImageMask { get; set; } + + /// Number of partial images to generate in streaming mode, from 0 (default value) to 3. + public int? PartialImages { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalImageGenToolCallItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalImageGenToolCallItemParam.Serialization.cs new file mode 100644 index 000000000000..f853090e3a91 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalImageGenToolCallItemParam.Serialization.cs @@ -0,0 +1,143 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalImageGenToolCallItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalImageGenToolCallItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalImageGenToolCallItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Result)) + { + writer.WritePropertyName("result"u8); + writer.WriteStringValue(Result); + } + else + { + writer.WriteNull("result"u8); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalImageGenToolCallItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalImageGenToolCallItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalImageGenToolCallItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalImageGenToolCallItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalImageGenToolCallItemParam DeserializeInternalImageGenToolCallItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string result = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("result"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + result = null; + continue; + } + result = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalImageGenToolCallItemParam(@type, additionalBinaryDataProperties, result); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalImageGenToolCallItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalImageGenToolCallItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalImageGenToolCallItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalImageGenToolCallItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalImageGenToolCallItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalImageGenToolCallItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalImageGenToolCallItemParam.cs new file mode 100644 index 000000000000..a8015e9ab6b7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalImageGenToolCallItemParam.cs @@ -0,0 +1,32 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalImageGenToolCallItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The generated image encoded in base64. + public InternalImageGenToolCallItemParam(string result) : base(AgentResponseItemKind.ImageGenerationCall) + { + Result = result; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The generated image encoded in base64. + internal InternalImageGenToolCallItemParam(AgentResponseItemKind @type, IDictionary additionalBinaryDataProperties, string result) : base(@type, additionalBinaryDataProperties) + { + Result = result; + } + + /// The generated image encoded in base64. + public string Result { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalImageGenToolCallItemResource.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalImageGenToolCallItemResource.Serialization.cs new file mode 100644 index 000000000000..e2983ea0965e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalImageGenToolCallItemResource.Serialization.cs @@ -0,0 +1,173 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalImageGenToolCallItemResource : AgentResponseItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalImageGenToolCallItemResource() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalImageGenToolCallItemResource)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + if (Optional.IsDefined(Result)) + { + writer.WritePropertyName("result"u8); + writer.WriteStringValue(Result); + } + else + { + writer.WriteNull("result"u8); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalImageGenToolCallItemResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalImageGenToolCallItemResource)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalImageGenToolCallItemResource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalImageGenToolCallItemResource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalImageGenToolCallItemResource DeserializeInternalImageGenToolCallItemResource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + string id = default; + AgentResponseItemSource createdBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ImageGenToolCallItemResourceStatus status = default; + string result = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdBy = AgentResponseItemSource.DeserializeAgentResponseItemSource(prop.Value, options); + continue; + } + if (prop.NameEquals("status"u8)) + { + status = new ImageGenToolCallItemResourceStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("result"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + result = null; + continue; + } + result = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalImageGenToolCallItemResource( + @type, + id, + createdBy, + additionalBinaryDataProperties, + status, + result); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalImageGenToolCallItemResource)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalImageGenToolCallItemResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalImageGenToolCallItemResource)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalImageGenToolCallItemResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalImageGenToolCallItemResource)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalImageGenToolCallItemResource.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalImageGenToolCallItemResource.cs new file mode 100644 index 000000000000..0fe63b3e0494 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalImageGenToolCallItemResource.cs @@ -0,0 +1,42 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalImageGenToolCallItemResource : AgentResponseItem + { + /// Initializes a new instance of . + /// + /// + /// The generated image encoded in base64. + internal InternalImageGenToolCallItemResource(string id, ImageGenToolCallItemResourceStatus status, string result) : base(AgentResponseItemKind.ImageGenerationCall, id) + { + Status = status; + Result = result; + } + + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + /// + /// The generated image encoded in base64. + internal InternalImageGenToolCallItemResource(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties, ImageGenToolCallItemResourceStatus status, string result) : base(@type, id, createdBy, additionalBinaryDataProperties) + { + Status = status; + Result = result; + } + + /// Gets the Status. + public ImageGenToolCallItemResourceStatus Status { get; } + + /// The generated image encoded in base64. + public string Result { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalImageGenToolInputImageMask.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalImageGenToolInputImageMask.Serialization.cs new file mode 100644 index 000000000000..2464366b7d89 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalImageGenToolInputImageMask.Serialization.cs @@ -0,0 +1,148 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalImageGenToolInputImageMask : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalImageGenToolInputImageMask)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(ImageUrl)) + { + writer.WritePropertyName("image_url"u8); + writer.WriteStringValue(ImageUrl); + } + if (Optional.IsDefined(FileId)) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalImageGenToolInputImageMask IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalImageGenToolInputImageMask JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalImageGenToolInputImageMask)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalImageGenToolInputImageMask(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalImageGenToolInputImageMask DeserializeInternalImageGenToolInputImageMask(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string imageUrl = default; + string fileId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("image_url"u8)) + { + imageUrl = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("file_id"u8)) + { + fileId = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalImageGenToolInputImageMask(imageUrl, fileId, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalImageGenToolInputImageMask)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalImageGenToolInputImageMask IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalImageGenToolInputImageMask PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalImageGenToolInputImageMask(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalImageGenToolInputImageMask)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalImageGenToolInputImageMask.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalImageGenToolInputImageMask.cs new file mode 100644 index 000000000000..d5139c3ce34c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalImageGenToolInputImageMask.cs @@ -0,0 +1,37 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalImageGenToolInputImageMask + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public InternalImageGenToolInputImageMask() + { + } + + /// Initializes a new instance of . + /// Base64-encoded mask image. + /// File ID for the mask image. + /// Keeps track of any properties unknown to the library. + internal InternalImageGenToolInputImageMask(string imageUrl, string fileId, IDictionary additionalBinaryDataProperties) + { + ImageUrl = imageUrl; + FileId = fileId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Base64-encoded mask image. + public string ImageUrl { get; set; } + + /// File ID for the mask image. + public string FileId { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContent.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContent.Serialization.cs new file mode 100644 index 000000000000..3f48b94b00a1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContent.Serialization.cs @@ -0,0 +1,145 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + [PersistableModelProxy(typeof(UnknownItemContent))] + internal abstract partial class InternalItemContent : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalItemContent() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContent)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToSerialString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalItemContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalItemContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalItemContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalItemContent DeserializeInternalItemContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "input_audio": + return InternalItemContentInputAudio.DeserializeInternalItemContentInputAudio(element, options); + case "output_audio": + return InternalItemContentOutputAudio.DeserializeInternalItemContentOutputAudio(element, options); + case "refusal": + return InternalItemContentRefusal.DeserializeInternalItemContentRefusal(element, options); + case "input_text": + return InternalItemContentInputText.DeserializeInternalItemContentInputText(element, options); + case "input_image": + return InternalItemContentInputImage.DeserializeInternalItemContentInputImage(element, options); + case "input_file": + return InternalItemContentInputFile.DeserializeInternalItemContentInputFile(element, options); + case "output_text": + return InternalItemContentOutputText.DeserializeInternalItemContentOutputText(element, options); + } + } + return UnknownItemContent.DeserializeUnknownItemContent(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalItemContent)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalItemContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalItemContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalItemContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalItemContent)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContent.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContent.cs new file mode 100644 index 000000000000..cfc9a9ff0418 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContent.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal abstract partial class InternalItemContent + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + private protected InternalItemContent(ItemContentType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalItemContent(ItemContentType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Type. + internal ItemContentType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentInputAudio.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentInputAudio.Serialization.cs new file mode 100644 index 000000000000..15b4fda38877 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentInputAudio.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalItemContentInputAudio : InternalItemContent, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalItemContentInputAudio() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentInputAudio)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("data"u8); + writer.WriteStringValue(Data); + writer.WritePropertyName("format"u8); + writer.WriteStringValue(Format.ToString()); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalItemContentInputAudio IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalItemContentInputAudio)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentInputAudio)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalItemContentInputAudio(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalItemContentInputAudio DeserializeInternalItemContentInputAudio(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemContentType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string data = default; + ItemContentInputAudioFormat format = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToItemContentType(); + continue; + } + if (prop.NameEquals("data"u8)) + { + data = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("format"u8)) + { + format = new ItemContentInputAudioFormat(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalItemContentInputAudio(@type, additionalBinaryDataProperties, data, format); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalItemContentInputAudio)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalItemContentInputAudio IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalItemContentInputAudio)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalItemContentInputAudio(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalItemContentInputAudio)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentInputAudio.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentInputAudio.cs new file mode 100644 index 000000000000..15a4e9f9b963 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentInputAudio.cs @@ -0,0 +1,51 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalItemContentInputAudio : InternalItemContent + { + /// Initializes a new instance of . + /// Base64-encoded audio data. + /// + /// The format of the audio data. Currently supported formats are `mp3` and + /// `wav`. + /// + /// is null. + public InternalItemContentInputAudio(string data, ItemContentInputAudioFormat format) : base(ItemContentType.InputAudio) + { + Argument.AssertNotNull(data, nameof(data)); + + Data = data; + Format = format; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// Base64-encoded audio data. + /// + /// The format of the audio data. Currently supported formats are `mp3` and + /// `wav`. + /// + internal InternalItemContentInputAudio(ItemContentType @type, IDictionary additionalBinaryDataProperties, string data, ItemContentInputAudioFormat format) : base(@type, additionalBinaryDataProperties) + { + Data = data; + Format = format; + } + + /// Base64-encoded audio data. + public string Data { get; } + + /// + /// The format of the audio data. Currently supported formats are `mp3` and + /// `wav`. + /// + public ItemContentInputAudioFormat Format { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentInputFile.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentInputFile.Serialization.cs new file mode 100644 index 000000000000..deaf7a26291e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentInputFile.Serialization.cs @@ -0,0 +1,156 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalItemContentInputFile : InternalItemContent, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentInputFile)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(FileId)) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + if (Optional.IsDefined(Filename)) + { + writer.WritePropertyName("filename"u8); + writer.WriteStringValue(Filename); + } + if (Optional.IsDefined(FileData)) + { + writer.WritePropertyName("file_data"u8); + writer.WriteStringValue(FileData); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalItemContentInputFile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalItemContentInputFile)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentInputFile)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalItemContentInputFile(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalItemContentInputFile DeserializeInternalItemContentInputFile(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemContentType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string fileId = default; + string filename = default; + string fileData = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToItemContentType(); + continue; + } + if (prop.NameEquals("file_id"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + fileId = null; + continue; + } + fileId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("filename"u8)) + { + filename = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("file_data"u8)) + { + fileData = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalItemContentInputFile(@type, additionalBinaryDataProperties, fileId, filename, fileData); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalItemContentInputFile)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalItemContentInputFile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalItemContentInputFile)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalItemContentInputFile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalItemContentInputFile)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentInputFile.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentInputFile.cs new file mode 100644 index 000000000000..f69e94685577 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentInputFile.cs @@ -0,0 +1,39 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalItemContentInputFile : InternalItemContent + { + /// Initializes a new instance of . + public InternalItemContentInputFile() : base(ItemContentType.InputFile) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The ID of the file to be sent to the model. + /// The name of the file to be sent to the model. + /// The content of the file to be sent to the model. + internal InternalItemContentInputFile(ItemContentType @type, IDictionary additionalBinaryDataProperties, string fileId, string filename, string fileData) : base(@type, additionalBinaryDataProperties) + { + FileId = fileId; + Filename = filename; + FileData = fileData; + } + + /// The ID of the file to be sent to the model. + public string FileId { get; set; } + + /// The name of the file to be sent to the model. + public string Filename { get; set; } + + /// The content of the file to be sent to the model. + public string FileData { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentInputImage.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentInputImage.Serialization.cs new file mode 100644 index 000000000000..138cb1d65a1b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentInputImage.Serialization.cs @@ -0,0 +1,165 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalItemContentInputImage : InternalItemContent, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentInputImage)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(ImageUrl)) + { + writer.WritePropertyName("image_url"u8); + writer.WriteStringValue(ImageUrl); + } + if (Optional.IsDefined(FileId)) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + if (Optional.IsDefined(Detail)) + { + writer.WritePropertyName("detail"u8); + writer.WriteStringValue(Detail.Value.ToString()); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalItemContentInputImage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalItemContentInputImage)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentInputImage)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalItemContentInputImage(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalItemContentInputImage DeserializeInternalItemContentInputImage(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemContentType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string imageUrl = default; + string fileId = default; + ItemContentInputImageDetail? detail = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToItemContentType(); + continue; + } + if (prop.NameEquals("image_url"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + imageUrl = null; + continue; + } + imageUrl = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("file_id"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + fileId = null; + continue; + } + fileId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("detail"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + detail = new ItemContentInputImageDetail(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalItemContentInputImage(@type, additionalBinaryDataProperties, imageUrl, fileId, detail); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalItemContentInputImage)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalItemContentInputImage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalItemContentInputImage)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalItemContentInputImage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalItemContentInputImage)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentInputImage.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentInputImage.cs new file mode 100644 index 000000000000..19dee8a19501 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentInputImage.cs @@ -0,0 +1,39 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalItemContentInputImage : InternalItemContent + { + /// Initializes a new instance of . + public InternalItemContentInputImage() : base(ItemContentType.InputImage) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL. + /// The ID of the file to be sent to the model. + /// The detail level of the image to be sent to the model. One of `high`, `low`, or `auto`. Defaults to `auto`. + internal InternalItemContentInputImage(ItemContentType @type, IDictionary additionalBinaryDataProperties, string imageUrl, string fileId, ItemContentInputImageDetail? detail) : base(@type, additionalBinaryDataProperties) + { + ImageUrl = imageUrl; + FileId = fileId; + Detail = detail; + } + + /// The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL. + public string ImageUrl { get; set; } + + /// The ID of the file to be sent to the model. + public string FileId { get; set; } + + /// The detail level of the image to be sent to the model. One of `high`, `low`, or `auto`. Defaults to `auto`. + public ItemContentInputImageDetail? Detail { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentInputText.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentInputText.Serialization.cs new file mode 100644 index 000000000000..8dec2247e959 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentInputText.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalItemContentInputText : InternalItemContent, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalItemContentInputText() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentInputText)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalItemContentInputText IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalItemContentInputText)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentInputText)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalItemContentInputText(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalItemContentInputText DeserializeInternalItemContentInputText(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemContentType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string text = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToItemContentType(); + continue; + } + if (prop.NameEquals("text"u8)) + { + text = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalItemContentInputText(@type, additionalBinaryDataProperties, text); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalItemContentInputText)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalItemContentInputText IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalItemContentInputText)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalItemContentInputText(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalItemContentInputText)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentInputText.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentInputText.cs new file mode 100644 index 000000000000..c8556b4b575b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentInputText.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalItemContentInputText : InternalItemContent + { + /// Initializes a new instance of . + /// The text input to the model. + /// is null. + public InternalItemContentInputText(string text) : base(ItemContentType.InputText) + { + Argument.AssertNotNull(text, nameof(text)); + + Text = text; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The text input to the model. + internal InternalItemContentInputText(ItemContentType @type, IDictionary additionalBinaryDataProperties, string text) : base(@type, additionalBinaryDataProperties) + { + Text = text; + } + + /// The text input to the model. + public string Text { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentOutputAudio.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentOutputAudio.Serialization.cs new file mode 100644 index 000000000000..f580b2725eb5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentOutputAudio.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalItemContentOutputAudio : InternalItemContent, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalItemContentOutputAudio() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentOutputAudio)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("data"u8); + writer.WriteStringValue(Data); + writer.WritePropertyName("transcript"u8); + writer.WriteStringValue(Transcript); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalItemContentOutputAudio IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalItemContentOutputAudio)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentOutputAudio)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalItemContentOutputAudio(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalItemContentOutputAudio DeserializeInternalItemContentOutputAudio(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemContentType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string data = default; + string transcript = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToItemContentType(); + continue; + } + if (prop.NameEquals("data"u8)) + { + data = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("transcript"u8)) + { + transcript = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalItemContentOutputAudio(@type, additionalBinaryDataProperties, data, transcript); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalItemContentOutputAudio)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalItemContentOutputAudio IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalItemContentOutputAudio)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalItemContentOutputAudio(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalItemContentOutputAudio)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentOutputAudio.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentOutputAudio.cs new file mode 100644 index 000000000000..8a469e33da32 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentOutputAudio.cs @@ -0,0 +1,43 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalItemContentOutputAudio : InternalItemContent + { + /// Initializes a new instance of . + /// Base64-encoded audio data from the model. + /// The transcript of the audio data from the model. + /// or is null. + public InternalItemContentOutputAudio(string data, string transcript) : base(ItemContentType.OutputAudio) + { + Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNull(transcript, nameof(transcript)); + + Data = data; + Transcript = transcript; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// Base64-encoded audio data from the model. + /// The transcript of the audio data from the model. + internal InternalItemContentOutputAudio(ItemContentType @type, IDictionary additionalBinaryDataProperties, string data, string transcript) : base(@type, additionalBinaryDataProperties) + { + Data = data; + Transcript = transcript; + } + + /// Base64-encoded audio data from the model. + public string Data { get; } + + /// The transcript of the audio data from the model. + public string Transcript { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentOutputText.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentOutputText.Serialization.cs new file mode 100644 index 000000000000..8c2606a4ad92 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentOutputText.Serialization.cs @@ -0,0 +1,174 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalItemContentOutputText : InternalItemContent, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalItemContentOutputText() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentOutputText)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + writer.WritePropertyName("annotations"u8); + writer.WriteStartArray(); + foreach (InternalAnnotation item in Annotations) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsCollectionDefined(Logprobs)) + { + writer.WritePropertyName("logprobs"u8); + writer.WriteStartArray(); + foreach (InternalLogProb item in Logprobs) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalItemContentOutputText IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalItemContentOutputText)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentOutputText)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalItemContentOutputText(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalItemContentOutputText DeserializeInternalItemContentOutputText(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemContentType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string text = default; + IList annotations = default; + IList logprobs = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToItemContentType(); + continue; + } + if (prop.NameEquals("text"u8)) + { + text = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("annotations"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalAnnotation.DeserializeInternalAnnotation(item, options)); + } + annotations = array; + continue; + } + if (prop.NameEquals("logprobs"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalLogProb.DeserializeInternalLogProb(item, options)); + } + logprobs = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalItemContentOutputText(@type, additionalBinaryDataProperties, text, annotations, logprobs ?? new ChangeTrackingList()); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalItemContentOutputText)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalItemContentOutputText IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalItemContentOutputText)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalItemContentOutputText(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalItemContentOutputText)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentOutputText.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentOutputText.cs new file mode 100644 index 000000000000..416ff306e5bc --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentOutputText.cs @@ -0,0 +1,50 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalItemContentOutputText : InternalItemContent + { + /// Initializes a new instance of . + /// The text output from the model. + /// The annotations of the text output. + /// or is null. + public InternalItemContentOutputText(string text, IEnumerable annotations) : base(ItemContentType.OutputText) + { + Argument.AssertNotNull(text, nameof(text)); + Argument.AssertNotNull(annotations, nameof(annotations)); + + Text = text; + Annotations = annotations.ToList(); + Logprobs = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The text output from the model. + /// The annotations of the text output. + /// + internal InternalItemContentOutputText(ItemContentType @type, IDictionary additionalBinaryDataProperties, string text, IList annotations, IList logprobs) : base(@type, additionalBinaryDataProperties) + { + Text = text; + Annotations = annotations; + Logprobs = logprobs; + } + + /// The text output from the model. + public string Text { get; } + + /// The annotations of the text output. + public IList Annotations { get; } + + /// Gets the Logprobs. + public IList Logprobs { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentRefusal.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentRefusal.Serialization.cs new file mode 100644 index 000000000000..8d30c1255acd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentRefusal.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalItemContentRefusal : InternalItemContent, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalItemContentRefusal() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentRefusal)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("refusal"u8); + writer.WriteStringValue(Refusal); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalItemContentRefusal IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalItemContentRefusal)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentRefusal)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalItemContentRefusal(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalItemContentRefusal DeserializeInternalItemContentRefusal(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemContentType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string refusal = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToItemContentType(); + continue; + } + if (prop.NameEquals("refusal"u8)) + { + refusal = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalItemContentRefusal(@type, additionalBinaryDataProperties, refusal); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalItemContentRefusal)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalItemContentRefusal IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalItemContentRefusal)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalItemContentRefusal(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalItemContentRefusal)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentRefusal.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentRefusal.cs new file mode 100644 index 000000000000..0b1c67bdc5df --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemContentRefusal.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalItemContentRefusal : InternalItemContent + { + /// Initializes a new instance of . + /// The refusal explanationfrom the model. + /// is null. + public InternalItemContentRefusal(string refusal) : base(ItemContentType.Refusal) + { + Argument.AssertNotNull(refusal, nameof(refusal)); + + Refusal = refusal; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The refusal explanationfrom the model. + internal InternalItemContentRefusal(ItemContentType @type, IDictionary additionalBinaryDataProperties, string refusal) : base(@type, additionalBinaryDataProperties) + { + Refusal = refusal; + } + + /// The refusal explanationfrom the model. + public string Refusal { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemParam.Serialization.cs new file mode 100644 index 000000000000..48aa296bb449 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemParam.Serialization.cs @@ -0,0 +1,114 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + [PersistableModelProxy(typeof(UnknownItemParam))] + internal abstract partial class InternalItemParam : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemParam)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalItemParam(document.RootElement, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemParam.cs new file mode 100644 index 000000000000..20b9696043a4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemParam.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + internal abstract partial class InternalItemParam + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + private protected InternalItemParam(AgentResponseItemKind @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalItemParam(AgentResponseItemKind @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Type. + internal AgentResponseItemKind Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemReferenceItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemReferenceItemParam.Serialization.cs new file mode 100644 index 000000000000..1dbd4174c7b8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemReferenceItemParam.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalItemReferenceItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalItemReferenceItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemReferenceItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalItemReferenceItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalItemReferenceItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemReferenceItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalItemReferenceItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalItemReferenceItemParam DeserializeInternalItemReferenceItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string id = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalItemReferenceItemParam(@type, additionalBinaryDataProperties, id); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalItemReferenceItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalItemReferenceItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalItemReferenceItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalItemReferenceItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalItemReferenceItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemReferenceItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemReferenceItemParam.cs new file mode 100644 index 000000000000..67fbc5ca63bb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalItemReferenceItemParam.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalItemReferenceItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The service-originated ID of the previously generated response item being referenced. + /// is null. + public InternalItemReferenceItemParam(string id) : base(AgentResponseItemKind.ItemReference) + { + Argument.AssertNotNull(id, nameof(id)); + + Id = id; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The service-originated ID of the previously generated response item being referenced. + internal InternalItemReferenceItemParam(AgentResponseItemKind @type, IDictionary additionalBinaryDataProperties, string id) : base(@type, additionalBinaryDataProperties) + { + Id = id; + } + + /// The service-originated ID of the previously generated response item being referenced. + public string Id { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLocalShellToolCallItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLocalShellToolCallItemParam.Serialization.cs new file mode 100644 index 000000000000..220757aad68d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLocalShellToolCallItemParam.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalLocalShellToolCallItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalLocalShellToolCallItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalLocalShellToolCallItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("call_id"u8); + writer.WriteStringValue(CallId); + writer.WritePropertyName("action"u8); + writer.WriteObjectValue(Action, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalLocalShellToolCallItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalLocalShellToolCallItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalLocalShellToolCallItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalLocalShellToolCallItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalLocalShellToolCallItemParam DeserializeInternalLocalShellToolCallItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string callId = default; + LocalShellAgentToolExecutionAction action = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("call_id"u8)) + { + callId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("action"u8)) + { + action = LocalShellAgentToolExecutionAction.DeserializeLocalShellAgentToolExecutionAction(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalLocalShellToolCallItemParam(@type, additionalBinaryDataProperties, callId, action); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalLocalShellToolCallItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalLocalShellToolCallItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalLocalShellToolCallItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalLocalShellToolCallItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalLocalShellToolCallItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLocalShellToolCallItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLocalShellToolCallItemParam.cs new file mode 100644 index 000000000000..5e5c8dc08a3a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLocalShellToolCallItemParam.cs @@ -0,0 +1,43 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalLocalShellToolCallItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The unique ID of the local shell tool call generated by the model. + /// + /// or is null. + public InternalLocalShellToolCallItemParam(string callId, LocalShellAgentToolExecutionAction action) : base(AgentResponseItemKind.LocalShellCall) + { + Argument.AssertNotNull(callId, nameof(callId)); + Argument.AssertNotNull(action, nameof(action)); + + CallId = callId; + Action = action; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The unique ID of the local shell tool call generated by the model. + /// + internal InternalLocalShellToolCallItemParam(AgentResponseItemKind @type, IDictionary additionalBinaryDataProperties, string callId, LocalShellAgentToolExecutionAction action) : base(@type, additionalBinaryDataProperties) + { + CallId = callId; + Action = action; + } + + /// The unique ID of the local shell tool call generated by the model. + public string CallId { get; } + + /// Gets the Action. + public LocalShellAgentToolExecutionAction Action { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLocalShellToolCallOutputItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLocalShellToolCallOutputItemParam.Serialization.cs new file mode 100644 index 000000000000..df4be8a713d9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLocalShellToolCallOutputItemParam.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalLocalShellToolCallOutputItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalLocalShellToolCallOutputItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalLocalShellToolCallOutputItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("output"u8); + writer.WriteStringValue(Output); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalLocalShellToolCallOutputItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalLocalShellToolCallOutputItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalLocalShellToolCallOutputItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalLocalShellToolCallOutputItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalLocalShellToolCallOutputItemParam DeserializeInternalLocalShellToolCallOutputItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string output = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("output"u8)) + { + output = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalLocalShellToolCallOutputItemParam(@type, additionalBinaryDataProperties, output); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalLocalShellToolCallOutputItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalLocalShellToolCallOutputItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalLocalShellToolCallOutputItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalLocalShellToolCallOutputItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalLocalShellToolCallOutputItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLocalShellToolCallOutputItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLocalShellToolCallOutputItemParam.cs new file mode 100644 index 000000000000..44520637e5c9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLocalShellToolCallOutputItemParam.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalLocalShellToolCallOutputItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// A JSON string of the output of the local shell tool call. + /// is null. + public InternalLocalShellToolCallOutputItemParam(string output) : base(AgentResponseItemKind.LocalShellCallOutput) + { + Argument.AssertNotNull(output, nameof(output)); + + Output = output; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// A JSON string of the output of the local shell tool call. + internal InternalLocalShellToolCallOutputItemParam(AgentResponseItemKind @type, IDictionary additionalBinaryDataProperties, string output) : base(@type, additionalBinaryDataProperties) + { + Output = output; + } + + /// A JSON string of the output of the local shell tool call. + public string Output { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLocalShellToolCallOutputItemResourceStatus.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLocalShellToolCallOutputItemResourceStatus.cs new file mode 100644 index 000000000000..21c62a4e153a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLocalShellToolCallOutputItemResourceStatus.cs @@ -0,0 +1,69 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct InternalLocalShellToolCallOutputItemResourceStatus : IEquatable + { + private readonly string _value; + private const string InProgressValue = "in_progress"; + private const string CompletedValue = "completed"; + private const string IncompleteValue = "incomplete"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public InternalLocalShellToolCallOutputItemResourceStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the InProgress. + public static InternalLocalShellToolCallOutputItemResourceStatus InProgress { get; } = new InternalLocalShellToolCallOutputItemResourceStatus(InProgressValue); + + /// Gets the Completed. + public static InternalLocalShellToolCallOutputItemResourceStatus Completed { get; } = new InternalLocalShellToolCallOutputItemResourceStatus(CompletedValue); + + /// Gets the Incomplete. + public static InternalLocalShellToolCallOutputItemResourceStatus Incomplete { get; } = new InternalLocalShellToolCallOutputItemResourceStatus(IncompleteValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(InternalLocalShellToolCallOutputItemResourceStatus left, InternalLocalShellToolCallOutputItemResourceStatus right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(InternalLocalShellToolCallOutputItemResourceStatus left, InternalLocalShellToolCallOutputItemResourceStatus right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator InternalLocalShellToolCallOutputItemResourceStatus(string value) => new InternalLocalShellToolCallOutputItemResourceStatus(value); + + /// Converts a string to a . + /// The value. + public static implicit operator InternalLocalShellToolCallOutputItemResourceStatus?(string value) => value == null ? null : new InternalLocalShellToolCallOutputItemResourceStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalLocalShellToolCallOutputItemResourceStatus other && Equals(other); + + /// + public bool Equals(InternalLocalShellToolCallOutputItemResourceStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLocation.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLocation.Serialization.cs new file mode 100644 index 000000000000..9b74ed76fe1b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLocation.Serialization.cs @@ -0,0 +1,133 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + [PersistableModelProxy(typeof(UnknownLocation))] + internal abstract partial class InternalLocation : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalLocation() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalLocation)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalLocation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalLocation JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalLocation)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalLocation(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalLocation DeserializeInternalLocation(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "approximate": + return InternalApproximateLocation.DeserializeInternalApproximateLocation(element, options); + } + } + return UnknownLocation.DeserializeUnknownLocation(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalLocation)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalLocation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalLocation PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalLocation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalLocation)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLocation.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLocation.cs new file mode 100644 index 000000000000..ae1142d7bec9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLocation.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal abstract partial class InternalLocation + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + private protected InternalLocation(LocationType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalLocation(LocationType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Type. + internal LocationType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLogProb.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLogProb.Serialization.cs new file mode 100644 index 000000000000..8977e66011d4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLogProb.Serialization.cs @@ -0,0 +1,183 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalLogProb : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalLogProb() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalLogProb)} does not support writing '{format}' format."); + } + writer.WritePropertyName("token"u8); + writer.WriteStringValue(Token); + writer.WritePropertyName("logprob"u8); + writer.WriteNumberValue(Logprob); + writer.WritePropertyName("bytes"u8); + writer.WriteStartArray(); + foreach (int item in Bytes) + { + writer.WriteNumberValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("top_logprobs"u8); + writer.WriteStartArray(); + foreach (InternalTopLogProb item in TopLogprobs) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalLogProb IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalLogProb JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalLogProb)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalLogProb(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalLogProb DeserializeInternalLogProb(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string token = default; + float logprob = default; + IList bytes = default; + IList topLogprobs = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("token"u8)) + { + token = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("logprob"u8)) + { + logprob = prop.Value.GetSingle(); + continue; + } + if (prop.NameEquals("bytes"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(item.GetInt32()); + } + bytes = array; + continue; + } + if (prop.NameEquals("top_logprobs"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalTopLogProb.DeserializeInternalTopLogProb(item, options)); + } + topLogprobs = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalLogProb(token, logprob, bytes, topLogprobs, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalLogProb)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalLogProb IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalLogProb PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalLogProb(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalLogProb)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLogProb.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLogProb.cs new file mode 100644 index 000000000000..bc79d5517889 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalLogProb.cs @@ -0,0 +1,62 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalLogProb + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// + /// + /// + /// , or is null. + public InternalLogProb(string token, float logprob, IEnumerable bytes, IEnumerable topLogprobs) + { + Argument.AssertNotNull(token, nameof(token)); + Argument.AssertNotNull(bytes, nameof(bytes)); + Argument.AssertNotNull(topLogprobs, nameof(topLogprobs)); + + Token = token; + Logprob = logprob; + Bytes = bytes.ToList(); + TopLogprobs = topLogprobs.ToList(); + } + + /// Initializes a new instance of . + /// + /// + /// + /// + /// Keeps track of any properties unknown to the library. + internal InternalLogProb(string token, float logprob, IList bytes, IList topLogprobs, IDictionary additionalBinaryDataProperties) + { + Token = token; + Logprob = logprob; + Bytes = bytes; + TopLogprobs = topLogprobs; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Token. + public string Token { get; } + + /// Gets the Logprob. + public float Logprob { get; } + + /// Gets the Bytes. + public IList Bytes { get; } + + /// Gets the TopLogprobs. + public IList TopLogprobs { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPApprovalRequestItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPApprovalRequestItemParam.Serialization.cs new file mode 100644 index 000000000000..ba3ca17b10c2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPApprovalRequestItemParam.Serialization.cs @@ -0,0 +1,147 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPApprovalRequestItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalMCPApprovalRequestItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPApprovalRequestItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("server_label"u8); + writer.WriteStringValue(ServerLabel); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("arguments"u8); + writer.WriteStringValue(Arguments); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMCPApprovalRequestItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalMCPApprovalRequestItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPApprovalRequestItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMCPApprovalRequestItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMCPApprovalRequestItemParam DeserializeInternalMCPApprovalRequestItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string serverLabel = default; + string name = default; + string arguments = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("server_label"u8)) + { + serverLabel = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("arguments"u8)) + { + arguments = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMCPApprovalRequestItemParam(@type, additionalBinaryDataProperties, serverLabel, name, arguments); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMCPApprovalRequestItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMCPApprovalRequestItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalMCPApprovalRequestItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMCPApprovalRequestItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMCPApprovalRequestItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPApprovalRequestItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPApprovalRequestItemParam.cs new file mode 100644 index 000000000000..86b867a0c012 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPApprovalRequestItemParam.cs @@ -0,0 +1,51 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPApprovalRequestItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The label of the MCP server making the request. + /// The name of the tool to run. + /// A JSON string of arguments for the tool. + /// , or is null. + public InternalMCPApprovalRequestItemParam(string serverLabel, string name, string arguments) : base(AgentResponseItemKind.McpApprovalRequest) + { + Argument.AssertNotNull(serverLabel, nameof(serverLabel)); + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(arguments, nameof(arguments)); + + ServerLabel = serverLabel; + Name = name; + Arguments = arguments; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The label of the MCP server making the request. + /// The name of the tool to run. + /// A JSON string of arguments for the tool. + internal InternalMCPApprovalRequestItemParam(AgentResponseItemKind @type, IDictionary additionalBinaryDataProperties, string serverLabel, string name, string arguments) : base(@type, additionalBinaryDataProperties) + { + ServerLabel = serverLabel; + Name = name; + Arguments = arguments; + } + + /// The label of the MCP server making the request. + public string ServerLabel { get; } + + /// The name of the tool to run. + public string Name { get; } + + /// A JSON string of arguments for the tool. + public string Arguments { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPApprovalRequestItemResource.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPApprovalRequestItemResource.Serialization.cs new file mode 100644 index 000000000000..b726b28d5e13 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPApprovalRequestItemResource.Serialization.cs @@ -0,0 +1,170 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPApprovalRequestItemResource : AgentResponseItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalMCPApprovalRequestItemResource() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPApprovalRequestItemResource)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("server_label"u8); + writer.WriteStringValue(ServerLabel); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("arguments"u8); + writer.WriteStringValue(Arguments); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMCPApprovalRequestItemResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalMCPApprovalRequestItemResource)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPApprovalRequestItemResource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMCPApprovalRequestItemResource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMCPApprovalRequestItemResource DeserializeInternalMCPApprovalRequestItemResource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + string id = default; + AgentResponseItemSource createdBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string serverLabel = default; + string name = default; + string arguments = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdBy = AgentResponseItemSource.DeserializeAgentResponseItemSource(prop.Value, options); + continue; + } + if (prop.NameEquals("server_label"u8)) + { + serverLabel = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("arguments"u8)) + { + arguments = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMCPApprovalRequestItemResource( + @type, + id, + createdBy, + additionalBinaryDataProperties, + serverLabel, + name, + arguments); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMCPApprovalRequestItemResource)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMCPApprovalRequestItemResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalMCPApprovalRequestItemResource)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMCPApprovalRequestItemResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMCPApprovalRequestItemResource)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPApprovalRequestItemResource.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPApprovalRequestItemResource.cs new file mode 100644 index 000000000000..581886e6cdf1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPApprovalRequestItemResource.cs @@ -0,0 +1,49 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPApprovalRequestItemResource : AgentResponseItem + { + /// Initializes a new instance of . + /// + /// The label of the MCP server making the request. + /// The name of the tool to run. + /// A JSON string of arguments for the tool. + internal InternalMCPApprovalRequestItemResource(string id, string serverLabel, string name, string arguments) : base(AgentResponseItemKind.McpApprovalRequest, id) + { + ServerLabel = serverLabel; + Name = name; + Arguments = arguments; + } + + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + /// The label of the MCP server making the request. + /// The name of the tool to run. + /// A JSON string of arguments for the tool. + internal InternalMCPApprovalRequestItemResource(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties, string serverLabel, string name, string arguments) : base(@type, id, createdBy, additionalBinaryDataProperties) + { + ServerLabel = serverLabel; + Name = name; + Arguments = arguments; + } + + /// The label of the MCP server making the request. + public string ServerLabel { get; } + + /// The name of the tool to run. + public string Name { get; } + + /// A JSON string of arguments for the tool. + public string Arguments { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPApprovalResponseItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPApprovalResponseItemParam.Serialization.cs new file mode 100644 index 000000000000..09e860b1084c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPApprovalResponseItemParam.Serialization.cs @@ -0,0 +1,155 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPApprovalResponseItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalMCPApprovalResponseItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPApprovalResponseItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("approval_request_id"u8); + writer.WriteStringValue(ApprovalRequestId); + writer.WritePropertyName("approve"u8); + writer.WriteBooleanValue(Approve); + if (Optional.IsDefined(Reason)) + { + writer.WritePropertyName("reason"u8); + writer.WriteStringValue(Reason); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMCPApprovalResponseItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalMCPApprovalResponseItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPApprovalResponseItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMCPApprovalResponseItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMCPApprovalResponseItemParam DeserializeInternalMCPApprovalResponseItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string approvalRequestId = default; + bool approve = default; + string reason = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("approval_request_id"u8)) + { + approvalRequestId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("approve"u8)) + { + approve = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("reason"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + reason = null; + continue; + } + reason = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMCPApprovalResponseItemParam(@type, additionalBinaryDataProperties, approvalRequestId, approve, reason); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMCPApprovalResponseItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMCPApprovalResponseItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalMCPApprovalResponseItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMCPApprovalResponseItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMCPApprovalResponseItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPApprovalResponseItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPApprovalResponseItemParam.cs new file mode 100644 index 000000000000..8eacd4b47a91 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPApprovalResponseItemParam.cs @@ -0,0 +1,47 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPApprovalResponseItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The ID of the approval request being answered. + /// Whether the request was approved. + /// is null. + public InternalMCPApprovalResponseItemParam(string approvalRequestId, bool approve) : base(AgentResponseItemKind.McpApprovalResponse) + { + Argument.AssertNotNull(approvalRequestId, nameof(approvalRequestId)); + + ApprovalRequestId = approvalRequestId; + Approve = approve; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The ID of the approval request being answered. + /// Whether the request was approved. + /// Optional reason for the decision. + internal InternalMCPApprovalResponseItemParam(AgentResponseItemKind @type, IDictionary additionalBinaryDataProperties, string approvalRequestId, bool approve, string reason) : base(@type, additionalBinaryDataProperties) + { + ApprovalRequestId = approvalRequestId; + Approve = approve; + Reason = reason; + } + + /// The ID of the approval request being answered. + public string ApprovalRequestId { get; } + + /// Whether the request was approved. + public bool Approve { get; } + + /// Optional reason for the decision. + public string Reason { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPApprovalResponseItemResource.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPApprovalResponseItemResource.Serialization.cs new file mode 100644 index 000000000000..2758e7a50493 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPApprovalResponseItemResource.Serialization.cs @@ -0,0 +1,178 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPApprovalResponseItemResource : AgentResponseItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalMCPApprovalResponseItemResource() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPApprovalResponseItemResource)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("approval_request_id"u8); + writer.WriteStringValue(ApprovalRequestId); + writer.WritePropertyName("approve"u8); + writer.WriteBooleanValue(Approve); + if (Optional.IsDefined(Reason)) + { + writer.WritePropertyName("reason"u8); + writer.WriteStringValue(Reason); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMCPApprovalResponseItemResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalMCPApprovalResponseItemResource)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPApprovalResponseItemResource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMCPApprovalResponseItemResource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMCPApprovalResponseItemResource DeserializeInternalMCPApprovalResponseItemResource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + string id = default; + AgentResponseItemSource createdBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string approvalRequestId = default; + bool approve = default; + string reason = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdBy = AgentResponseItemSource.DeserializeAgentResponseItemSource(prop.Value, options); + continue; + } + if (prop.NameEquals("approval_request_id"u8)) + { + approvalRequestId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("approve"u8)) + { + approve = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("reason"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + reason = null; + continue; + } + reason = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMCPApprovalResponseItemResource( + @type, + id, + createdBy, + additionalBinaryDataProperties, + approvalRequestId, + approve, + reason); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMCPApprovalResponseItemResource)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMCPApprovalResponseItemResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalMCPApprovalResponseItemResource)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMCPApprovalResponseItemResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMCPApprovalResponseItemResource)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPApprovalResponseItemResource.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPApprovalResponseItemResource.cs new file mode 100644 index 000000000000..fb270eb376c4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPApprovalResponseItemResource.cs @@ -0,0 +1,47 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPApprovalResponseItemResource : AgentResponseItem + { + /// Initializes a new instance of . + /// + /// The ID of the approval request being answered. + /// Whether the request was approved. + internal InternalMCPApprovalResponseItemResource(string id, string approvalRequestId, bool approve) : base(AgentResponseItemKind.McpApprovalResponse, id) + { + ApprovalRequestId = approvalRequestId; + Approve = approve; + } + + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + /// The ID of the approval request being answered. + /// Whether the request was approved. + /// Optional reason for the decision. + internal InternalMCPApprovalResponseItemResource(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties, string approvalRequestId, bool approve, string reason) : base(@type, id, createdBy, additionalBinaryDataProperties) + { + ApprovalRequestId = approvalRequestId; + Approve = approve; + Reason = reason; + } + + /// The ID of the approval request being answered. + public string ApprovalRequestId { get; } + + /// Whether the request was approved. + public bool Approve { get; } + + /// Optional reason for the decision. + public string Reason { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPCallItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPCallItemParam.Serialization.cs new file mode 100644 index 000000000000..3c3f7b579af5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPCallItemParam.Serialization.cs @@ -0,0 +1,186 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPCallItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalMCPCallItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPCallItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("server_label"u8); + writer.WriteStringValue(ServerLabel); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("arguments"u8); + writer.WriteStringValue(Arguments); + if (Optional.IsDefined(Output)) + { + writer.WritePropertyName("output"u8); + writer.WriteStringValue(Output); + } + if (Optional.IsDefined(Error)) + { + writer.WritePropertyName("error"u8); + writer.WriteStringValue(Error); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMCPCallItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalMCPCallItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPCallItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMCPCallItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMCPCallItemParam DeserializeInternalMCPCallItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string serverLabel = default; + string name = default; + string arguments = default; + string output = default; + string error = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("server_label"u8)) + { + serverLabel = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("arguments"u8)) + { + arguments = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("output"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + output = null; + continue; + } + output = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("error"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + error = null; + continue; + } + error = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMCPCallItemParam( + @type, + additionalBinaryDataProperties, + serverLabel, + name, + arguments, + output, + error); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMCPCallItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMCPCallItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalMCPCallItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMCPCallItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMCPCallItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPCallItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPCallItemParam.cs new file mode 100644 index 000000000000..f806e852e903 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPCallItemParam.cs @@ -0,0 +1,61 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPCallItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The label of the MCP server running the tool. + /// The name of the tool that was run. + /// A JSON string of the arguments passed to the tool. + /// , or is null. + public InternalMCPCallItemParam(string serverLabel, string name, string arguments) : base(AgentResponseItemKind.McpCall) + { + Argument.AssertNotNull(serverLabel, nameof(serverLabel)); + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(arguments, nameof(arguments)); + + ServerLabel = serverLabel; + Name = name; + Arguments = arguments; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The label of the MCP server running the tool. + /// The name of the tool that was run. + /// A JSON string of the arguments passed to the tool. + /// The output from the tool call. + /// The error from the tool call, if any. + internal InternalMCPCallItemParam(AgentResponseItemKind @type, IDictionary additionalBinaryDataProperties, string serverLabel, string name, string arguments, string output, string error) : base(@type, additionalBinaryDataProperties) + { + ServerLabel = serverLabel; + Name = name; + Arguments = arguments; + Output = output; + Error = error; + } + + /// The label of the MCP server running the tool. + public string ServerLabel { get; } + + /// The name of the tool that was run. + public string Name { get; } + + /// A JSON string of the arguments passed to the tool. + public string Arguments { get; } + + /// The output from the tool call. + public string Output { get; set; } + + /// The error from the tool call, if any. + public string Error { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPCallItemResource.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPCallItemResource.Serialization.cs new file mode 100644 index 000000000000..e1bab0ae2a37 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPCallItemResource.Serialization.cs @@ -0,0 +1,204 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPCallItemResource : AgentResponseItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalMCPCallItemResource() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPCallItemResource)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("server_label"u8); + writer.WriteStringValue(ServerLabel); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("arguments"u8); + writer.WriteStringValue(Arguments); + if (Optional.IsDefined(Output)) + { + writer.WritePropertyName("output"u8); + writer.WriteStringValue(Output); + } + if (Optional.IsDefined(Error)) + { + writer.WritePropertyName("error"u8); + writer.WriteStringValue(Error); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMCPCallItemResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalMCPCallItemResource)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPCallItemResource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMCPCallItemResource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMCPCallItemResource DeserializeInternalMCPCallItemResource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + string id = default; + AgentResponseItemSource createdBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string serverLabel = default; + string name = default; + string arguments = default; + string output = default; + string error = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdBy = AgentResponseItemSource.DeserializeAgentResponseItemSource(prop.Value, options); + continue; + } + if (prop.NameEquals("server_label"u8)) + { + serverLabel = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("arguments"u8)) + { + arguments = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("output"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + output = null; + continue; + } + output = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("error"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + error = null; + continue; + } + error = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMCPCallItemResource( + @type, + id, + createdBy, + additionalBinaryDataProperties, + serverLabel, + name, + arguments, + output, + error); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMCPCallItemResource)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMCPCallItemResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalMCPCallItemResource)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMCPCallItemResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMCPCallItemResource)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPCallItemResource.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPCallItemResource.cs new file mode 100644 index 000000000000..5bc74488b60b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPCallItemResource.cs @@ -0,0 +1,59 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPCallItemResource : AgentResponseItem + { + /// Initializes a new instance of . + /// + /// The label of the MCP server running the tool. + /// The name of the tool that was run. + /// A JSON string of the arguments passed to the tool. + internal InternalMCPCallItemResource(string id, string serverLabel, string name, string arguments) : base(AgentResponseItemKind.McpCall, id) + { + ServerLabel = serverLabel; + Name = name; + Arguments = arguments; + } + + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + /// The label of the MCP server running the tool. + /// The name of the tool that was run. + /// A JSON string of the arguments passed to the tool. + /// The output from the tool call. + /// The error from the tool call, if any. + internal InternalMCPCallItemResource(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties, string serverLabel, string name, string arguments, string output, string error) : base(@type, id, createdBy, additionalBinaryDataProperties) + { + ServerLabel = serverLabel; + Name = name; + Arguments = arguments; + Output = output; + Error = error; + } + + /// The label of the MCP server running the tool. + public string ServerLabel { get; } + + /// The name of the tool that was run. + public string Name { get; } + + /// A JSON string of the arguments passed to the tool. + public string Arguments { get; } + + /// The output from the tool call. + public string Output { get; } + + /// The error from the tool call, if any. + public string Error { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPListToolsItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPListToolsItemParam.Serialization.cs new file mode 100644 index 000000000000..435f9a5b1520 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPListToolsItemParam.Serialization.cs @@ -0,0 +1,165 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPListToolsItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalMCPListToolsItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPListToolsItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("server_label"u8); + writer.WriteStringValue(ServerLabel); + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (InternalMCPListToolsTool item in Tools) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(Error)) + { + writer.WritePropertyName("error"u8); + writer.WriteStringValue(Error); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMCPListToolsItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalMCPListToolsItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPListToolsItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMCPListToolsItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMCPListToolsItemParam DeserializeInternalMCPListToolsItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string serverLabel = default; + IList tools = default; + string error = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("server_label"u8)) + { + serverLabel = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("tools"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalMCPListToolsTool.DeserializeInternalMCPListToolsTool(item, options)); + } + tools = array; + continue; + } + if (prop.NameEquals("error"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + error = null; + continue; + } + error = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMCPListToolsItemParam(@type, additionalBinaryDataProperties, serverLabel, tools, error); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMCPListToolsItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMCPListToolsItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalMCPListToolsItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMCPListToolsItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMCPListToolsItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPListToolsItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPListToolsItemParam.cs new file mode 100644 index 000000000000..9e8865509e7e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPListToolsItemParam.cs @@ -0,0 +1,49 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPListToolsItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The label of the MCP server. + /// The tools available on the server. + /// or is null. + public InternalMCPListToolsItemParam(string serverLabel, IEnumerable tools) : base(AgentResponseItemKind.McpListTools) + { + Argument.AssertNotNull(serverLabel, nameof(serverLabel)); + Argument.AssertNotNull(tools, nameof(tools)); + + ServerLabel = serverLabel; + Tools = tools.ToList(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The label of the MCP server. + /// The tools available on the server. + /// Error message if the server could not list tools. + internal InternalMCPListToolsItemParam(AgentResponseItemKind @type, IDictionary additionalBinaryDataProperties, string serverLabel, IList tools, string error) : base(@type, additionalBinaryDataProperties) + { + ServerLabel = serverLabel; + Tools = tools; + Error = error; + } + + /// The label of the MCP server. + public string ServerLabel { get; } + + /// The tools available on the server. + public IList Tools { get; } + + /// Error message if the server could not list tools. + public string Error { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPListToolsItemResource.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPListToolsItemResource.Serialization.cs new file mode 100644 index 000000000000..98cf75adfbd0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPListToolsItemResource.Serialization.cs @@ -0,0 +1,188 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPListToolsItemResource : AgentResponseItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalMCPListToolsItemResource() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPListToolsItemResource)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("server_label"u8); + writer.WriteStringValue(ServerLabel); + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (InternalMCPListToolsTool item in Tools) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(Error)) + { + writer.WritePropertyName("error"u8); + writer.WriteStringValue(Error); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMCPListToolsItemResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalMCPListToolsItemResource)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPListToolsItemResource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMCPListToolsItemResource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMCPListToolsItemResource DeserializeInternalMCPListToolsItemResource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + string id = default; + AgentResponseItemSource createdBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string serverLabel = default; + IList tools = default; + string error = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdBy = AgentResponseItemSource.DeserializeAgentResponseItemSource(prop.Value, options); + continue; + } + if (prop.NameEquals("server_label"u8)) + { + serverLabel = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("tools"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalMCPListToolsTool.DeserializeInternalMCPListToolsTool(item, options)); + } + tools = array; + continue; + } + if (prop.NameEquals("error"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + error = null; + continue; + } + error = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMCPListToolsItemResource( + @type, + id, + createdBy, + additionalBinaryDataProperties, + serverLabel, + tools, + error); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMCPListToolsItemResource)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMCPListToolsItemResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalMCPListToolsItemResource)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMCPListToolsItemResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMCPListToolsItemResource)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPListToolsItemResource.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPListToolsItemResource.cs new file mode 100644 index 000000000000..50d60ab6e44d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPListToolsItemResource.cs @@ -0,0 +1,48 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPListToolsItemResource : AgentResponseItem + { + /// Initializes a new instance of . + /// + /// The label of the MCP server. + /// The tools available on the server. + internal InternalMCPListToolsItemResource(string id, string serverLabel, IEnumerable tools) : base(AgentResponseItemKind.McpListTools, id) + { + ServerLabel = serverLabel; + Tools = tools.ToList(); + } + + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + /// The label of the MCP server. + /// The tools available on the server. + /// Error message if the server could not list tools. + internal InternalMCPListToolsItemResource(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties, string serverLabel, IList tools, string error) : base(@type, id, createdBy, additionalBinaryDataProperties) + { + ServerLabel = serverLabel; + Tools = tools; + Error = error; + } + + /// The label of the MCP server. + public string ServerLabel { get; } + + /// The tools available on the server. + public IList Tools { get; } + + /// Error message if the server could not list tools. + public string Error { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPListToolsTool.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPListToolsTool.Serialization.cs new file mode 100644 index 000000000000..4c8f553746a4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPListToolsTool.Serialization.cs @@ -0,0 +1,193 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPListToolsTool : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalMCPListToolsTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPListToolsTool)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("input_schema"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(InputSchema); +#else + using (JsonDocument document = JsonDocument.Parse(InputSchema)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + if (Optional.IsDefined(Annotations)) + { + writer.WritePropertyName("annotations"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Annotations); +#else + using (JsonDocument document = JsonDocument.Parse(Annotations)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMCPListToolsTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalMCPListToolsTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPListToolsTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMCPListToolsTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMCPListToolsTool DeserializeInternalMCPListToolsTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string description = default; + BinaryData inputSchema = default; + BinaryData annotations = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("description"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + description = null; + continue; + } + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("input_schema"u8)) + { + inputSchema = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("annotations"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + annotations = null; + continue; + } + annotations = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMCPListToolsTool(name, description, inputSchema, annotations, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMCPListToolsTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMCPListToolsTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalMCPListToolsTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMCPListToolsTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMCPListToolsTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPListToolsTool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPListToolsTool.cs new file mode 100644 index 000000000000..c0475d96b4d2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPListToolsTool.cs @@ -0,0 +1,107 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPListToolsTool + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The name of the tool. + /// The JSON schema describing the tool's input. + /// or is null. + public InternalMCPListToolsTool(string name, BinaryData inputSchema) + { + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(inputSchema, nameof(inputSchema)); + + Name = name; + InputSchema = inputSchema; + } + + /// Initializes a new instance of . + /// The name of the tool. + /// The description of the tool. + /// The JSON schema describing the tool's input. + /// Additional annotations about the tool. + /// Keeps track of any properties unknown to the library. + internal InternalMCPListToolsTool(string name, string description, BinaryData inputSchema, BinaryData annotations, IDictionary additionalBinaryDataProperties) + { + Name = name; + Description = description; + InputSchema = inputSchema; + Annotations = annotations; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The name of the tool. + public string Name { get; } + + /// The description of the tool. + public string Description { get; set; } + + /// + /// The JSON schema describing the tool's input. + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData InputSchema { get; } + + /// + /// Additional annotations about the tool. + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData Annotations { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPTool.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPTool.Serialization.cs new file mode 100644 index 000000000000..081870c76bfe --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPTool.Serialization.cs @@ -0,0 +1,242 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPTool : AgentTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalMCPTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("server_label"u8); + writer.WriteStringValue(ServerLabel); + writer.WritePropertyName("server_url"u8); + writer.WriteStringValue(ServerUrl); + if (Optional.IsCollectionDefined(Headers)) + { + writer.WritePropertyName("headers"u8); + writer.WriteStartObject(); + foreach (var item in Headers) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(AllowedTools)) + { + writer.WritePropertyName("allowed_tools"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(AllowedTools); +#else + using (JsonDocument document = JsonDocument.Parse(AllowedTools)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (Optional.IsDefined(RequireApproval)) + { + writer.WritePropertyName("require_approval"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(RequireApproval); +#else + using (JsonDocument document = JsonDocument.Parse(RequireApproval)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (Optional.IsDefined(ProjectConnectionId)) + { + writer.WritePropertyName("project_connection_id"u8); + writer.WriteStringValue(ProjectConnectionId); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMCPTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalMCPTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMCPTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMCPTool DeserializeInternalMCPTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string serverLabel = default; + string serverUrl = default; + IDictionary headers = default; + BinaryData allowedTools = default; + BinaryData requireApproval = default; + string projectConnectionId = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("server_label"u8)) + { + serverLabel = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("server_url"u8)) + { + serverUrl = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("headers"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + headers = dictionary; + continue; + } + if (prop.NameEquals("allowed_tools"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + allowedTools = null; + continue; + } + allowedTools = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("require_approval"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + requireApproval = null; + continue; + } + requireApproval = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("project_connection_id"u8)) + { + projectConnectionId = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMCPTool( + @type, + additionalBinaryDataProperties, + serverLabel, + serverUrl, + headers ?? new ChangeTrackingDictionary(), + allowedTools, + requireApproval, + projectConnectionId); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMCPTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMCPTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalMCPTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMCPTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMCPTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPTool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPTool.cs new file mode 100644 index 000000000000..db7b63c2b649 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPTool.cs @@ -0,0 +1,150 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPTool : AgentTool + { + /// Initializes a new instance of . + /// A label for this MCP server, used to identify it in tool calls. + /// The URL for the MCP server. + /// or is null. + public InternalMCPTool(string serverLabel, string serverUrl) : base(ToolType.Mcp) + { + Argument.AssertNotNull(serverLabel, nameof(serverLabel)); + Argument.AssertNotNull(serverUrl, nameof(serverUrl)); + + ServerLabel = serverLabel; + ServerUrl = serverUrl; + Headers = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// A label for this MCP server, used to identify it in tool calls. + /// The URL for the MCP server. + /// + /// Optional HTTP headers to send to the MCP server. Use for authentication + /// or other purposes. + /// + /// List of allowed tool names or a filter object. + /// Specify which of the MCP server's tools require approval. + /// The connection ID in the project for the MCP server. The connection stores authentication and other connection details needed to connect to the MCP server. + internal InternalMCPTool(ToolType @type, IDictionary additionalBinaryDataProperties, string serverLabel, string serverUrl, IDictionary headers, BinaryData allowedTools, BinaryData requireApproval, string projectConnectionId) : base(@type, additionalBinaryDataProperties) + { + ServerLabel = serverLabel; + ServerUrl = serverUrl; + Headers = headers; + AllowedTools = allowedTools; + RequireApproval = requireApproval; + ProjectConnectionId = projectConnectionId; + } + + /// A label for this MCP server, used to identify it in tool calls. + public string ServerLabel { get; set; } + + /// The URL for the MCP server. + public string ServerUrl { get; set; } + + /// + /// Optional HTTP headers to send to the MCP server. Use for authentication + /// or other purposes. + /// + public IDictionary Headers { get; set; } + + /// + /// List of allowed tool names or a filter object. + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// where T is of type . + /// + /// + /// . + /// + /// + /// + /// + /// + /// 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" }. + /// + /// + /// + /// + public BinaryData AllowedTools { get; set; } + + /// + /// Specify which of the MCP server's tools require approval. + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// "always". + /// + /// + /// "never". + /// + /// + /// + /// + /// + /// 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" }. + /// + /// + /// + /// + public BinaryData RequireApproval { get; set; } + + /// The connection ID in the project for the MCP server. The connection stores authentication and other connection details needed to connect to the MCP server. + public string ProjectConnectionId { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPToolAllowedTools1.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPToolAllowedTools1.Serialization.cs new file mode 100644 index 000000000000..54f1eb790a2b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPToolAllowedTools1.Serialization.cs @@ -0,0 +1,163 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPToolAllowedTools1 : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPToolAllowedTools1)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(ToolNames)) + { + writer.WritePropertyName("tool_names"u8); + writer.WriteStartArray(); + foreach (string item in ToolNames) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMCPToolAllowedTools1 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalMCPToolAllowedTools1 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPToolAllowedTools1)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMCPToolAllowedTools1(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMCPToolAllowedTools1 DeserializeInternalMCPToolAllowedTools1(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList toolNames = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("tool_names"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + toolNames = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMCPToolAllowedTools1(toolNames ?? new ChangeTrackingList(), additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMCPToolAllowedTools1)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMCPToolAllowedTools1 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalMCPToolAllowedTools1 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMCPToolAllowedTools1(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMCPToolAllowedTools1)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPToolAllowedTools1.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPToolAllowedTools1.cs new file mode 100644 index 000000000000..c9bbbacef284 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPToolAllowedTools1.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPToolAllowedTools1 + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public InternalMCPToolAllowedTools1() + { + ToolNames = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// List of allowed tool names. + /// Keeps track of any properties unknown to the library. + internal InternalMCPToolAllowedTools1(IList toolNames, IDictionary additionalBinaryDataProperties) + { + ToolNames = toolNames; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// List of allowed tool names. + public IList ToolNames { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPToolRequireApproval1.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPToolRequireApproval1.Serialization.cs new file mode 100644 index 000000000000..fd4816b17505 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPToolRequireApproval1.Serialization.cs @@ -0,0 +1,156 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPToolRequireApproval1 : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPToolRequireApproval1)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Always)) + { + writer.WritePropertyName("always"u8); + writer.WriteObjectValue(Always, options); + } + if (Optional.IsDefined(Never)) + { + writer.WritePropertyName("never"u8); + writer.WriteObjectValue(Never, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMCPToolRequireApproval1 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalMCPToolRequireApproval1 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPToolRequireApproval1)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMCPToolRequireApproval1(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMCPToolRequireApproval1 DeserializeInternalMCPToolRequireApproval1(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalMCPToolRequireApprovalAlways always = default; + InternalMCPToolRequireApprovalNever never = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("always"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + always = InternalMCPToolRequireApprovalAlways.DeserializeInternalMCPToolRequireApprovalAlways(prop.Value, options); + continue; + } + if (prop.NameEquals("never"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + never = InternalMCPToolRequireApprovalNever.DeserializeInternalMCPToolRequireApprovalNever(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMCPToolRequireApproval1(always, never, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMCPToolRequireApproval1)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMCPToolRequireApproval1 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalMCPToolRequireApproval1 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMCPToolRequireApproval1(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMCPToolRequireApproval1)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPToolRequireApproval1.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPToolRequireApproval1.cs new file mode 100644 index 000000000000..be59e8145e35 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPToolRequireApproval1.cs @@ -0,0 +1,37 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalMCPToolRequireApproval1 + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public InternalMCPToolRequireApproval1() + { + } + + /// Initializes a new instance of . + /// A list of tools that always require approval. + /// A list of tools that never require approval. + /// Keeps track of any properties unknown to the library. + internal InternalMCPToolRequireApproval1(InternalMCPToolRequireApprovalAlways always, InternalMCPToolRequireApprovalNever never, IDictionary additionalBinaryDataProperties) + { + Always = always; + Never = never; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// A list of tools that always require approval. + public InternalMCPToolRequireApprovalAlways Always { get; set; } + + /// A list of tools that never require approval. + public InternalMCPToolRequireApprovalNever Never { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPToolRequireApprovalAlways.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPToolRequireApprovalAlways.Serialization.cs new file mode 100644 index 000000000000..1e5d45b42f5b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPToolRequireApprovalAlways.Serialization.cs @@ -0,0 +1,163 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPToolRequireApprovalAlways : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPToolRequireApprovalAlways)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(ToolNames)) + { + writer.WritePropertyName("tool_names"u8); + writer.WriteStartArray(); + foreach (string item in ToolNames) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMCPToolRequireApprovalAlways IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalMCPToolRequireApprovalAlways JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPToolRequireApprovalAlways)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMCPToolRequireApprovalAlways(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMCPToolRequireApprovalAlways DeserializeInternalMCPToolRequireApprovalAlways(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList toolNames = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("tool_names"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + toolNames = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMCPToolRequireApprovalAlways(toolNames ?? new ChangeTrackingList(), additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMCPToolRequireApprovalAlways)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMCPToolRequireApprovalAlways IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalMCPToolRequireApprovalAlways PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMCPToolRequireApprovalAlways(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMCPToolRequireApprovalAlways)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPToolRequireApprovalAlways.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPToolRequireApprovalAlways.cs new file mode 100644 index 000000000000..794349ed7871 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPToolRequireApprovalAlways.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPToolRequireApprovalAlways + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public InternalMCPToolRequireApprovalAlways() + { + ToolNames = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// List of tools that require approval. + /// Keeps track of any properties unknown to the library. + internal InternalMCPToolRequireApprovalAlways(IList toolNames, IDictionary additionalBinaryDataProperties) + { + ToolNames = toolNames; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// List of tools that require approval. + public IList ToolNames { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPToolRequireApprovalNever.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPToolRequireApprovalNever.Serialization.cs new file mode 100644 index 000000000000..fcc5932b2965 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPToolRequireApprovalNever.Serialization.cs @@ -0,0 +1,163 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPToolRequireApprovalNever : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPToolRequireApprovalNever)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(ToolNames)) + { + writer.WritePropertyName("tool_names"u8); + writer.WriteStartArray(); + foreach (string item in ToolNames) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMCPToolRequireApprovalNever IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalMCPToolRequireApprovalNever JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPToolRequireApprovalNever)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMCPToolRequireApprovalNever(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMCPToolRequireApprovalNever DeserializeInternalMCPToolRequireApprovalNever(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList toolNames = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("tool_names"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + toolNames = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMCPToolRequireApprovalNever(toolNames ?? new ChangeTrackingList(), additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMCPToolRequireApprovalNever)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMCPToolRequireApprovalNever IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalMCPToolRequireApprovalNever PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMCPToolRequireApprovalNever(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMCPToolRequireApprovalNever)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPToolRequireApprovalNever.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPToolRequireApprovalNever.cs new file mode 100644 index 000000000000..b76321a58ba0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalMCPToolRequireApprovalNever.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalMCPToolRequireApprovalNever + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public InternalMCPToolRequireApprovalNever() + { + ToolNames = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// List of tools that do not require approval. + /// Keeps track of any properties unknown to the library. + internal InternalMCPToolRequireApprovalNever(IList toolNames, IDictionary additionalBinaryDataProperties) + { + ToolNames = toolNames; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// List of tools that do not require approval. + public IList ToolNames { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalRankingOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalRankingOptions.Serialization.cs new file mode 100644 index 000000000000..a45062b6d136 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalRankingOptions.Serialization.cs @@ -0,0 +1,156 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalRankingOptions : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalRankingOptions)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Ranker)) + { + writer.WritePropertyName("ranker"u8); + writer.WriteStringValue(Ranker.Value.ToString()); + } + if (Optional.IsDefined(ScoreThreshold)) + { + writer.WritePropertyName("score_threshold"u8); + writer.WriteNumberValue(ScoreThreshold.Value); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalRankingOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalRankingOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalRankingOptions)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRankingOptions(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalRankingOptions DeserializeInternalRankingOptions(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RankingOptionsRanker? ranker = default; + float? scoreThreshold = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("ranker"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + ranker = new RankingOptionsRanker(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("score_threshold"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + scoreThreshold = prop.Value.GetSingle(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalRankingOptions(ranker, scoreThreshold, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalRankingOptions)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalRankingOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalRankingOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalRankingOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRankingOptions)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalRankingOptions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalRankingOptions.cs new file mode 100644 index 000000000000..1a7309395e70 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalRankingOptions.cs @@ -0,0 +1,37 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalRankingOptions + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public InternalRankingOptions() + { + } + + /// Initializes a new instance of . + /// The ranker to use for the file search. + /// The score threshold for the file search, a number between 0 and 1. Numbers closer to 1 will attempt to return only the most relevant results, but may return fewer results. + /// Keeps track of any properties unknown to the library. + internal InternalRankingOptions(RankingOptionsRanker? ranker, float? scoreThreshold, IDictionary additionalBinaryDataProperties) + { + Ranker = ranker; + ScoreThreshold = scoreThreshold; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The ranker to use for the file search. + public RankingOptionsRanker? Ranker { get; set; } + + /// The score threshold for the file search, a number between 0 and 1. Numbers closer to 1 will attempt to return only the most relevant results, but may return fewer results. + public float? ScoreThreshold { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoning.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoning.Serialization.cs new file mode 100644 index 000000000000..8bb87abfd0d4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoning.Serialization.cs @@ -0,0 +1,174 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalReasoning : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalReasoning)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Effort)) + { + writer.WritePropertyName("effort"u8); + writer.WriteStringValue(Effort.Value.ToString()); + } + if (Optional.IsDefined(Summary)) + { + writer.WritePropertyName("summary"u8); + writer.WriteStringValue(Summary.Value.ToString()); + } + if (Optional.IsDefined(GenerateSummary)) + { + writer.WritePropertyName("generate_summary"u8); + writer.WriteStringValue(GenerateSummary.Value.ToString()); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalReasoning IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalReasoning JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalReasoning)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalReasoning(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalReasoning DeserializeInternalReasoning(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ReasoningEffort? effort = default; + ReasoningSummary? summary = default; + ReasoningGenerateSummary? generateSummary = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("effort"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + effort = null; + continue; + } + effort = new ReasoningEffort(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("summary"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + summary = null; + continue; + } + summary = new ReasoningSummary(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("generate_summary"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + generateSummary = null; + continue; + } + generateSummary = new ReasoningGenerateSummary(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalReasoning(effort, summary, generateSummary, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalReasoning)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalReasoning IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalReasoning PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalReasoning(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalReasoning)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoning.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoning.cs new file mode 100644 index 000000000000..e26a1b61420f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoning.cs @@ -0,0 +1,50 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalReasoning + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public InternalReasoning() + { + } + + /// Initializes a new instance of . + /// + /// + /// A summary of the reasoning performed by the model. This can be + /// useful for debugging and understanding the model's reasoning process. + /// One of `auto`, `concise`, or `detailed`. + /// + /// **Deprecated**: use `summary` instead. A summary of the reasoning performed by the model. This can be useful for debugging and understanding the model's reasoning process. One of `auto`, `concise`, or `detailed`. + /// Keeps track of any properties unknown to the library. + internal InternalReasoning(ReasoningEffort? effort, ReasoningSummary? summary, ReasoningGenerateSummary? generateSummary, IDictionary additionalBinaryDataProperties) + { + Effort = effort; + Summary = summary; + GenerateSummary = generateSummary; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Effort. + public ReasoningEffort? Effort { get; set; } + + /// + /// A summary of the reasoning performed by the model. This can be + /// useful for debugging and understanding the model's reasoning process. + /// One of `auto`, `concise`, or `detailed`. + /// + public ReasoningSummary? Summary { get; set; } + + /// **Deprecated**: use `summary` instead. A summary of the reasoning performed by the model. This can be useful for debugging and understanding the model's reasoning process. One of `auto`, `concise`, or `detailed`. + public ReasoningGenerateSummary? GenerateSummary { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoningItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoningItemParam.Serialization.cs new file mode 100644 index 000000000000..d43c1a6d8ca3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoningItemParam.Serialization.cs @@ -0,0 +1,157 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalReasoningItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalReasoningItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalReasoningItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(EncryptedContent)) + { + writer.WritePropertyName("encrypted_content"u8); + writer.WriteStringValue(EncryptedContent); + } + writer.WritePropertyName("summary"u8); + writer.WriteStartArray(); + foreach (InternalReasoningItemSummaryPart item in Summary) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalReasoningItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalReasoningItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalReasoningItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalReasoningItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalReasoningItemParam DeserializeInternalReasoningItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string encryptedContent = default; + IList summary = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("encrypted_content"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + encryptedContent = null; + continue; + } + encryptedContent = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("summary"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalReasoningItemSummaryPart.DeserializeInternalReasoningItemSummaryPart(item, options)); + } + summary = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalReasoningItemParam(@type, additionalBinaryDataProperties, encryptedContent, summary); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalReasoningItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalReasoningItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalReasoningItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalReasoningItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalReasoningItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoningItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoningItemParam.cs new file mode 100644 index 000000000000..2a281625b374 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoningItemParam.cs @@ -0,0 +1,47 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalReasoningItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// Reasoning text contents. + /// is null. + public InternalReasoningItemParam(IEnumerable summary) : base(AgentResponseItemKind.Reasoning) + { + Argument.AssertNotNull(summary, nameof(summary)); + + Summary = summary.ToList(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// + /// The encrypted content of the reasoning item - populated when a response is + /// generated with `reasoning.encrypted_content` in the `include` parameter. + /// + /// Reasoning text contents. + internal InternalReasoningItemParam(AgentResponseItemKind @type, IDictionary additionalBinaryDataProperties, string encryptedContent, IList summary) : base(@type, additionalBinaryDataProperties) + { + EncryptedContent = encryptedContent; + Summary = summary; + } + + /// + /// The encrypted content of the reasoning item - populated when a response is + /// generated with `reasoning.encrypted_content` in the `include` parameter. + /// + public string EncryptedContent { get; set; } + + /// Reasoning text contents. + public IList Summary { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoningItemResource.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoningItemResource.Serialization.cs new file mode 100644 index 000000000000..9c90a38abbda --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoningItemResource.Serialization.cs @@ -0,0 +1,179 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalReasoningItemResource : AgentResponseItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalReasoningItemResource() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalReasoningItemResource)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(EncryptedContent)) + { + writer.WritePropertyName("encrypted_content"u8); + writer.WriteStringValue(EncryptedContent); + } + writer.WritePropertyName("summary"u8); + writer.WriteStartArray(); + foreach (InternalReasoningItemSummaryPart item in Summary) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalReasoningItemResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalReasoningItemResource)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalReasoningItemResource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalReasoningItemResource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalReasoningItemResource DeserializeInternalReasoningItemResource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + string id = default; + AgentResponseItemSource createdBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string encryptedContent = default; + IList summary = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdBy = AgentResponseItemSource.DeserializeAgentResponseItemSource(prop.Value, options); + continue; + } + if (prop.NameEquals("encrypted_content"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + encryptedContent = null; + continue; + } + encryptedContent = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("summary"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalReasoningItemSummaryPart.DeserializeInternalReasoningItemSummaryPart(item, options)); + } + summary = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalReasoningItemResource( + @type, + id, + createdBy, + additionalBinaryDataProperties, + encryptedContent, + summary); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalReasoningItemResource)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalReasoningItemResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalReasoningItemResource)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalReasoningItemResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalReasoningItemResource)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoningItemResource.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoningItemResource.cs new file mode 100644 index 000000000000..f911f069adb3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoningItemResource.cs @@ -0,0 +1,47 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalReasoningItemResource : AgentResponseItem + { + /// Initializes a new instance of . + /// + /// Reasoning text contents. + internal InternalReasoningItemResource(string id, IEnumerable summary) : base(AgentResponseItemKind.Reasoning, id) + { + Summary = summary.ToList(); + } + + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + /// + /// The encrypted content of the reasoning item - populated when a response is + /// generated with `reasoning.encrypted_content` in the `include` parameter. + /// + /// Reasoning text contents. + internal InternalReasoningItemResource(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties, string encryptedContent, IList summary) : base(@type, id, createdBy, additionalBinaryDataProperties) + { + EncryptedContent = encryptedContent; + Summary = summary; + } + + /// + /// The encrypted content of the reasoning item - populated when a response is + /// generated with `reasoning.encrypted_content` in the `include` parameter. + /// + public string EncryptedContent { get; } + + /// Reasoning text contents. + public IList Summary { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoningItemSummaryPart.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoningItemSummaryPart.Serialization.cs new file mode 100644 index 000000000000..7e656db646b6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoningItemSummaryPart.Serialization.cs @@ -0,0 +1,133 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + [PersistableModelProxy(typeof(UnknownReasoningItemSummaryPart))] + internal abstract partial class InternalReasoningItemSummaryPart : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalReasoningItemSummaryPart() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalReasoningItemSummaryPart)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalReasoningItemSummaryPart IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalReasoningItemSummaryPart JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalReasoningItemSummaryPart)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalReasoningItemSummaryPart(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalReasoningItemSummaryPart DeserializeInternalReasoningItemSummaryPart(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "summary_text": + return InternalReasoningItemSummaryTextPart.DeserializeInternalReasoningItemSummaryTextPart(element, options); + } + } + return UnknownReasoningItemSummaryPart.DeserializeUnknownReasoningItemSummaryPart(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalReasoningItemSummaryPart)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalReasoningItemSummaryPart IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalReasoningItemSummaryPart PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalReasoningItemSummaryPart(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalReasoningItemSummaryPart)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoningItemSummaryPart.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoningItemSummaryPart.cs new file mode 100644 index 000000000000..9c90e84b6c68 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoningItemSummaryPart.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal abstract partial class InternalReasoningItemSummaryPart + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + private protected InternalReasoningItemSummaryPart(ReasoningItemSummaryPartType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalReasoningItemSummaryPart(ReasoningItemSummaryPartType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Type. + internal ReasoningItemSummaryPartType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoningItemSummaryTextPart.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoningItemSummaryTextPart.Serialization.cs new file mode 100644 index 000000000000..5672349f831e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoningItemSummaryTextPart.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalReasoningItemSummaryTextPart : InternalReasoningItemSummaryPart, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalReasoningItemSummaryTextPart() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalReasoningItemSummaryTextPart)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalReasoningItemSummaryTextPart IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalReasoningItemSummaryTextPart)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalReasoningItemSummaryPart JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalReasoningItemSummaryTextPart)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalReasoningItemSummaryTextPart(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalReasoningItemSummaryTextPart DeserializeInternalReasoningItemSummaryTextPart(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ReasoningItemSummaryPartType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string text = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ReasoningItemSummaryPartType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("text"u8)) + { + text = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalReasoningItemSummaryTextPart(@type, additionalBinaryDataProperties, text); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalReasoningItemSummaryTextPart)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalReasoningItemSummaryTextPart IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalReasoningItemSummaryTextPart)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalReasoningItemSummaryPart PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalReasoningItemSummaryTextPart(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalReasoningItemSummaryTextPart)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoningItemSummaryTextPart.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoningItemSummaryTextPart.cs new file mode 100644 index 000000000000..70ff1b23fa10 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalReasoningItemSummaryTextPart.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalReasoningItemSummaryTextPart : InternalReasoningItemSummaryPart + { + /// Initializes a new instance of . + /// + /// is null. + public InternalReasoningItemSummaryTextPart(string text) : base(ReasoningItemSummaryPartType.SummaryText) + { + Argument.AssertNotNull(text, nameof(text)); + + Text = text; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// + internal InternalReasoningItemSummaryTextPart(ReasoningItemSummaryPartType @type, IDictionary additionalBinaryDataProperties, string text) : base(@type, additionalBinaryDataProperties) + { + Text = text; + } + + /// Gets the Text. + public string Text { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponseTextFormatConfiguration.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponseTextFormatConfiguration.Serialization.cs new file mode 100644 index 000000000000..17074f0316c2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponseTextFormatConfiguration.Serialization.cs @@ -0,0 +1,137 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + [PersistableModelProxy(typeof(UnknownResponseTextFormatConfiguration))] + internal abstract partial class InternalResponseTextFormatConfiguration : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalResponseTextFormatConfiguration() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfiguration)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponseTextFormatConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalResponseTextFormatConfiguration JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfiguration)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponseTextFormatConfiguration(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalResponseTextFormatConfiguration DeserializeInternalResponseTextFormatConfiguration(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "text": + return InternalResponseTextFormatConfigurationText.DeserializeInternalResponseTextFormatConfigurationText(element, options); + case "json_object": + return InternalResponseTextFormatConfigurationJsonObject.DeserializeInternalResponseTextFormatConfigurationJsonObject(element, options); + case "json_schema": + return InternalResponseTextFormatConfigurationJsonSchema.DeserializeInternalResponseTextFormatConfigurationJsonSchema(element, options); + } + } + return UnknownResponseTextFormatConfiguration.DeserializeUnknownResponseTextFormatConfiguration(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfiguration)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponseTextFormatConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalResponseTextFormatConfiguration PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponseTextFormatConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfiguration)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponseTextFormatConfiguration.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponseTextFormatConfiguration.cs new file mode 100644 index 000000000000..134c9b052903 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponseTextFormatConfiguration.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal abstract partial class InternalResponseTextFormatConfiguration + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + private protected InternalResponseTextFormatConfiguration(ResponseTextFormatConfigurationType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalResponseTextFormatConfiguration(ResponseTextFormatConfigurationType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Type. + internal ResponseTextFormatConfigurationType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponseTextFormatConfigurationJsonObject.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponseTextFormatConfigurationJsonObject.Serialization.cs new file mode 100644 index 000000000000..b13539b70c27 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponseTextFormatConfigurationJsonObject.Serialization.cs @@ -0,0 +1,118 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalResponseTextFormatConfigurationJsonObject : InternalResponseTextFormatConfiguration, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfigurationJsonObject)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponseTextFormatConfigurationJsonObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponseTextFormatConfigurationJsonObject)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalResponseTextFormatConfiguration JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfigurationJsonObject)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponseTextFormatConfigurationJsonObject(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalResponseTextFormatConfigurationJsonObject DeserializeInternalResponseTextFormatConfigurationJsonObject(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResponseTextFormatConfigurationType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ResponseTextFormatConfigurationType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalResponseTextFormatConfigurationJsonObject(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfigurationJsonObject)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponseTextFormatConfigurationJsonObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponseTextFormatConfigurationJsonObject)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalResponseTextFormatConfiguration PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponseTextFormatConfigurationJsonObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfigurationJsonObject)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponseTextFormatConfigurationJsonObject.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponseTextFormatConfigurationJsonObject.cs new file mode 100644 index 000000000000..8e3093103d10 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponseTextFormatConfigurationJsonObject.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalResponseTextFormatConfigurationJsonObject : InternalResponseTextFormatConfiguration + { + /// Initializes a new instance of . + public InternalResponseTextFormatConfigurationJsonObject() : base(ResponseTextFormatConfigurationType.JsonObject) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalResponseTextFormatConfigurationJsonObject(ResponseTextFormatConfigurationType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponseTextFormatConfigurationJsonSchema.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponseTextFormatConfigurationJsonSchema.Serialization.cs new file mode 100644 index 000000000000..006bbeb11450 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponseTextFormatConfigurationJsonSchema.Serialization.cs @@ -0,0 +1,202 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalResponseTextFormatConfigurationJsonSchema : InternalResponseTextFormatConfiguration, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalResponseTextFormatConfigurationJsonSchema() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfigurationJsonSchema)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("schema"u8); + writer.WriteStartObject(); + foreach (var item in Schema) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#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(); + if (Optional.IsDefined(Strict)) + { + writer.WritePropertyName("strict"u8); + writer.WriteBooleanValue(Strict.Value); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponseTextFormatConfigurationJsonSchema IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponseTextFormatConfigurationJsonSchema)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalResponseTextFormatConfiguration JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfigurationJsonSchema)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponseTextFormatConfigurationJsonSchema(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalResponseTextFormatConfigurationJsonSchema DeserializeInternalResponseTextFormatConfigurationJsonSchema(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResponseTextFormatConfigurationType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string description = default; + string name = default; + IDictionary schema = default; + bool? strict = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ResponseTextFormatConfigurationType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("schema"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + schema = dictionary; + continue; + } + if (prop.NameEquals("strict"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + strict = null; + continue; + } + strict = prop.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalResponseTextFormatConfigurationJsonSchema( + @type, + additionalBinaryDataProperties, + description, + name, + schema, + strict); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfigurationJsonSchema)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponseTextFormatConfigurationJsonSchema IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponseTextFormatConfigurationJsonSchema)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalResponseTextFormatConfiguration PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponseTextFormatConfigurationJsonSchema(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfigurationJsonSchema)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponseTextFormatConfigurationJsonSchema.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponseTextFormatConfigurationJsonSchema.cs new file mode 100644 index 000000000000..cd81f30b0a92 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponseTextFormatConfigurationJsonSchema.cs @@ -0,0 +1,106 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalResponseTextFormatConfigurationJsonSchema : InternalResponseTextFormatConfiguration + { + /// Initializes a new instance of . + /// + /// The name of the response format. Must be a-z, A-Z, 0-9, or contain + /// underscores and dashes, with a maximum length of 64. + /// + /// + /// or is null. + public InternalResponseTextFormatConfigurationJsonSchema(string name, IDictionary schema) : base(ResponseTextFormatConfigurationType.JsonSchema) + { + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(schema, nameof(schema)); + + Name = name; + Schema = schema; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// + /// A description of what the response format is for, used by the model to + /// determine how to respond in the format. + /// + /// + /// The name of the response format. Must be a-z, A-Z, 0-9, or contain + /// underscores and dashes, with a maximum length of 64. + /// + /// + /// + /// Whether to enable strict schema adherence when generating the output. + /// If set to true, the model will always follow the exact schema defined + /// in the `schema` field. Only a subset of JSON Schema is supported when + /// `strict` is `true`. To learn more, read the [Structured Outputs + /// guide](https://platform.openai.com/docs/guides/structured-outputs). + /// + internal InternalResponseTextFormatConfigurationJsonSchema(ResponseTextFormatConfigurationType @type, IDictionary additionalBinaryDataProperties, string description, string name, IDictionary schema, bool? strict) : base(@type, additionalBinaryDataProperties) + { + Description = description; + Name = name; + Schema = schema; + Strict = strict; + } + + /// + /// A description of what the response format is for, used by the model to + /// determine how to respond in the format. + /// + public string Description { get; set; } + + /// + /// The name of the response format. Must be a-z, A-Z, 0-9, or contain + /// underscores and dashes, with a maximum length of 64. + /// + public string Name { get; set; } + + /// + /// Gets the Schema. + /// 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" }. + /// + /// + /// + /// + public IDictionary Schema { get; } + + /// + /// Whether to enable strict schema adherence when generating the output. + /// If set to true, the model will always follow the exact schema defined + /// in the `schema` field. Only a subset of JSON Schema is supported when + /// `strict` is `true`. To learn more, read the [Structured Outputs + /// guide](https://platform.openai.com/docs/guides/structured-outputs). + /// + public bool? Strict { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponseTextFormatConfigurationText.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponseTextFormatConfigurationText.Serialization.cs new file mode 100644 index 000000000000..007f0b35bca8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponseTextFormatConfigurationText.Serialization.cs @@ -0,0 +1,118 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalResponseTextFormatConfigurationText : InternalResponseTextFormatConfiguration, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfigurationText)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponseTextFormatConfigurationText IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponseTextFormatConfigurationText)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalResponseTextFormatConfiguration JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfigurationText)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponseTextFormatConfigurationText(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalResponseTextFormatConfigurationText DeserializeInternalResponseTextFormatConfigurationText(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResponseTextFormatConfigurationType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ResponseTextFormatConfigurationType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalResponseTextFormatConfigurationText(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfigurationText)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponseTextFormatConfigurationText IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponseTextFormatConfigurationText)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalResponseTextFormatConfiguration PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponseTextFormatConfigurationText(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfigurationText)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponseTextFormatConfigurationText.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponseTextFormatConfigurationText.cs new file mode 100644 index 000000000000..8ca9f61f2a8e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponseTextFormatConfigurationText.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalResponseTextFormatConfigurationText : InternalResponseTextFormatConfiguration + { + /// Initializes a new instance of . + public InternalResponseTextFormatConfigurationText() : base(ResponseTextFormatConfigurationType.Text) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalResponseTextFormatConfigurationText(ResponseTextFormatConfigurationType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesAssistantMessageItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesAssistantMessageItemParam.Serialization.cs new file mode 100644 index 000000000000..85eec9c95dd0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesAssistantMessageItemParam.Serialization.cs @@ -0,0 +1,144 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalResponsesAssistantMessageItemParam : InternalResponsesMessageItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalResponsesAssistantMessageItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesAssistantMessageItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("content"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Content); +#else + using (JsonDocument document = JsonDocument.Parse(Content)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponsesAssistantMessageItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesAssistantMessageItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesAssistantMessageItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponsesAssistantMessageItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalResponsesAssistantMessageItemParam DeserializeInternalResponsesAssistantMessageItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ResponsesMessageRole role = default; + BinaryData content = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("role"u8)) + { + role = new ResponsesMessageRole(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("content"u8)) + { + content = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalResponsesAssistantMessageItemParam(@type, additionalBinaryDataProperties, role, content); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponsesAssistantMessageItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponsesAssistantMessageItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesAssistantMessageItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponsesAssistantMessageItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponsesAssistantMessageItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesAssistantMessageItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesAssistantMessageItemParam.cs new file mode 100644 index 000000000000..7ff25d586527 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesAssistantMessageItemParam.cs @@ -0,0 +1,75 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalResponsesAssistantMessageItemParam : InternalResponsesMessageItemParam + { + /// Initializes a new instance of . + /// The content associated with the message. + /// is null. + public InternalResponsesAssistantMessageItemParam(BinaryData content) : base(ResponsesMessageRole.Assistant) + { + Argument.AssertNotNull(content, nameof(content)); + + Content = content; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The role associated with the message. + /// The content associated with the message. + internal InternalResponsesAssistantMessageItemParam(AgentResponseItemKind @type, IDictionary additionalBinaryDataProperties, ResponsesMessageRole role, BinaryData content) : base(@type, additionalBinaryDataProperties, role) + { + Content = content; + } + + /// + /// The content associated with the message. + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// where T is of type . + /// + /// + /// + /// + /// + /// 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" }. + /// + /// + /// + /// + public BinaryData Content { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesAssistantMessageItemResource.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesAssistantMessageItemResource.Serialization.cs new file mode 100644 index 000000000000..ebc55643fded --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesAssistantMessageItemResource.Serialization.cs @@ -0,0 +1,176 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalResponsesAssistantMessageItemResource : InternalResponsesMessageItemResource, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalResponsesAssistantMessageItemResource() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesAssistantMessageItemResource)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("content"u8); + writer.WriteStartArray(); + foreach (InternalItemContent item in Content) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponsesAssistantMessageItemResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesAssistantMessageItemResource)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesAssistantMessageItemResource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponsesAssistantMessageItemResource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalResponsesAssistantMessageItemResource DeserializeInternalResponsesAssistantMessageItemResource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + string id = default; + AgentResponseItemSource createdBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ResponsesMessageItemResourceStatus status = default; + ResponsesMessageRole role = default; + IList content = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdBy = AgentResponseItemSource.DeserializeAgentResponseItemSource(prop.Value, options); + continue; + } + if (prop.NameEquals("status"u8)) + { + status = new ResponsesMessageItemResourceStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("role"u8)) + { + role = new ResponsesMessageRole(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("content"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalItemContent.DeserializeInternalItemContent(item, options)); + } + content = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalResponsesAssistantMessageItemResource( + @type, + id, + createdBy, + additionalBinaryDataProperties, + status, + role, + content); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponsesAssistantMessageItemResource)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponsesAssistantMessageItemResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesAssistantMessageItemResource)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponsesAssistantMessageItemResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponsesAssistantMessageItemResource)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesAssistantMessageItemResource.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesAssistantMessageItemResource.cs new file mode 100644 index 000000000000..7bbd9f5c73fb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesAssistantMessageItemResource.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalResponsesAssistantMessageItemResource : InternalResponsesMessageItemResource + { + /// Initializes a new instance of . + /// + /// + /// The status of the item. One of `in_progress`, `completed`, or + /// `incomplete`. Populated when items are returned via API. + /// + /// The content associated with the message. + internal InternalResponsesAssistantMessageItemResource(string id, ResponsesMessageItemResourceStatus status, IEnumerable content) : base(id, status, ResponsesMessageRole.Assistant) + { + Content = content.ToList(); + } + + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + /// + /// The status of the item. One of `in_progress`, `completed`, or + /// `incomplete`. Populated when items are returned via API. + /// + /// The role associated with the message. + /// The content associated with the message. + internal InternalResponsesAssistantMessageItemResource(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties, ResponsesMessageItemResourceStatus status, ResponsesMessageRole role, IList content) : base(@type, id, createdBy, additionalBinaryDataProperties, status, role) + { + Content = content; + } + + /// The content associated with the message. + public IList Content { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesDeveloperMessageItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesDeveloperMessageItemParam.Serialization.cs new file mode 100644 index 000000000000..3e2310f5e4c4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesDeveloperMessageItemParam.Serialization.cs @@ -0,0 +1,144 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalResponsesDeveloperMessageItemParam : InternalResponsesMessageItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalResponsesDeveloperMessageItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesDeveloperMessageItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("content"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Content); +#else + using (JsonDocument document = JsonDocument.Parse(Content)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponsesDeveloperMessageItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesDeveloperMessageItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesDeveloperMessageItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponsesDeveloperMessageItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalResponsesDeveloperMessageItemParam DeserializeInternalResponsesDeveloperMessageItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ResponsesMessageRole role = default; + BinaryData content = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("role"u8)) + { + role = new ResponsesMessageRole(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("content"u8)) + { + content = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalResponsesDeveloperMessageItemParam(@type, additionalBinaryDataProperties, role, content); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponsesDeveloperMessageItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponsesDeveloperMessageItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesDeveloperMessageItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponsesDeveloperMessageItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponsesDeveloperMessageItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesDeveloperMessageItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesDeveloperMessageItemParam.cs new file mode 100644 index 000000000000..ae5a638cfe9a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesDeveloperMessageItemParam.cs @@ -0,0 +1,75 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalResponsesDeveloperMessageItemParam : InternalResponsesMessageItemParam + { + /// Initializes a new instance of . + /// The content associated with the message. + /// is null. + public InternalResponsesDeveloperMessageItemParam(BinaryData content) : base(ResponsesMessageRole.Developer) + { + Argument.AssertNotNull(content, nameof(content)); + + Content = content; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The role associated with the message. + /// The content associated with the message. + internal InternalResponsesDeveloperMessageItemParam(AgentResponseItemKind @type, IDictionary additionalBinaryDataProperties, ResponsesMessageRole role, BinaryData content) : base(@type, additionalBinaryDataProperties, role) + { + Content = content; + } + + /// + /// The content associated with the message. + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// where T is of type . + /// + /// + /// + /// + /// + /// 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" }. + /// + /// + /// + /// + public BinaryData Content { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesDeveloperMessageItemResource.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesDeveloperMessageItemResource.Serialization.cs new file mode 100644 index 000000000000..27ce021c345b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesDeveloperMessageItemResource.Serialization.cs @@ -0,0 +1,176 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalResponsesDeveloperMessageItemResource : InternalResponsesMessageItemResource, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalResponsesDeveloperMessageItemResource() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesDeveloperMessageItemResource)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("content"u8); + writer.WriteStartArray(); + foreach (InternalItemContent item in Content) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponsesDeveloperMessageItemResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesDeveloperMessageItemResource)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesDeveloperMessageItemResource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponsesDeveloperMessageItemResource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalResponsesDeveloperMessageItemResource DeserializeInternalResponsesDeveloperMessageItemResource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + string id = default; + AgentResponseItemSource createdBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ResponsesMessageItemResourceStatus status = default; + ResponsesMessageRole role = default; + IList content = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdBy = AgentResponseItemSource.DeserializeAgentResponseItemSource(prop.Value, options); + continue; + } + if (prop.NameEquals("status"u8)) + { + status = new ResponsesMessageItemResourceStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("role"u8)) + { + role = new ResponsesMessageRole(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("content"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalItemContent.DeserializeInternalItemContent(item, options)); + } + content = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalResponsesDeveloperMessageItemResource( + @type, + id, + createdBy, + additionalBinaryDataProperties, + status, + role, + content); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponsesDeveloperMessageItemResource)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponsesDeveloperMessageItemResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesDeveloperMessageItemResource)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponsesDeveloperMessageItemResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponsesDeveloperMessageItemResource)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesDeveloperMessageItemResource.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesDeveloperMessageItemResource.cs new file mode 100644 index 000000000000..ea0c703680fd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesDeveloperMessageItemResource.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalResponsesDeveloperMessageItemResource : InternalResponsesMessageItemResource + { + /// Initializes a new instance of . + /// + /// + /// The status of the item. One of `in_progress`, `completed`, or + /// `incomplete`. Populated when items are returned via API. + /// + /// The content associated with the message. + internal InternalResponsesDeveloperMessageItemResource(string id, ResponsesMessageItemResourceStatus status, IEnumerable content) : base(id, status, ResponsesMessageRole.Developer) + { + Content = content.ToList(); + } + + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + /// + /// The status of the item. One of `in_progress`, `completed`, or + /// `incomplete`. Populated when items are returned via API. + /// + /// The role associated with the message. + /// The content associated with the message. + internal InternalResponsesDeveloperMessageItemResource(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties, ResponsesMessageItemResourceStatus status, ResponsesMessageRole role, IList content) : base(@type, id, createdBy, additionalBinaryDataProperties, status, role) + { + Content = content; + } + + /// The content associated with the message. + public IList Content { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesMessageItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesMessageItemParam.Serialization.cs new file mode 100644 index 000000000000..82f50b82c1df --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesMessageItemParam.Serialization.cs @@ -0,0 +1,124 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalResponsesMessageItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalResponsesMessageItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesMessageItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("role"u8); + writer.WriteStringValue(Role.ToString()); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponsesMessageItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesMessageItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesMessageItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponsesMessageItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalResponsesMessageItemParam DeserializeInternalResponsesMessageItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("role"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "user": + return InternalResponsesUserMessageItemParam.DeserializeInternalResponsesUserMessageItemParam(element, options); + case "system": + return InternalResponsesSystemMessageItemParam.DeserializeInternalResponsesSystemMessageItemParam(element, options); + case "developer": + return InternalResponsesDeveloperMessageItemParam.DeserializeInternalResponsesDeveloperMessageItemParam(element, options); + case "assistant": + return InternalResponsesAssistantMessageItemParam.DeserializeInternalResponsesAssistantMessageItemParam(element, options); + } + } + return UnknownResponsesMessageItemParam.DeserializeUnknownResponsesMessageItemParam(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponsesMessageItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponsesMessageItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesMessageItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponsesMessageItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponsesMessageItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesMessageItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesMessageItemParam.cs new file mode 100644 index 000000000000..534739c4efd8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesMessageItemParam.cs @@ -0,0 +1,32 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalResponsesMessageItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The role associated with the message. + public InternalResponsesMessageItemParam(ResponsesMessageRole role) : base(AgentResponseItemKind.Message) + { + Role = role; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The role associated with the message. + internal InternalResponsesMessageItemParam(AgentResponseItemKind @type, IDictionary additionalBinaryDataProperties, ResponsesMessageRole role) : base(@type, additionalBinaryDataProperties) + { + Role = role; + } + + /// The role associated with the message. + internal ResponsesMessageRole Role { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesMessageItemResource.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesMessageItemResource.Serialization.cs new file mode 100644 index 000000000000..1e99463efa2b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesMessageItemResource.Serialization.cs @@ -0,0 +1,126 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalResponsesMessageItemResource : AgentResponseItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalResponsesMessageItemResource() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesMessageItemResource)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + writer.WritePropertyName("role"u8); + writer.WriteStringValue(Role.ToString()); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponsesMessageItemResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesMessageItemResource)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesMessageItemResource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponsesMessageItemResource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalResponsesMessageItemResource DeserializeInternalResponsesMessageItemResource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("role"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "user": + return InternalResponsesUserMessageItemResource.DeserializeInternalResponsesUserMessageItemResource(element, options); + case "system": + return InternalResponsesSystemMessageItemResource.DeserializeInternalResponsesSystemMessageItemResource(element, options); + case "developer": + return InternalResponsesDeveloperMessageItemResource.DeserializeInternalResponsesDeveloperMessageItemResource(element, options); + case "assistant": + return InternalResponsesAssistantMessageItemResource.DeserializeInternalResponsesAssistantMessageItemResource(element, options); + } + } + return UnknownResponsesMessageItemResource.DeserializeUnknownResponsesMessageItemResource(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponsesMessageItemResource)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponsesMessageItemResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesMessageItemResource)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponsesMessageItemResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponsesMessageItemResource)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesMessageItemResource.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesMessageItemResource.cs new file mode 100644 index 000000000000..cc2507b2e08b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesMessageItemResource.cs @@ -0,0 +1,51 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalResponsesMessageItemResource : AgentResponseItem + { + /// Initializes a new instance of . + /// + /// + /// The status of the item. One of `in_progress`, `completed`, or + /// `incomplete`. Populated when items are returned via API. + /// + /// The role associated with the message. + internal InternalResponsesMessageItemResource(string id, ResponsesMessageItemResourceStatus status, ResponsesMessageRole role) : base(AgentResponseItemKind.Message, id) + { + Status = status; + Role = role; + } + + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + /// + /// The status of the item. One of `in_progress`, `completed`, or + /// `incomplete`. Populated when items are returned via API. + /// + /// The role associated with the message. + internal InternalResponsesMessageItemResource(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties, ResponsesMessageItemResourceStatus status, ResponsesMessageRole role) : base(@type, id, createdBy, additionalBinaryDataProperties) + { + Status = status; + Role = role; + } + + /// + /// The status of the item. One of `in_progress`, `completed`, or + /// `incomplete`. Populated when items are returned via API. + /// + public ResponsesMessageItemResourceStatus Status { get; } + + /// The role associated with the message. + internal ResponsesMessageRole Role { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesSystemMessageItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesSystemMessageItemParam.Serialization.cs new file mode 100644 index 000000000000..8445bdae31d7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesSystemMessageItemParam.Serialization.cs @@ -0,0 +1,144 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalResponsesSystemMessageItemParam : InternalResponsesMessageItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalResponsesSystemMessageItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesSystemMessageItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("content"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Content); +#else + using (JsonDocument document = JsonDocument.Parse(Content)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponsesSystemMessageItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesSystemMessageItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesSystemMessageItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponsesSystemMessageItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalResponsesSystemMessageItemParam DeserializeInternalResponsesSystemMessageItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ResponsesMessageRole role = default; + BinaryData content = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("role"u8)) + { + role = new ResponsesMessageRole(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("content"u8)) + { + content = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalResponsesSystemMessageItemParam(@type, additionalBinaryDataProperties, role, content); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponsesSystemMessageItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponsesSystemMessageItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesSystemMessageItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponsesSystemMessageItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponsesSystemMessageItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesSystemMessageItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesSystemMessageItemParam.cs new file mode 100644 index 000000000000..b6e76f0514ac --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesSystemMessageItemParam.cs @@ -0,0 +1,75 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalResponsesSystemMessageItemParam : InternalResponsesMessageItemParam + { + /// Initializes a new instance of . + /// The content associated with the message. + /// is null. + public InternalResponsesSystemMessageItemParam(BinaryData content) : base(ResponsesMessageRole.System) + { + Argument.AssertNotNull(content, nameof(content)); + + Content = content; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The role associated with the message. + /// The content associated with the message. + internal InternalResponsesSystemMessageItemParam(AgentResponseItemKind @type, IDictionary additionalBinaryDataProperties, ResponsesMessageRole role, BinaryData content) : base(@type, additionalBinaryDataProperties, role) + { + Content = content; + } + + /// + /// The content associated with the message. + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// where T is of type . + /// + /// + /// + /// + /// + /// 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" }. + /// + /// + /// + /// + public BinaryData Content { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesSystemMessageItemResource.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesSystemMessageItemResource.Serialization.cs new file mode 100644 index 000000000000..5f56ab82870c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesSystemMessageItemResource.Serialization.cs @@ -0,0 +1,176 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalResponsesSystemMessageItemResource : InternalResponsesMessageItemResource, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalResponsesSystemMessageItemResource() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesSystemMessageItemResource)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("content"u8); + writer.WriteStartArray(); + foreach (InternalItemContent item in Content) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponsesSystemMessageItemResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesSystemMessageItemResource)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesSystemMessageItemResource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponsesSystemMessageItemResource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalResponsesSystemMessageItemResource DeserializeInternalResponsesSystemMessageItemResource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + string id = default; + AgentResponseItemSource createdBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ResponsesMessageItemResourceStatus status = default; + ResponsesMessageRole role = default; + IList content = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdBy = AgentResponseItemSource.DeserializeAgentResponseItemSource(prop.Value, options); + continue; + } + if (prop.NameEquals("status"u8)) + { + status = new ResponsesMessageItemResourceStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("role"u8)) + { + role = new ResponsesMessageRole(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("content"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalItemContent.DeserializeInternalItemContent(item, options)); + } + content = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalResponsesSystemMessageItemResource( + @type, + id, + createdBy, + additionalBinaryDataProperties, + status, + role, + content); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponsesSystemMessageItemResource)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponsesSystemMessageItemResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesSystemMessageItemResource)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponsesSystemMessageItemResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponsesSystemMessageItemResource)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesSystemMessageItemResource.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesSystemMessageItemResource.cs new file mode 100644 index 000000000000..11e533bf3da2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesSystemMessageItemResource.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalResponsesSystemMessageItemResource : InternalResponsesMessageItemResource + { + /// Initializes a new instance of . + /// + /// + /// The status of the item. One of `in_progress`, `completed`, or + /// `incomplete`. Populated when items are returned via API. + /// + /// The content associated with the message. + internal InternalResponsesSystemMessageItemResource(string id, ResponsesMessageItemResourceStatus status, IEnumerable content) : base(id, status, ResponsesMessageRole.System) + { + Content = content.ToList(); + } + + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + /// + /// The status of the item. One of `in_progress`, `completed`, or + /// `incomplete`. Populated when items are returned via API. + /// + /// The role associated with the message. + /// The content associated with the message. + internal InternalResponsesSystemMessageItemResource(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties, ResponsesMessageItemResourceStatus status, ResponsesMessageRole role, IList content) : base(@type, id, createdBy, additionalBinaryDataProperties, status, role) + { + Content = content; + } + + /// The content associated with the message. + public IList Content { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesUserMessageItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesUserMessageItemParam.Serialization.cs new file mode 100644 index 000000000000..2e632ba84bd2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesUserMessageItemParam.Serialization.cs @@ -0,0 +1,144 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalResponsesUserMessageItemParam : InternalResponsesMessageItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalResponsesUserMessageItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesUserMessageItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("content"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Content); +#else + using (JsonDocument document = JsonDocument.Parse(Content)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponsesUserMessageItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesUserMessageItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesUserMessageItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponsesUserMessageItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalResponsesUserMessageItemParam DeserializeInternalResponsesUserMessageItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ResponsesMessageRole role = default; + BinaryData content = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("role"u8)) + { + role = new ResponsesMessageRole(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("content"u8)) + { + content = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalResponsesUserMessageItemParam(@type, additionalBinaryDataProperties, role, content); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponsesUserMessageItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponsesUserMessageItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesUserMessageItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponsesUserMessageItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponsesUserMessageItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesUserMessageItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesUserMessageItemParam.cs new file mode 100644 index 000000000000..354cb423c7c7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesUserMessageItemParam.cs @@ -0,0 +1,75 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalResponsesUserMessageItemParam : InternalResponsesMessageItemParam + { + /// Initializes a new instance of . + /// The content associated with the message. + /// is null. + public InternalResponsesUserMessageItemParam(BinaryData content) : base(ResponsesMessageRole.User) + { + Argument.AssertNotNull(content, nameof(content)); + + Content = content; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The role associated with the message. + /// The content associated with the message. + internal InternalResponsesUserMessageItemParam(AgentResponseItemKind @type, IDictionary additionalBinaryDataProperties, ResponsesMessageRole role, BinaryData content) : base(@type, additionalBinaryDataProperties, role) + { + Content = content; + } + + /// + /// The content associated with the message. + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// where T is of type . + /// + /// + /// + /// + /// + /// 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" }. + /// + /// + /// + /// + public BinaryData Content { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesUserMessageItemResource.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesUserMessageItemResource.Serialization.cs new file mode 100644 index 000000000000..cc35cfa18a0f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesUserMessageItemResource.Serialization.cs @@ -0,0 +1,176 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalResponsesUserMessageItemResource : InternalResponsesMessageItemResource, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalResponsesUserMessageItemResource() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesUserMessageItemResource)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("content"u8); + writer.WriteStartArray(); + foreach (InternalItemContent item in Content) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponsesUserMessageItemResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesUserMessageItemResource)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesUserMessageItemResource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponsesUserMessageItemResource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalResponsesUserMessageItemResource DeserializeInternalResponsesUserMessageItemResource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + string id = default; + AgentResponseItemSource createdBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ResponsesMessageItemResourceStatus status = default; + ResponsesMessageRole role = default; + IList content = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdBy = AgentResponseItemSource.DeserializeAgentResponseItemSource(prop.Value, options); + continue; + } + if (prop.NameEquals("status"u8)) + { + status = new ResponsesMessageItemResourceStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("role"u8)) + { + role = new ResponsesMessageRole(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("content"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalItemContent.DeserializeInternalItemContent(item, options)); + } + content = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalResponsesUserMessageItemResource( + @type, + id, + createdBy, + additionalBinaryDataProperties, + status, + role, + content); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponsesUserMessageItemResource)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponsesUserMessageItemResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesUserMessageItemResource)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponsesUserMessageItemResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponsesUserMessageItemResource)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesUserMessageItemResource.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesUserMessageItemResource.cs new file mode 100644 index 000000000000..f9da46cbe685 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalResponsesUserMessageItemResource.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalResponsesUserMessageItemResource : InternalResponsesMessageItemResource + { + /// Initializes a new instance of . + /// + /// + /// The status of the item. One of `in_progress`, `completed`, or + /// `incomplete`. Populated when items are returned via API. + /// + /// The content associated with the message. + internal InternalResponsesUserMessageItemResource(string id, ResponsesMessageItemResourceStatus status, IEnumerable content) : base(id, status, ResponsesMessageRole.User) + { + Content = content.ToList(); + } + + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + /// + /// The status of the item. One of `in_progress`, `completed`, or + /// `incomplete`. Populated when items are returned via API. + /// + /// The role associated with the message. + /// The content associated with the message. + internal InternalResponsesUserMessageItemResource(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties, ResponsesMessageItemResourceStatus status, ResponsesMessageRole role, IList content) : base(@type, id, createdBy, additionalBinaryDataProperties, status, role) + { + Content = content; + } + + /// The content associated with the message. + public IList Content { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObject.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObject.Serialization.cs new file mode 100644 index 000000000000..c8b1a74cf1f3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObject.Serialization.cs @@ -0,0 +1,145 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + [PersistableModelProxy(typeof(UnknownToolChoiceObject))] + internal abstract partial class InternalToolChoiceObject : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalToolChoiceObject() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalToolChoiceObject)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalToolChoiceObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalToolChoiceObject JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalToolChoiceObject)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalToolChoiceObject(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalToolChoiceObject DeserializeInternalToolChoiceObject(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "file_search": + return InternalToolChoiceObjectFileSearch.DeserializeInternalToolChoiceObjectFileSearch(element, options); + case "computer_use_preview": + return InternalToolChoiceObjectComputer.DeserializeInternalToolChoiceObjectComputer(element, options); + case "web_search_preview": + return InternalToolChoiceObjectWebSearch.DeserializeInternalToolChoiceObjectWebSearch(element, options); + case "image_generation": + return InternalToolChoiceObjectImageGen.DeserializeInternalToolChoiceObjectImageGen(element, options); + case "code_interpreter": + return InternalToolChoiceObjectCodeInterpreter.DeserializeInternalToolChoiceObjectCodeInterpreter(element, options); + case "function": + return InternalToolChoiceObjectFunction.DeserializeInternalToolChoiceObjectFunction(element, options); + case "mcp": + return InternalToolChoiceObjectMCP.DeserializeInternalToolChoiceObjectMCP(element, options); + } + } + return UnknownToolChoiceObject.DeserializeUnknownToolChoiceObject(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalToolChoiceObject)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalToolChoiceObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalToolChoiceObject PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalToolChoiceObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalToolChoiceObject)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObject.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObject.cs new file mode 100644 index 000000000000..e711dad60aff --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObject.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal abstract partial class InternalToolChoiceObject + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + private protected InternalToolChoiceObject(ToolChoiceObjectType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalToolChoiceObject(ToolChoiceObjectType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Type. + internal ToolChoiceObjectType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectCodeInterpreter.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectCodeInterpreter.Serialization.cs new file mode 100644 index 000000000000..7ec2a81cd6dc --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectCodeInterpreter.Serialization.cs @@ -0,0 +1,118 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalToolChoiceObjectCodeInterpreter : InternalToolChoiceObject, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalToolChoiceObjectCodeInterpreter)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalToolChoiceObjectCodeInterpreter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalToolChoiceObjectCodeInterpreter)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalToolChoiceObject JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalToolChoiceObjectCodeInterpreter)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalToolChoiceObjectCodeInterpreter(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalToolChoiceObjectCodeInterpreter DeserializeInternalToolChoiceObjectCodeInterpreter(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolChoiceObjectType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolChoiceObjectType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalToolChoiceObjectCodeInterpreter(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalToolChoiceObjectCodeInterpreter)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalToolChoiceObjectCodeInterpreter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalToolChoiceObjectCodeInterpreter)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalToolChoiceObject PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalToolChoiceObjectCodeInterpreter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalToolChoiceObjectCodeInterpreter)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectCodeInterpreter.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectCodeInterpreter.cs new file mode 100644 index 000000000000..7463500487cd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectCodeInterpreter.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalToolChoiceObjectCodeInterpreter : InternalToolChoiceObject + { + /// Initializes a new instance of . + internal InternalToolChoiceObjectCodeInterpreter() : base(ToolChoiceObjectType.CodeInterpreter) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalToolChoiceObjectCodeInterpreter(ToolChoiceObjectType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectComputer.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectComputer.Serialization.cs new file mode 100644 index 000000000000..48440a9fa763 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectComputer.Serialization.cs @@ -0,0 +1,118 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalToolChoiceObjectComputer : InternalToolChoiceObject, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalToolChoiceObjectComputer)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalToolChoiceObjectComputer IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalToolChoiceObjectComputer)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalToolChoiceObject JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalToolChoiceObjectComputer)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalToolChoiceObjectComputer(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalToolChoiceObjectComputer DeserializeInternalToolChoiceObjectComputer(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolChoiceObjectType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolChoiceObjectType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalToolChoiceObjectComputer(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalToolChoiceObjectComputer)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalToolChoiceObjectComputer IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalToolChoiceObjectComputer)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalToolChoiceObject PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalToolChoiceObjectComputer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalToolChoiceObjectComputer)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectComputer.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectComputer.cs new file mode 100644 index 000000000000..3ae01341a4be --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectComputer.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalToolChoiceObjectComputer : InternalToolChoiceObject + { + /// Initializes a new instance of . + internal InternalToolChoiceObjectComputer() : base(ToolChoiceObjectType.Computer) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalToolChoiceObjectComputer(ToolChoiceObjectType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectFileSearch.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectFileSearch.Serialization.cs new file mode 100644 index 000000000000..421647b5cb22 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectFileSearch.Serialization.cs @@ -0,0 +1,118 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalToolChoiceObjectFileSearch : InternalToolChoiceObject, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalToolChoiceObjectFileSearch)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalToolChoiceObjectFileSearch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalToolChoiceObjectFileSearch)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalToolChoiceObject JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalToolChoiceObjectFileSearch)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalToolChoiceObjectFileSearch(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalToolChoiceObjectFileSearch DeserializeInternalToolChoiceObjectFileSearch(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolChoiceObjectType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolChoiceObjectType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalToolChoiceObjectFileSearch(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalToolChoiceObjectFileSearch)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalToolChoiceObjectFileSearch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalToolChoiceObjectFileSearch)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalToolChoiceObject PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalToolChoiceObjectFileSearch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalToolChoiceObjectFileSearch)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectFileSearch.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectFileSearch.cs new file mode 100644 index 000000000000..edc819df9564 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectFileSearch.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalToolChoiceObjectFileSearch : InternalToolChoiceObject + { + /// Initializes a new instance of . + internal InternalToolChoiceObjectFileSearch() : base(ToolChoiceObjectType.FileSearch) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalToolChoiceObjectFileSearch(ToolChoiceObjectType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectFunction.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectFunction.Serialization.cs new file mode 100644 index 000000000000..21264b605e28 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectFunction.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalToolChoiceObjectFunction : InternalToolChoiceObject, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalToolChoiceObjectFunction() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalToolChoiceObjectFunction)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalToolChoiceObjectFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalToolChoiceObjectFunction)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalToolChoiceObject JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalToolChoiceObjectFunction)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalToolChoiceObjectFunction(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalToolChoiceObjectFunction DeserializeInternalToolChoiceObjectFunction(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolChoiceObjectType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string name = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolChoiceObjectType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalToolChoiceObjectFunction(@type, additionalBinaryDataProperties, name); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalToolChoiceObjectFunction)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalToolChoiceObjectFunction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalToolChoiceObjectFunction)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalToolChoiceObject PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalToolChoiceObjectFunction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalToolChoiceObjectFunction)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectFunction.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectFunction.cs new file mode 100644 index 000000000000..69d5e0cbf4ad --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectFunction.cs @@ -0,0 +1,31 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalToolChoiceObjectFunction : InternalToolChoiceObject + { + /// Initializes a new instance of . + /// The name of the function to call. + internal InternalToolChoiceObjectFunction(string name) : base(ToolChoiceObjectType.Function) + { + Name = name; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The name of the function to call. + internal InternalToolChoiceObjectFunction(ToolChoiceObjectType @type, IDictionary additionalBinaryDataProperties, string name) : base(@type, additionalBinaryDataProperties) + { + Name = name; + } + + /// The name of the function to call. + public string Name { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectImageGen.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectImageGen.Serialization.cs new file mode 100644 index 000000000000..8531dce9513a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectImageGen.Serialization.cs @@ -0,0 +1,118 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalToolChoiceObjectImageGen : InternalToolChoiceObject, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalToolChoiceObjectImageGen)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalToolChoiceObjectImageGen IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalToolChoiceObjectImageGen)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalToolChoiceObject JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalToolChoiceObjectImageGen)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalToolChoiceObjectImageGen(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalToolChoiceObjectImageGen DeserializeInternalToolChoiceObjectImageGen(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolChoiceObjectType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolChoiceObjectType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalToolChoiceObjectImageGen(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalToolChoiceObjectImageGen)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalToolChoiceObjectImageGen IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalToolChoiceObjectImageGen)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalToolChoiceObject PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalToolChoiceObjectImageGen(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalToolChoiceObjectImageGen)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectImageGen.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectImageGen.cs new file mode 100644 index 000000000000..a573e5aad8a2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectImageGen.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalToolChoiceObjectImageGen : InternalToolChoiceObject + { + /// Initializes a new instance of . + internal InternalToolChoiceObjectImageGen() : base(ToolChoiceObjectType.ImageGeneration) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalToolChoiceObjectImageGen(ToolChoiceObjectType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectMCP.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectMCP.Serialization.cs new file mode 100644 index 000000000000..34b26c3fc172 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectMCP.Serialization.cs @@ -0,0 +1,147 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalToolChoiceObjectMCP : InternalToolChoiceObject, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalToolChoiceObjectMCP() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalToolChoiceObjectMCP)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("server_label"u8); + writer.WriteStringValue(ServerLabel); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalToolChoiceObjectMCP IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalToolChoiceObjectMCP)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalToolChoiceObject JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalToolChoiceObjectMCP)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalToolChoiceObjectMCP(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalToolChoiceObjectMCP DeserializeInternalToolChoiceObjectMCP(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolChoiceObjectType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string serverLabel = default; + string name = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolChoiceObjectType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("server_label"u8)) + { + serverLabel = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + name = null; + continue; + } + name = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalToolChoiceObjectMCP(@type, additionalBinaryDataProperties, serverLabel, name); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalToolChoiceObjectMCP)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalToolChoiceObjectMCP IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalToolChoiceObjectMCP)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalToolChoiceObject PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalToolChoiceObjectMCP(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalToolChoiceObjectMCP)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectMCP.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectMCP.cs new file mode 100644 index 000000000000..5b5d5f7c8bc5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectMCP.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalToolChoiceObjectMCP : InternalToolChoiceObject + { + /// Initializes a new instance of . + /// The label of the MCP server to use. + internal InternalToolChoiceObjectMCP(string serverLabel) : base(ToolChoiceObjectType.Mcp) + { + ServerLabel = serverLabel; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The label of the MCP server to use. + /// The name of the tool to call on the server. + internal InternalToolChoiceObjectMCP(ToolChoiceObjectType @type, IDictionary additionalBinaryDataProperties, string serverLabel, string name) : base(@type, additionalBinaryDataProperties) + { + ServerLabel = serverLabel; + Name = name; + } + + /// The label of the MCP server to use. + public string ServerLabel { get; } + + /// The name of the tool to call on the server. + public string Name { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectWebSearch.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectWebSearch.Serialization.cs new file mode 100644 index 000000000000..eee23c2d1690 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectWebSearch.Serialization.cs @@ -0,0 +1,118 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalToolChoiceObjectWebSearch : InternalToolChoiceObject, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalToolChoiceObjectWebSearch)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalToolChoiceObjectWebSearch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalToolChoiceObjectWebSearch)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalToolChoiceObject JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalToolChoiceObjectWebSearch)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalToolChoiceObjectWebSearch(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalToolChoiceObjectWebSearch DeserializeInternalToolChoiceObjectWebSearch(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolChoiceObjectType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolChoiceObjectType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalToolChoiceObjectWebSearch(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalToolChoiceObjectWebSearch)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalToolChoiceObjectWebSearch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalToolChoiceObjectWebSearch)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalToolChoiceObject PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalToolChoiceObjectWebSearch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalToolChoiceObjectWebSearch)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectWebSearch.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectWebSearch.cs new file mode 100644 index 000000000000..beae6258a07f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalToolChoiceObjectWebSearch.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalToolChoiceObjectWebSearch : InternalToolChoiceObject + { + /// Initializes a new instance of . + internal InternalToolChoiceObjectWebSearch() : base(ToolChoiceObjectType.WebSearch) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalToolChoiceObjectWebSearch(ToolChoiceObjectType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalTopLogProb.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalTopLogProb.Serialization.cs new file mode 100644 index 000000000000..387cbbc66f70 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalTopLogProb.Serialization.cs @@ -0,0 +1,165 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalTopLogProb : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalTopLogProb() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalTopLogProb)} does not support writing '{format}' format."); + } + writer.WritePropertyName("token"u8); + writer.WriteStringValue(Token); + writer.WritePropertyName("logprob"u8); + writer.WriteNumberValue(Logprob); + writer.WritePropertyName("bytes"u8); + writer.WriteStartArray(); + foreach (int item in Bytes) + { + writer.WriteNumberValue(item); + } + writer.WriteEndArray(); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalTopLogProb IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalTopLogProb JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalTopLogProb)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalTopLogProb(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalTopLogProb DeserializeInternalTopLogProb(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string token = default; + float logprob = default; + IList bytes = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("token"u8)) + { + token = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("logprob"u8)) + { + logprob = prop.Value.GetSingle(); + continue; + } + if (prop.NameEquals("bytes"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(item.GetInt32()); + } + bytes = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalTopLogProb(token, logprob, bytes, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalTopLogProb)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalTopLogProb IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalTopLogProb PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalTopLogProb(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalTopLogProb)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalTopLogProb.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalTopLogProb.cs new file mode 100644 index 000000000000..c3cf90766239 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalTopLogProb.cs @@ -0,0 +1,54 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalTopLogProb + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// + /// + /// or is null. + public InternalTopLogProb(string token, float logprob, IEnumerable bytes) + { + Argument.AssertNotNull(token, nameof(token)); + Argument.AssertNotNull(bytes, nameof(bytes)); + + Token = token; + Logprob = logprob; + Bytes = bytes.ToList(); + } + + /// Initializes a new instance of . + /// + /// + /// + /// Keeps track of any properties unknown to the library. + internal InternalTopLogProb(string token, float logprob, IList bytes, IDictionary additionalBinaryDataProperties) + { + Token = token; + Logprob = logprob; + Bytes = bytes; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Token. + public string Token { get; } + + /// Gets the Logprob. + public float Logprob { get; } + + /// Gets the Bytes. + public IList Bytes { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalVectorStoreFileAttributes.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalVectorStoreFileAttributes.Serialization.cs new file mode 100644 index 000000000000..3352803a7011 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalVectorStoreFileAttributes.Serialization.cs @@ -0,0 +1,171 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalVectorStoreFileAttributes : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalVectorStoreFileAttributes)} does not support writing '{format}' format."); + } + foreach (var item in AdditionalProperties) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + foreach (var item in AdditionalBooleanProperties) + { + writer.WritePropertyName(item.Key); + writer.WriteBooleanValue(item.Value); + } + foreach (var item in AdditionalInt32Properties) + { + writer.WritePropertyName(item.Key); + writer.WriteNumberValue(item.Value); + } + foreach (var item in AdditionalSingleProperties) + { + writer.WritePropertyName(item.Key); + writer.WriteNumberValue(item.Value); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalVectorStoreFileAttributes IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalVectorStoreFileAttributes JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalVectorStoreFileAttributes)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalVectorStoreFileAttributes(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalVectorStoreFileAttributes DeserializeInternalVectorStoreFileAttributes(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary additionalProperties = new ChangeTrackingDictionary(); + IDictionary additionalBooleanProperties = new ChangeTrackingDictionary(); + IDictionary additionalInt32Properties = new ChangeTrackingDictionary(); + IDictionary additionalSingleProperties = new ChangeTrackingDictionary(); + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + switch (prop.Value.ValueKind) + { + case JsonValueKind.String: + additionalProperties.Add(prop.Name, prop.Value.GetString()); + continue; + case JsonValueKind.True or JsonValueKind.False: + additionalBooleanProperties.Add(prop.Name, prop.Value.GetBoolean()); + continue; + case JsonValueKind.Number: + if (prop.Value.TryGetInt32(out int intValue)) + { + additionalInt32Properties.Add(prop.Name, intValue); + continue; + } + if (prop.Value.TryGetSingle(out float floatValue)) + { + additionalSingleProperties.Add(prop.Name, floatValue); + continue; + } + break; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalVectorStoreFileAttributes(additionalProperties, additionalBooleanProperties, additionalInt32Properties, additionalSingleProperties, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalVectorStoreFileAttributes)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalVectorStoreFileAttributes IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalVectorStoreFileAttributes PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalVectorStoreFileAttributes(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalVectorStoreFileAttributes)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalVectorStoreFileAttributes.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalVectorStoreFileAttributes.cs new file mode 100644 index 000000000000..4f669f9cac75 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalVectorStoreFileAttributes.cs @@ -0,0 +1,56 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalVectorStoreFileAttributes + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + private IDictionary _additionalStringProperties; + private IDictionary _additionalBooleanProperties; + private IDictionary _additionalInt32Properties; + private IDictionary _additionalSingleProperties; + + /// Initializes a new instance of . + public InternalVectorStoreFileAttributes() + { + _additionalStringProperties = new ChangeTrackingDictionary(); + _additionalBooleanProperties = new ChangeTrackingDictionary(); + _additionalInt32Properties = new ChangeTrackingDictionary(); + _additionalSingleProperties = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// + /// + /// + /// + /// Keeps track of any properties unknown to the library. + internal InternalVectorStoreFileAttributes(IDictionary additionalProperties, IDictionary additionalBooleanProperties, IDictionary additionalInt32Properties, IDictionary additionalSingleProperties, IDictionary additionalBinaryDataProperties) + { + _additionalStringProperties = additionalProperties; + _additionalBooleanProperties = additionalBooleanProperties; + _additionalInt32Properties = additionalInt32Properties; + _additionalSingleProperties = additionalSingleProperties; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the AdditionalProperties. + public IDictionary AdditionalProperties => _additionalStringProperties; + + /// Gets the AdditionalBooleanProperties. + public IDictionary AdditionalBooleanProperties => _additionalBooleanProperties; + + /// Gets the AdditionalInt32Properties. + public IDictionary AdditionalInt32Properties => _additionalInt32Properties; + + /// Gets the AdditionalSingleProperties. + public IDictionary AdditionalSingleProperties => _additionalSingleProperties; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchAction.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchAction.Serialization.cs new file mode 100644 index 000000000000..7413e6669100 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchAction.Serialization.cs @@ -0,0 +1,137 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + [PersistableModelProxy(typeof(UnknownWebSearchAction))] + internal abstract partial class InternalWebSearchAction : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalWebSearchAction() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchAction)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToSerialString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalWebSearchAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalWebSearchAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchAction)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalWebSearchAction(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalWebSearchAction DeserializeInternalWebSearchAction(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "find": + return InternalWebSearchActionFind.DeserializeInternalWebSearchActionFind(element, options); + case "open_page": + return InternalWebSearchActionOpenPage.DeserializeInternalWebSearchActionOpenPage(element, options); + case "search": + return InternalWebSearchActionSearch.DeserializeInternalWebSearchActionSearch(element, options); + } + } + return UnknownWebSearchAction.DeserializeUnknownWebSearchAction(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalWebSearchAction)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalWebSearchAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalWebSearchAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalWebSearchAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalWebSearchAction)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchAction.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchAction.cs new file mode 100644 index 000000000000..372397a91f43 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchAction.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal abstract partial class InternalWebSearchAction + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + private protected InternalWebSearchAction(WebSearchActionType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalWebSearchAction(WebSearchActionType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Type. + internal WebSearchActionType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchActionFind.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchActionFind.Serialization.cs new file mode 100644 index 000000000000..c60302da6b96 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchActionFind.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalWebSearchActionFind : InternalWebSearchAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalWebSearchActionFind() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchActionFind)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Url.AbsoluteUri); + writer.WritePropertyName("pattern"u8); + writer.WriteStringValue(Pattern); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalWebSearchActionFind IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalWebSearchActionFind)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalWebSearchAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchActionFind)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalWebSearchActionFind(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalWebSearchActionFind DeserializeInternalWebSearchActionFind(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + WebSearchActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + Uri url = default; + string pattern = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToWebSearchActionType(); + continue; + } + if (prop.NameEquals("url"u8)) + { + url = new Uri(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("pattern"u8)) + { + pattern = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalWebSearchActionFind(@type, additionalBinaryDataProperties, url, pattern); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalWebSearchActionFind)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalWebSearchActionFind IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalWebSearchActionFind)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalWebSearchAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalWebSearchActionFind(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalWebSearchActionFind)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchActionFind.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchActionFind.cs new file mode 100644 index 000000000000..05dea0bbeafa --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchActionFind.cs @@ -0,0 +1,43 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalWebSearchActionFind : InternalWebSearchAction + { + /// Initializes a new instance of . + /// The URL of the page searched for the pattern. + /// The pattern or text to search for within the page. + /// or is null. + public InternalWebSearchActionFind(Uri url, string pattern) : base(WebSearchActionType.Find) + { + Argument.AssertNotNull(url, nameof(url)); + Argument.AssertNotNull(pattern, nameof(pattern)); + + Url = url; + Pattern = pattern; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The URL of the page searched for the pattern. + /// The pattern or text to search for within the page. + internal InternalWebSearchActionFind(WebSearchActionType @type, IDictionary additionalBinaryDataProperties, Uri url, string pattern) : base(@type, additionalBinaryDataProperties) + { + Url = url; + Pattern = pattern; + } + + /// The URL of the page searched for the pattern. + public Uri Url { get; } + + /// The pattern or text to search for within the page. + public string Pattern { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchActionOpenPage.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchActionOpenPage.Serialization.cs new file mode 100644 index 000000000000..ec73672b6daa --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchActionOpenPage.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalWebSearchActionOpenPage : InternalWebSearchAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalWebSearchActionOpenPage() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchActionOpenPage)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Url.AbsoluteUri); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalWebSearchActionOpenPage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalWebSearchActionOpenPage)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalWebSearchAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchActionOpenPage)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalWebSearchActionOpenPage(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalWebSearchActionOpenPage DeserializeInternalWebSearchActionOpenPage(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + WebSearchActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + Uri url = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToWebSearchActionType(); + continue; + } + if (prop.NameEquals("url"u8)) + { + url = new Uri(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalWebSearchActionOpenPage(@type, additionalBinaryDataProperties, url); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalWebSearchActionOpenPage)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalWebSearchActionOpenPage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalWebSearchActionOpenPage)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalWebSearchAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalWebSearchActionOpenPage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalWebSearchActionOpenPage)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchActionOpenPage.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchActionOpenPage.cs new file mode 100644 index 000000000000..ac6ec08bd440 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchActionOpenPage.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalWebSearchActionOpenPage : InternalWebSearchAction + { + /// Initializes a new instance of . + /// The URL opened by the model. + /// is null. + public InternalWebSearchActionOpenPage(Uri url) : base(WebSearchActionType.OpenPage) + { + Argument.AssertNotNull(url, nameof(url)); + + Url = url; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The URL opened by the model. + internal InternalWebSearchActionOpenPage(WebSearchActionType @type, IDictionary additionalBinaryDataProperties, Uri url) : base(@type, additionalBinaryDataProperties) + { + Url = url; + } + + /// The URL opened by the model. + public Uri Url { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchActionSearch.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchActionSearch.Serialization.cs new file mode 100644 index 000000000000..55cf3db06000 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchActionSearch.Serialization.cs @@ -0,0 +1,156 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalWebSearchActionSearch : InternalWebSearchAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalWebSearchActionSearch() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchActionSearch)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("query"u8); + writer.WriteStringValue(Query); + if (Optional.IsCollectionDefined(Sources)) + { + writer.WritePropertyName("sources"u8); + writer.WriteStartArray(); + foreach (WebSearchActionSearchSources item in Sources) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalWebSearchActionSearch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalWebSearchActionSearch)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalWebSearchAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchActionSearch)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalWebSearchActionSearch(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalWebSearchActionSearch DeserializeInternalWebSearchActionSearch(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + WebSearchActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string query = default; + IList sources = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToWebSearchActionType(); + continue; + } + if (prop.NameEquals("query"u8)) + { + query = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("sources"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(WebSearchActionSearchSources.DeserializeWebSearchActionSearchSources(item, options)); + } + sources = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalWebSearchActionSearch(@type, additionalBinaryDataProperties, query, sources ?? new ChangeTrackingList()); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalWebSearchActionSearch)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalWebSearchActionSearch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalWebSearchActionSearch)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalWebSearchAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalWebSearchActionSearch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalWebSearchActionSearch)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchActionSearch.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchActionSearch.cs new file mode 100644 index 000000000000..9ba31e7f2938 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchActionSearch.cs @@ -0,0 +1,41 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalWebSearchActionSearch : InternalWebSearchAction + { + /// Initializes a new instance of . + /// The search query. + /// is null. + public InternalWebSearchActionSearch(string query) : base(WebSearchActionType.Search) + { + Argument.AssertNotNull(query, nameof(query)); + + Query = query; + Sources = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The search query. + /// The sources used in the search. + internal InternalWebSearchActionSearch(WebSearchActionType @type, IDictionary additionalBinaryDataProperties, string query, IList sources) : base(@type, additionalBinaryDataProperties) + { + Query = query; + Sources = sources; + } + + /// The search query. + public string Query { get; } + + /// The sources used in the search. + public IList Sources { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchPreviewTool.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchPreviewTool.Serialization.cs new file mode 100644 index 000000000000..7b8f63894f5a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchPreviewTool.Serialization.cs @@ -0,0 +1,149 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalWebSearchPreviewTool : AgentTool, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchPreviewTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(UserLocation)) + { + writer.WritePropertyName("user_location"u8); + writer.WriteObjectValue(UserLocation, options); + } + if (Optional.IsDefined(SearchContextSize)) + { + writer.WritePropertyName("search_context_size"u8); + writer.WriteStringValue(SearchContextSize.Value.ToString()); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalWebSearchPreviewTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalWebSearchPreviewTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchPreviewTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalWebSearchPreviewTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalWebSearchPreviewTool DeserializeInternalWebSearchPreviewTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + InternalLocation userLocation = default; + WebSearchPreviewToolSearchContextSize? searchContextSize = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("user_location"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + userLocation = null; + continue; + } + userLocation = InternalLocation.DeserializeInternalLocation(prop.Value, options); + continue; + } + if (prop.NameEquals("search_context_size"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + searchContextSize = new WebSearchPreviewToolSearchContextSize(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalWebSearchPreviewTool(@type, additionalBinaryDataProperties, userLocation, searchContextSize); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalWebSearchPreviewTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalWebSearchPreviewTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalWebSearchPreviewTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalWebSearchPreviewTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalWebSearchPreviewTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchPreviewTool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchPreviewTool.cs new file mode 100644 index 000000000000..157a88c662c1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchPreviewTool.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalWebSearchPreviewTool : AgentTool + { + /// Initializes a new instance of . + public InternalWebSearchPreviewTool() : base(ToolType.WebSearchPreview) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The user's location. + /// High level guidance for the amount of context window space to use for the search. One of `low`, `medium`, or `high`. `medium` is the default. + internal InternalWebSearchPreviewTool(ToolType @type, IDictionary additionalBinaryDataProperties, InternalLocation userLocation, WebSearchPreviewToolSearchContextSize? searchContextSize) : base(@type, additionalBinaryDataProperties) + { + UserLocation = userLocation; + SearchContextSize = searchContextSize; + } + + /// The user's location. + public InternalLocation UserLocation { get; set; } + + /// High level guidance for the amount of context window space to use for the search. One of `low`, `medium`, or `high`. `medium` is the default. + public WebSearchPreviewToolSearchContextSize? SearchContextSize { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchToolCallItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchToolCallItemParam.Serialization.cs new file mode 100644 index 000000000000..5b44aea2c68f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchToolCallItemParam.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalWebSearchToolCallItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalWebSearchToolCallItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchToolCallItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("action"u8); + writer.WriteObjectValue(Action, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalWebSearchToolCallItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalWebSearchToolCallItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchToolCallItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalWebSearchToolCallItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalWebSearchToolCallItemParam DeserializeInternalWebSearchToolCallItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + InternalWebSearchAction action = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("action"u8)) + { + action = InternalWebSearchAction.DeserializeInternalWebSearchAction(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalWebSearchToolCallItemParam(@type, additionalBinaryDataProperties, action); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalWebSearchToolCallItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalWebSearchToolCallItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalWebSearchToolCallItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalWebSearchToolCallItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalWebSearchToolCallItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchToolCallItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchToolCallItemParam.cs new file mode 100644 index 000000000000..fd34ebf48440 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchToolCallItemParam.cs @@ -0,0 +1,44 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalWebSearchToolCallItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// + /// An object describing the specific action taken in this web search call. + /// Includes details on how the model used the web (search, open_page, find). + /// + /// is null. + public InternalWebSearchToolCallItemParam(InternalWebSearchAction action) : base(AgentResponseItemKind.WebSearchCall) + { + Argument.AssertNotNull(action, nameof(action)); + + Action = action; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// + /// An object describing the specific action taken in this web search call. + /// Includes details on how the model used the web (search, open_page, find). + /// + internal InternalWebSearchToolCallItemParam(AgentResponseItemKind @type, IDictionary additionalBinaryDataProperties, InternalWebSearchAction action) : base(@type, additionalBinaryDataProperties) + { + Action = action; + } + + /// + /// An object describing the specific action taken in this web search call. + /// Includes details on how the model used the web (search, open_page, find). + /// + public InternalWebSearchAction Action { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchToolCallItemResource.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchToolCallItemResource.Serialization.cs new file mode 100644 index 000000000000..af3ffb737de0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchToolCallItemResource.Serialization.cs @@ -0,0 +1,161 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalWebSearchToolCallItemResource : AgentResponseItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalWebSearchToolCallItemResource() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchToolCallItemResource)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + writer.WritePropertyName("action"u8); + writer.WriteObjectValue(Action, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalWebSearchToolCallItemResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalWebSearchToolCallItemResource)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchToolCallItemResource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalWebSearchToolCallItemResource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalWebSearchToolCallItemResource DeserializeInternalWebSearchToolCallItemResource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + string id = default; + AgentResponseItemSource createdBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + WebSearchToolCallItemResourceStatus status = default; + InternalWebSearchAction action = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdBy = AgentResponseItemSource.DeserializeAgentResponseItemSource(prop.Value, options); + continue; + } + if (prop.NameEquals("status"u8)) + { + status = new WebSearchToolCallItemResourceStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("action"u8)) + { + action = InternalWebSearchAction.DeserializeInternalWebSearchAction(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalWebSearchToolCallItemResource( + @type, + id, + createdBy, + additionalBinaryDataProperties, + status, + action); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalWebSearchToolCallItemResource)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalWebSearchToolCallItemResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalWebSearchToolCallItemResource)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalWebSearchToolCallItemResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalWebSearchToolCallItemResource)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchToolCallItemResource.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchToolCallItemResource.cs new file mode 100644 index 000000000000..c4cdd718a8b7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/InternalWebSearchToolCallItemResource.cs @@ -0,0 +1,51 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class InternalWebSearchToolCallItemResource : AgentResponseItem + { + /// Initializes a new instance of . + /// + /// The status of the web search tool call. + /// + /// An object describing the specific action taken in this web search call. + /// Includes details on how the model used the web (search, open_page, find). + /// + internal InternalWebSearchToolCallItemResource(string id, WebSearchToolCallItemResourceStatus status, InternalWebSearchAction action) : base(AgentResponseItemKind.WebSearchCall, id) + { + Status = status; + Action = action; + } + + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + /// The status of the web search tool call. + /// + /// An object describing the specific action taken in this web search call. + /// Includes details on how the model used the web (search, open_page, find). + /// + internal InternalWebSearchToolCallItemResource(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties, WebSearchToolCallItemResourceStatus status, InternalWebSearchAction action) : base(@type, id, createdBy, additionalBinaryDataProperties) + { + Status = status; + Action = action; + } + + /// The status of the web search tool call. + public WebSearchToolCallItemResourceStatus Status { get; } + + /// + /// An object describing the specific action taken in this web search call. + /// Includes details on how the model used the web (search, open_page, find). + /// + public InternalWebSearchAction Action { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ItemContentInputAudioFormat.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ItemContentInputAudioFormat.cs new file mode 100644 index 000000000000..46428194b85f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ItemContentInputAudioFormat.cs @@ -0,0 +1,65 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct ItemContentInputAudioFormat : IEquatable + { + private readonly string _value; + private const string Mp3Value = "mp3"; + private const string WavValue = "wav"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ItemContentInputAudioFormat(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Mp3. + public static ItemContentInputAudioFormat Mp3 { get; } = new ItemContentInputAudioFormat(Mp3Value); + + /// Gets the Wav. + public static ItemContentInputAudioFormat Wav { get; } = new ItemContentInputAudioFormat(WavValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ItemContentInputAudioFormat left, ItemContentInputAudioFormat right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ItemContentInputAudioFormat left, ItemContentInputAudioFormat right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ItemContentInputAudioFormat(string value) => new ItemContentInputAudioFormat(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ItemContentInputAudioFormat?(string value) => value == null ? null : new ItemContentInputAudioFormat(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ItemContentInputAudioFormat other && Equals(other); + + /// + public bool Equals(ItemContentInputAudioFormat other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ItemContentInputImageDetail.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ItemContentInputImageDetail.cs new file mode 100644 index 000000000000..9ae96dff18ac --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ItemContentInputImageDetail.cs @@ -0,0 +1,69 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct ItemContentInputImageDetail : IEquatable + { + private readonly string _value; + private const string LowValue = "low"; + private const string HighValue = "high"; + private const string AutoValue = "auto"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ItemContentInputImageDetail(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Low. + public static ItemContentInputImageDetail Low { get; } = new ItemContentInputImageDetail(LowValue); + + /// Gets the High. + public static ItemContentInputImageDetail High { get; } = new ItemContentInputImageDetail(HighValue); + + /// Gets the Auto. + public static ItemContentInputImageDetail Auto { get; } = new ItemContentInputImageDetail(AutoValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ItemContentInputImageDetail left, ItemContentInputImageDetail right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ItemContentInputImageDetail left, ItemContentInputImageDetail right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ItemContentInputImageDetail(string value) => new ItemContentInputImageDetail(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ItemContentInputImageDetail?(string value) => value == null ? null : new ItemContentInputImageDetail(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ItemContentInputImageDetail other && Equals(other); + + /// + public bool Equals(ItemContentInputImageDetail other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ItemContentType.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ItemContentType.Serialization.cs new file mode 100644 index 000000000000..eaa2f9a227e6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ItemContentType.Serialization.cs @@ -0,0 +1,58 @@ +// + +#nullable disable + +using System; + +namespace OpenAI +{ + internal static partial class ItemContentTypeExtensions + { + /// The value to serialize. + public static string ToSerialString(this ItemContentType value) => value switch + { + ItemContentType.InputText => "input_text", + ItemContentType.InputAudio => "input_audio", + ItemContentType.InputImage => "input_image", + ItemContentType.InputFile => "input_file", + ItemContentType.OutputText => "output_text", + ItemContentType.OutputAudio => "output_audio", + ItemContentType.Refusal => "refusal", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ItemContentType value.") + }; + + /// The value to deserialize. + public static ItemContentType ToItemContentType(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "input_text")) + { + return ItemContentType.InputText; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "input_audio")) + { + return ItemContentType.InputAudio; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "input_image")) + { + return ItemContentType.InputImage; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "input_file")) + { + return ItemContentType.InputFile; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "output_text")) + { + return ItemContentType.OutputText; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "output_audio")) + { + return ItemContentType.OutputAudio; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "refusal")) + { + return ItemContentType.Refusal; + } + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ItemContentType value."); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ItemContentType.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ItemContentType.cs new file mode 100644 index 000000000000..da75ee105bfd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ItemContentType.cs @@ -0,0 +1,25 @@ +// + +#nullable disable + +namespace OpenAI +{ + /// Multi-modal input and output contents. + internal enum ItemContentType + { + /// InputText. + InputText, + /// InputAudio. + InputAudio, + /// InputImage. + InputImage, + /// InputFile. + InputFile, + /// OutputText. + OutputText, + /// OutputAudio. + OutputAudio, + /// Refusal. + Refusal + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellAgentTool.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellAgentTool.Serialization.cs new file mode 100644 index 000000000000..ece6f53aecef --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellAgentTool.Serialization.cs @@ -0,0 +1,119 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// A tool that allows the model to execute shell commands in a local environment. + public partial class LocalShellAgentTool : AgentTool, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LocalShellAgentTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + LocalShellAgentTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (LocalShellAgentTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LocalShellAgentTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLocalShellAgentTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static LocalShellAgentTool DeserializeLocalShellAgentTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new LocalShellAgentTool(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(LocalShellAgentTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + LocalShellAgentTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (LocalShellAgentTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeLocalShellAgentTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LocalShellAgentTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellAgentTool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellAgentTool.cs new file mode 100644 index 000000000000..4cc25de1d60f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellAgentTool.cs @@ -0,0 +1,26 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// A tool that allows the model to execute shell commands in a local environment. + public partial class LocalShellAgentTool : AgentTool + { + /// Initializes a new instance of . + public LocalShellAgentTool() : base(ToolType.LocalShell) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal LocalShellAgentTool(ToolType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellAgentToolCallStatus.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellAgentToolCallStatus.cs new file mode 100644 index 000000000000..23fd1df41a95 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellAgentToolCallStatus.cs @@ -0,0 +1,69 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects.OpenAI +{ + /// + public readonly partial struct LocalShellAgentToolCallStatus : IEquatable + { + private readonly string _value; + private const string InProgressValue = "in_progress"; + private const string CompletedValue = "completed"; + private const string IncompleteValue = "incomplete"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public LocalShellAgentToolCallStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the InProgress. + public static LocalShellAgentToolCallStatus InProgress { get; } = new LocalShellAgentToolCallStatus(InProgressValue); + + /// Gets the Completed. + public static LocalShellAgentToolCallStatus Completed { get; } = new LocalShellAgentToolCallStatus(CompletedValue); + + /// Gets the Incomplete. + public static LocalShellAgentToolCallStatus Incomplete { get; } = new LocalShellAgentToolCallStatus(IncompleteValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(LocalShellAgentToolCallStatus left, LocalShellAgentToolCallStatus right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(LocalShellAgentToolCallStatus left, LocalShellAgentToolCallStatus right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator LocalShellAgentToolCallStatus(string value) => new LocalShellAgentToolCallStatus(value); + + /// Converts a string to a . + /// The value. + public static implicit operator LocalShellAgentToolCallStatus?(string value) => value == null ? null : new LocalShellAgentToolCallStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is LocalShellAgentToolCallStatus other && Equals(other); + + /// + public bool Equals(LocalShellAgentToolCallStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellAgentToolExecutionAction.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellAgentToolExecutionAction.Serialization.cs new file mode 100644 index 000000000000..b1849101ccb3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellAgentToolExecutionAction.Serialization.cs @@ -0,0 +1,255 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// Execute a shell command on the server. + public partial class LocalShellAgentToolExecutionAction : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal LocalShellAgentToolExecutionAction() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LocalShellAgentToolExecutionAction)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + writer.WritePropertyName("command"u8); + writer.WriteStartArray(); + foreach (string item in Command) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + if (Optional.IsDefined(TimeoutMs)) + { + writer.WritePropertyName("timeout_ms"u8); + writer.WriteNumberValue(TimeoutMs.Value); + } + if (Optional.IsDefined(WorkingDirectory)) + { + writer.WritePropertyName("working_directory"u8); + writer.WriteStringValue(WorkingDirectory); + } + writer.WritePropertyName("env"u8); + writer.WriteStartObject(); + foreach (var item in Env) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + if (Optional.IsDefined(User)) + { + writer.WritePropertyName("user"u8); + writer.WriteStringValue(User); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + LocalShellAgentToolExecutionAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual LocalShellAgentToolExecutionAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LocalShellAgentToolExecutionAction)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLocalShellAgentToolExecutionAction(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static LocalShellAgentToolExecutionAction DeserializeLocalShellAgentToolExecutionAction(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = default; + IList command = default; + int? timeoutMs = default; + string workingDirectory = default; + IDictionary env = default; + string user = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("command"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + command = array; + continue; + } + if (prop.NameEquals("timeout_ms"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + timeoutMs = null; + continue; + } + timeoutMs = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("working_directory"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + workingDirectory = null; + continue; + } + workingDirectory = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("env"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + env = dictionary; + continue; + } + if (prop.NameEquals("user"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + user = null; + continue; + } + user = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new LocalShellAgentToolExecutionAction( + @type, + command, + timeoutMs, + workingDirectory, + env, + user, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(LocalShellAgentToolExecutionAction)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + LocalShellAgentToolExecutionAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual LocalShellAgentToolExecutionAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeLocalShellAgentToolExecutionAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LocalShellAgentToolExecutionAction)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellAgentToolExecutionAction.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellAgentToolExecutionAction.cs new file mode 100644 index 000000000000..12ff4a24a54a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellAgentToolExecutionAction.cs @@ -0,0 +1,67 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects.OpenAI +{ + /// Execute a shell command on the server. + public partial class LocalShellAgentToolExecutionAction + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The command to run. + /// Environment variables to set for the command. + /// or is null. + public LocalShellAgentToolExecutionAction(IEnumerable command, IDictionary env) + { + Argument.AssertNotNull(command, nameof(command)); + Argument.AssertNotNull(env, nameof(env)); + + Command = command.ToList(); + Env = env; + } + + /// Initializes a new instance of . + /// The type of the local shell action. Always `exec`. + /// The command to run. + /// Optional timeout in milliseconds for the command. + /// Optional working directory to run the command in. + /// Environment variables to set for the command. + /// Optional user to run the command as. + /// Keeps track of any properties unknown to the library. + internal LocalShellAgentToolExecutionAction(string @type, IList command, int? timeoutMs, string workingDirectory, IDictionary env, string user, IDictionary additionalBinaryDataProperties) + { + Type = @type; + Command = command; + TimeoutMs = timeoutMs; + WorkingDirectory = workingDirectory; + Env = env; + User = user; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The type of the local shell action. Always `exec`. + internal string Type { get; } = "exec"; + + /// The command to run. + public IList Command { get; } + + /// Optional timeout in milliseconds for the command. + public int? TimeoutMs { get; set; } + + /// Optional working directory to run the command in. + public string WorkingDirectory { get; set; } + + /// Environment variables to set for the command. + public IDictionary Env { get; } + + /// Optional user to run the command as. + public string User { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellToolCallAgentResponseItem.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellToolCallAgentResponseItem.Serialization.cs new file mode 100644 index 000000000000..eb613836eb4e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellToolCallAgentResponseItem.Serialization.cs @@ -0,0 +1,173 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// + /// A tool call to run a command on the local shell. + /// + /// + public partial class LocalShellToolCallAgentResponseItem : AgentResponseItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal LocalShellToolCallAgentResponseItem() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LocalShellToolCallAgentResponseItem)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + writer.WritePropertyName("call_id"u8); + writer.WriteStringValue(CallId); + writer.WritePropertyName("action"u8); + writer.WriteObjectValue(Action, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + LocalShellToolCallAgentResponseItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (LocalShellToolCallAgentResponseItem)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LocalShellToolCallAgentResponseItem)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLocalShellToolCallAgentResponseItem(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static LocalShellToolCallAgentResponseItem DeserializeLocalShellToolCallAgentResponseItem(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + string id = default; + AgentResponseItemSource createdBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + LocalShellAgentToolCallStatus status = default; + string callId = default; + LocalShellAgentToolExecutionAction action = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdBy = AgentResponseItemSource.DeserializeAgentResponseItemSource(prop.Value, options); + continue; + } + if (prop.NameEquals("status"u8)) + { + status = new LocalShellAgentToolCallStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("call_id"u8)) + { + callId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("action"u8)) + { + action = LocalShellAgentToolExecutionAction.DeserializeLocalShellAgentToolExecutionAction(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new LocalShellToolCallAgentResponseItem( + @type, + id, + createdBy, + additionalBinaryDataProperties, + status, + callId, + action); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(LocalShellToolCallAgentResponseItem)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + LocalShellToolCallAgentResponseItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (LocalShellToolCallAgentResponseItem)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeLocalShellToolCallAgentResponseItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LocalShellToolCallAgentResponseItem)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellToolCallAgentResponseItem.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellToolCallAgentResponseItem.cs new file mode 100644 index 000000000000..f8675996b22a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellToolCallAgentResponseItem.cs @@ -0,0 +1,52 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// + /// A tool call to run a command on the local shell. + /// + /// + public partial class LocalShellToolCallAgentResponseItem : AgentResponseItem + { + /// Initializes a new instance of . + /// + /// + /// The unique ID of the local shell tool call generated by the model. + /// + internal LocalShellToolCallAgentResponseItem(string id, LocalShellAgentToolCallStatus status, string callId, LocalShellAgentToolExecutionAction action) : base(AgentResponseItemKind.LocalShellCall, id) + { + Status = status; + CallId = callId; + Action = action; + } + + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + /// + /// The unique ID of the local shell tool call generated by the model. + /// + internal LocalShellToolCallAgentResponseItem(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties, LocalShellAgentToolCallStatus status, string callId, LocalShellAgentToolExecutionAction action) : base(@type, id, createdBy, additionalBinaryDataProperties) + { + Status = status; + CallId = callId; + Action = action; + } + + /// Gets the Status. + public LocalShellAgentToolCallStatus Status { get; } + + /// The unique ID of the local shell tool call generated by the model. + public string CallId { get; } + + /// Gets the Action. + public LocalShellAgentToolExecutionAction Action { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellToolCallOutputAgentResponseItem.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellToolCallOutputAgentResponseItem.Serialization.cs new file mode 100644 index 000000000000..518b8092345a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellToolCallOutputAgentResponseItem.Serialization.cs @@ -0,0 +1,164 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// + /// The output of a local shell tool call. + /// + /// + public partial class LocalShellToolCallOutputAgentResponseItem : AgentResponseItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal LocalShellToolCallOutputAgentResponseItem() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LocalShellToolCallOutputAgentResponseItem)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + writer.WritePropertyName("output"u8); + writer.WriteStringValue(Output); + } + + /// The JSON reader. + /// The client options for reading and writing models. + LocalShellToolCallOutputAgentResponseItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (LocalShellToolCallOutputAgentResponseItem)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LocalShellToolCallOutputAgentResponseItem)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLocalShellToolCallOutputAgentResponseItem(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static LocalShellToolCallOutputAgentResponseItem DeserializeLocalShellToolCallOutputAgentResponseItem(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + string id = default; + AgentResponseItemSource createdBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + LocalShellAgentToolCallStatus status = default; + string output = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdBy = AgentResponseItemSource.DeserializeAgentResponseItemSource(prop.Value, options); + continue; + } + if (prop.NameEquals("status"u8)) + { + status = new LocalShellAgentToolCallStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("output"u8)) + { + output = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new LocalShellToolCallOutputAgentResponseItem( + @type, + id, + createdBy, + additionalBinaryDataProperties, + status, + output); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(LocalShellToolCallOutputAgentResponseItem)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + LocalShellToolCallOutputAgentResponseItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (LocalShellToolCallOutputAgentResponseItem)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeLocalShellToolCallOutputAgentResponseItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LocalShellToolCallOutputAgentResponseItem)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellToolCallOutputAgentResponseItem.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellToolCallOutputAgentResponseItem.cs new file mode 100644 index 000000000000..e023875b9cc2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocalShellToolCallOutputAgentResponseItem.cs @@ -0,0 +1,42 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// + /// The output of a local shell tool call. + /// + /// + public partial class LocalShellToolCallOutputAgentResponseItem : AgentResponseItem + { + /// Initializes a new instance of . + /// + /// + /// A JSON string of the output of the local shell tool call. + internal LocalShellToolCallOutputAgentResponseItem(string id, LocalShellAgentToolCallStatus status, string output) : base(AgentResponseItemKind.LocalShellCallOutput, id) + { + Status = status; + Output = output; + } + + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + /// + /// A JSON string of the output of the local shell tool call. + internal LocalShellToolCallOutputAgentResponseItem(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties, LocalShellAgentToolCallStatus status, string output) : base(@type, id, createdBy, additionalBinaryDataProperties) + { + Status = status; + Output = output; + } + + /// A JSON string of the output of the local shell tool call. + public string Output { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocationType.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocationType.cs new file mode 100644 index 000000000000..5465340de7b7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/LocationType.cs @@ -0,0 +1,62 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + /// + internal readonly partial struct LocationType : IEquatable + { + private readonly string _value; + private const string ApproximateValue = "approximate"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public LocationType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Approximate. + public static LocationType Approximate { get; } = new LocationType(ApproximateValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(LocationType left, LocationType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(LocationType left, LocationType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator LocationType(string value) => new LocationType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator LocationType?(string value) => value == null ? null : new LocationType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is LocationType other && Equals(other); + + /// + public bool Equals(LocationType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemoryItem.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemoryItem.Serialization.cs new file mode 100644 index 000000000000..2219019383a9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemoryItem.Serialization.cs @@ -0,0 +1,147 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.Projects; + +namespace Azure.AI.Projects.OpenAI +{ + /// + /// A single memory item stored in the memory store, containing content and metadata. + /// Please note this is the abstract base class. The derived classes available for instantiation are: . + /// + [PersistableModelProxy(typeof(UnknownMemoryItem))] + public abstract partial class MemoryItem : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal MemoryItem() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryItem)} does not support writing '{format}' format."); + } + writer.WritePropertyName("memory_id"u8); + writer.WriteStringValue(MemoryId); + writer.WritePropertyName("updated_at"u8); + writer.WriteNumberValue(UpdatedAt, "U"); + writer.WritePropertyName("scope"u8); + writer.WriteStringValue(Scope); + writer.WritePropertyName("content"u8); + writer.WriteStringValue(Content); + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemoryItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MemoryItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryItem)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemoryItem(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MemoryItem DeserializeMemoryItem(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("kind"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "user_profile": + return UserProfileMemoryItem.DeserializeUserProfileMemoryItem(element, options); + case "chat_summary": + return ChatSummaryMemoryItem.DeserializeChatSummaryMemoryItem(element, options); + } + } + return UnknownMemoryItem.DeserializeUnknownMemoryItem(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(MemoryItem)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemoryItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MemoryItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemoryItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemoryItem)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemoryItem.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemoryItem.cs new file mode 100644 index 000000000000..9be6a637ed78 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemoryItem.cs @@ -0,0 +1,66 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// + /// A single memory item stored in the memory store, containing content and metadata. + /// Please note this is the abstract base class. The derived classes available for instantiation are: . + /// + public abstract partial class MemoryItem + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The unique ID of the memory item. + /// The last update time of the memory item. + /// The namespace that logically groups and isolates memories, such as a user ID. + /// The content of the memory. + /// The kind of the memory item. + private protected MemoryItem(string memoryId, DateTimeOffset updatedAt, string scope, string content, MemoryItemKind kind) + { + MemoryId = memoryId; + UpdatedAt = updatedAt; + Scope = scope; + Content = content; + Kind = kind; + } + + /// Initializes a new instance of . + /// The unique ID of the memory item. + /// The last update time of the memory item. + /// The namespace that logically groups and isolates memories, such as a user ID. + /// The content of the memory. + /// The kind of the memory item. + /// Keeps track of any properties unknown to the library. + internal MemoryItem(string memoryId, DateTimeOffset updatedAt, string scope, string content, MemoryItemKind kind, IDictionary additionalBinaryDataProperties) + { + MemoryId = memoryId; + UpdatedAt = updatedAt; + Scope = scope; + Content = content; + Kind = kind; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The unique ID of the memory item. + public string MemoryId { get; } + + /// The last update time of the memory item. + public DateTimeOffset UpdatedAt { get; } + + /// The namespace that logically groups and isolates memories, such as a user ID. + public string Scope { get; } + + /// The content of the memory. + public string Content { get; } + + /// The kind of the memory item. + internal MemoryItemKind Kind { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemoryItemKind.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemoryItemKind.cs new file mode 100644 index 000000000000..5749ea7e83aa --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemoryItemKind.cs @@ -0,0 +1,67 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects.OpenAI +{ + /// Memory item kind. + internal readonly partial struct MemoryItemKind : IEquatable + { + private readonly string _value; + /// User profile information extracted from conversations. + private const string UserProfileValue = "user_profile"; + /// Summary of chat conversations. + private const string ChatSummaryValue = "chat_summary"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public MemoryItemKind(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// User profile information extracted from conversations. + public static MemoryItemKind UserProfile { get; } = new MemoryItemKind(UserProfileValue); + + /// Summary of chat conversations. + public static MemoryItemKind ChatSummary { get; } = new MemoryItemKind(ChatSummaryValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(MemoryItemKind left, MemoryItemKind right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(MemoryItemKind left, MemoryItemKind right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator MemoryItemKind(string value) => new MemoryItemKind(value); + + /// Converts a string to a . + /// The value. + public static implicit operator MemoryItemKind?(string value) => value == null ? null : new MemoryItemKind(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MemoryItemKind other && Equals(other); + + /// + public bool Equals(MemoryItemKind other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchItem.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchItem.Serialization.cs new file mode 100644 index 000000000000..1c564b78a024 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchItem.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// A retrieved memory item from memory search. + public partial class MemorySearchItem : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal MemorySearchItem() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemorySearchItem)} does not support writing '{format}' format."); + } + writer.WritePropertyName("memory_item"u8); + writer.WriteObjectValue(MemoryItem, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemorySearchItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MemorySearchItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemorySearchItem)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemorySearchItem(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MemorySearchItem DeserializeMemorySearchItem(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MemoryItem memoryItem = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("memory_item"u8)) + { + memoryItem = MemoryItem.DeserializeMemoryItem(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MemorySearchItem(memoryItem, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(MemorySearchItem)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemorySearchItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MemorySearchItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemorySearchItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemorySearchItem)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchItem.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchItem.cs new file mode 100644 index 000000000000..276504548de0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchItem.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// A retrieved memory item from memory search. + public partial class MemorySearchItem + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Retrieved memory item. + /// is null. + public MemorySearchItem(MemoryItem memoryItem) + { + Argument.AssertNotNull(memoryItem, nameof(memoryItem)); + + MemoryItem = memoryItem; + } + + /// Initializes a new instance of . + /// Retrieved memory item. + /// Keeps track of any properties unknown to the library. + internal MemorySearchItem(MemoryItem memoryItem, IDictionary additionalBinaryDataProperties) + { + MemoryItem = memoryItem; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Retrieved memory item. + public MemoryItem MemoryItem { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchTool.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchTool.Serialization.cs new file mode 100644 index 000000000000..88856c1e6571 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchTool.Serialization.cs @@ -0,0 +1,176 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// A tool for integrating memories into the agent. + public partial class MemorySearchTool : AgentTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal MemorySearchTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemorySearchTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("memory_store_name"u8); + writer.WriteStringValue(MemoryStoreName); + writer.WritePropertyName("scope"u8); + writer.WriteStringValue(Scope); + if (Optional.IsDefined(SearchOptions)) + { + writer.WritePropertyName("search_options"u8); + writer.WriteObjectValue(SearchOptions, options); + } + if (Optional.IsDefined(UpdateDelay)) + { + writer.WritePropertyName("update_delay"u8); + writer.WriteNumberValue(UpdateDelay.Value); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemorySearchTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (MemorySearchTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemorySearchTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemorySearchTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MemorySearchTool DeserializeMemorySearchTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string memoryStoreName = default; + string scope = default; + MemorySearchToolOptions searchOptions = default; + int? updateDelay = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("memory_store_name"u8)) + { + memoryStoreName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("scope"u8)) + { + scope = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("search_options"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + searchOptions = MemorySearchToolOptions.DeserializeMemorySearchToolOptions(prop.Value, options); + continue; + } + if (prop.NameEquals("update_delay"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + updateDelay = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MemorySearchTool( + @type, + additionalBinaryDataProperties, + memoryStoreName, + scope, + searchOptions, + updateDelay); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(MemorySearchTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemorySearchTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (MemorySearchTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemorySearchTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemorySearchTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchTool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchTool.cs new file mode 100644 index 000000000000..195bde2a7c9e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchTool.cs @@ -0,0 +1,66 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// A tool for integrating memories into the agent. + public partial class MemorySearchTool : AgentTool + { + /// Initializes a new instance of . + /// The name of the memory store to use. + /// + /// The namespace used to group and isolate memories, such as a user ID. + /// Limits which memories can be retrieved or updated. + /// Use special variable `{{$userId}}` to scope memories to the current signed-in user. + /// + /// or is null. + public MemorySearchTool(string memoryStoreName, string scope) : base(ToolType.MemorySearch) + { + Argument.AssertNotNull(memoryStoreName, nameof(memoryStoreName)); + Argument.AssertNotNull(scope, nameof(scope)); + + MemoryStoreName = memoryStoreName; + Scope = scope; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The name of the memory store to use. + /// + /// The namespace used to group and isolate memories, such as a user ID. + /// Limits which memories can be retrieved or updated. + /// Use special variable `{{$userId}}` to scope memories to the current signed-in user. + /// + /// Options for searching the memory store. + /// Time to wait before updating memories after inactivity (seconds). Default 300. + internal MemorySearchTool(ToolType @type, IDictionary additionalBinaryDataProperties, string memoryStoreName, string scope, MemorySearchToolOptions searchOptions, int? updateDelay) : base(@type, additionalBinaryDataProperties) + { + MemoryStoreName = memoryStoreName; + Scope = scope; + SearchOptions = searchOptions; + UpdateDelay = updateDelay; + } + + /// The name of the memory store to use. + public string MemoryStoreName { get; set; } + + /// + /// The namespace used to group and isolate memories, such as a user ID. + /// Limits which memories can be retrieved or updated. + /// Use special variable `{{$userId}}` to scope memories to the current signed-in user. + /// + public string Scope { get; set; } + + /// Options for searching the memory store. + public MemorySearchToolOptions SearchOptions { get; set; } + + /// Time to wait before updating memories after inactivity (seconds). Default 300. + public int? UpdateDelay { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchToolCallItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchToolCallItemParam.Serialization.cs new file mode 100644 index 000000000000..2620e7a7121a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchToolCallItemParam.Serialization.cs @@ -0,0 +1,143 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The MemorySearchToolCallItemParam. + internal partial class MemorySearchToolCallItemParam : InternalItemParam, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemorySearchToolCallItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsCollectionDefined(Results)) + { + writer.WritePropertyName("results"u8); + writer.WriteStartArray(); + foreach (MemorySearchItem item in Results) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemorySearchToolCallItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (MemorySearchToolCallItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemorySearchToolCallItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemorySearchToolCallItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MemorySearchToolCallItemParam DeserializeMemorySearchToolCallItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList results = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("results"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(MemorySearchItem.DeserializeMemorySearchItem(item, options)); + } + results = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MemorySearchToolCallItemParam(@type, additionalBinaryDataProperties, results ?? new ChangeTrackingList()); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(MemorySearchToolCallItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemorySearchToolCallItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (MemorySearchToolCallItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemorySearchToolCallItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemorySearchToolCallItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchToolCallItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchToolCallItemParam.cs new file mode 100644 index 000000000000..c87ccd472776 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchToolCallItemParam.cs @@ -0,0 +1,31 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// The MemorySearchToolCallItemParam. + internal partial class MemorySearchToolCallItemParam : InternalItemParam + { + /// Initializes a new instance of . + public MemorySearchToolCallItemParam() : base(AgentResponseItemKind.MemorySearchCall) + { + Results = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The results returned from the memory search. + internal MemorySearchToolCallItemParam(AgentResponseItemKind @type, IDictionary additionalBinaryDataProperties, IList results) : base(@type, additionalBinaryDataProperties) + { + Results = results; + } + + /// The results returned from the memory search. + public IList Results { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchToolCallResponseItem.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchToolCallResponseItem.Serialization.cs new file mode 100644 index 000000000000..8e254f1d1935 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchToolCallResponseItem.Serialization.cs @@ -0,0 +1,178 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The MemorySearchToolCallResponseItem. + public partial class MemorySearchToolCallResponseItem : AgentResponseItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal MemorySearchToolCallResponseItem() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemorySearchToolCallResponseItem)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + if (Optional.IsCollectionDefined(Results)) + { + writer.WritePropertyName("results"u8); + writer.WriteStartArray(); + foreach (MemorySearchItem item in Results) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemorySearchToolCallResponseItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (MemorySearchToolCallResponseItem)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemorySearchToolCallResponseItem)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemorySearchToolCallResponseItem(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MemorySearchToolCallResponseItem DeserializeMemorySearchToolCallResponseItem(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + string id = default; + AgentResponseItemSource createdBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + MemorySearchToolCallStatus status = default; + IList results = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdBy = AgentResponseItemSource.DeserializeAgentResponseItemSource(prop.Value, options); + continue; + } + if (prop.NameEquals("status"u8)) + { + status = new MemorySearchToolCallStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("results"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(MemorySearchItem.DeserializeMemorySearchItem(item, options)); + } + results = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MemorySearchToolCallResponseItem( + @type, + id, + createdBy, + additionalBinaryDataProperties, + status, + results ?? new ChangeTrackingList()); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(MemorySearchToolCallResponseItem)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemorySearchToolCallResponseItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (MemorySearchToolCallResponseItem)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemorySearchToolCallResponseItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemorySearchToolCallResponseItem)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchToolCallResponseItem.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchToolCallResponseItem.cs new file mode 100644 index 000000000000..3015b82176aa --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchToolCallResponseItem.cs @@ -0,0 +1,50 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// The MemorySearchToolCallResponseItem. + public partial class MemorySearchToolCallResponseItem : AgentResponseItem + { + /// Initializes a new instance of . + /// + /// + /// The status of the memory search tool call. One of `in_progress`, + /// `searching`, `completed`, `incomplete` or `failed`, + /// + internal MemorySearchToolCallResponseItem(string id, MemorySearchToolCallStatus status) : base(AgentResponseItemKind.MemorySearchCall, id) + { + Status = status; + Results = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + /// + /// The status of the memory search tool call. One of `in_progress`, + /// `searching`, `completed`, `incomplete` or `failed`, + /// + /// The results returned from the memory search. + internal MemorySearchToolCallResponseItem(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties, MemorySearchToolCallStatus status, IList results) : base(@type, id, createdBy, additionalBinaryDataProperties) + { + Status = status; + Results = results; + } + + /// + /// The status of the memory search tool call. One of `in_progress`, + /// `searching`, `completed`, `incomplete` or `failed`, + /// + public MemorySearchToolCallStatus Status { get; } + + /// The results returned from the memory search. + public IList Results { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchToolCallStatus.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchToolCallStatus.cs new file mode 100644 index 000000000000..1ab174b490ea --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchToolCallStatus.cs @@ -0,0 +1,77 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects.OpenAI +{ + /// + public readonly partial struct MemorySearchToolCallStatus : IEquatable + { + private readonly string _value; + private const string InProgressValue = "in_progress"; + private const string SearchingValue = "searching"; + private const string CompletedValue = "completed"; + private const string IncompleteValue = "incomplete"; + private const string FailedValue = "failed"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public MemorySearchToolCallStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the InProgress. + public static MemorySearchToolCallStatus InProgress { get; } = new MemorySearchToolCallStatus(InProgressValue); + + /// Gets the Searching. + public static MemorySearchToolCallStatus Searching { get; } = new MemorySearchToolCallStatus(SearchingValue); + + /// Gets the Completed. + public static MemorySearchToolCallStatus Completed { get; } = new MemorySearchToolCallStatus(CompletedValue); + + /// Gets the Incomplete. + public static MemorySearchToolCallStatus Incomplete { get; } = new MemorySearchToolCallStatus(IncompleteValue); + + /// Gets the Failed. + public static MemorySearchToolCallStatus Failed { get; } = new MemorySearchToolCallStatus(FailedValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(MemorySearchToolCallStatus left, MemorySearchToolCallStatus right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(MemorySearchToolCallStatus left, MemorySearchToolCallStatus right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator MemorySearchToolCallStatus(string value) => new MemorySearchToolCallStatus(value); + + /// Converts a string to a . + /// The value. + public static implicit operator MemorySearchToolCallStatus?(string value) => value == null ? null : new MemorySearchToolCallStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MemorySearchToolCallStatus other && Equals(other); + + /// + public bool Equals(MemorySearchToolCallStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchToolOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchToolOptions.Serialization.cs new file mode 100644 index 000000000000..d61b398ce2b5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchToolOptions.Serialization.cs @@ -0,0 +1,141 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// Memory search options. + public partial class MemorySearchToolOptions : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemorySearchToolOptions)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(MaxMemories)) + { + writer.WritePropertyName("max_memories"u8); + writer.WriteNumberValue(MaxMemories.Value); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemorySearchToolOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MemorySearchToolOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemorySearchToolOptions)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemorySearchToolOptions(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MemorySearchToolOptions DeserializeMemorySearchToolOptions(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? maxMemories = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("max_memories"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxMemories = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MemorySearchToolOptions(maxMemories, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(MemorySearchToolOptions)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemorySearchToolOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MemorySearchToolOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemorySearchToolOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemorySearchToolOptions)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchToolOptions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchToolOptions.cs new file mode 100644 index 000000000000..68153983403e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MemorySearchToolOptions.cs @@ -0,0 +1,33 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// Memory search options. + public partial class MemorySearchToolOptions + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public MemorySearchToolOptions() + { + } + + /// Initializes a new instance of . + /// Maximum number of memory items to return. + /// Keeps track of any properties unknown to the library. + internal MemorySearchToolOptions(int? maxMemories, IDictionary additionalBinaryDataProperties) + { + MaxMemories = maxMemories; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Maximum number of memory items to return. + public int? MaxMemories { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MicrosoftFabricAgentTool.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MicrosoftFabricAgentTool.Serialization.cs new file mode 100644 index 000000000000..27999dfc83b1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MicrosoftFabricAgentTool.Serialization.cs @@ -0,0 +1,132 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// The input definition information for a Microsoft Fabric tool as used to configure an agent. + public partial class MicrosoftFabricAgentTool : AgentTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal MicrosoftFabricAgentTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MicrosoftFabricAgentTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("fabric_dataagent_preview"u8); + writer.WriteObjectValue(FabricDataagentPreview, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + MicrosoftFabricAgentTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (MicrosoftFabricAgentTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MicrosoftFabricAgentTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMicrosoftFabricAgentTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MicrosoftFabricAgentTool DeserializeMicrosoftFabricAgentTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + FabricDataAgentToolOptions fabricDataagentPreview = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("fabric_dataagent_preview"u8)) + { + fabricDataagentPreview = FabricDataAgentToolOptions.DeserializeFabricDataAgentToolOptions(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MicrosoftFabricAgentTool(@type, additionalBinaryDataProperties, fabricDataagentPreview); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(MicrosoftFabricAgentTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MicrosoftFabricAgentTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (MicrosoftFabricAgentTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMicrosoftFabricAgentTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MicrosoftFabricAgentTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MicrosoftFabricAgentTool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MicrosoftFabricAgentTool.cs new file mode 100644 index 000000000000..3c4d6c1d1997 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/MicrosoftFabricAgentTool.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// The input definition information for a Microsoft Fabric tool as used to configure an agent. + public partial class MicrosoftFabricAgentTool : AgentTool + { + /// Initializes a new instance of . + /// The fabric data agent tool parameters. + /// is null. + public MicrosoftFabricAgentTool(FabricDataAgentToolOptions fabricDataagentPreview) : base(ToolType.FabricDataagentPreview) + { + Argument.AssertNotNull(fabricDataagentPreview, nameof(fabricDataagentPreview)); + + FabricDataagentPreview = fabricDataagentPreview; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The fabric data agent tool parameters. + internal MicrosoftFabricAgentTool(ToolType @type, IDictionary additionalBinaryDataProperties, FabricDataAgentToolOptions fabricDataagentPreview) : base(@type, additionalBinaryDataProperties) + { + FabricDataagentPreview = fabricDataagentPreview; + } + + /// The fabric data agent tool parameters. + public FabricDataAgentToolOptions FabricDataagentPreview { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Models/AzureAIProjectsOpenAIContext.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Models/AzureAIProjectsOpenAIContext.cs new file mode 100644 index 000000000000..8e68b7e7ac5a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Models/AzureAIProjectsOpenAIContext.cs @@ -0,0 +1,231 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; +using Azure.AI.Projects; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// + /// Context class which will be filled in by the System.ClientModel.SourceGeneration. + /// For more information + /// + [ModelReaderWriterBuildable(typeof(A2ATool))] + [ModelReaderWriterBuildable(typeof(AgentDefinition))] + [ModelReaderWriterBuildable(typeof(AgentInfo))] + [ModelReaderWriterBuildable(typeof(AgentObjectVersions))] + [ModelReaderWriterBuildable(typeof(AgentRecord))] + [ModelReaderWriterBuildable(typeof(AgentReference))] + [ModelReaderWriterBuildable(typeof(AgentResponseItem))] + [ModelReaderWriterBuildable(typeof(AgentResponseItemSource))] + [ModelReaderWriterBuildable(typeof(AgentStructuredOutputsResponseItem))] + [ModelReaderWriterBuildable(typeof(AgentTool))] + [ModelReaderWriterBuildable(typeof(AgentVersion))] + [ModelReaderWriterBuildable(typeof(AgentWorkflowActionResponseItem))] + [ModelReaderWriterBuildable(typeof(AzureAISearchAgentTool))] + [ModelReaderWriterBuildable(typeof(AzureAISearchToolIndex))] + [ModelReaderWriterBuildable(typeof(AzureAISearchToolOptions))] + [ModelReaderWriterBuildable(typeof(AzureFunctionAgentTool))] + [ModelReaderWriterBuildable(typeof(AzureFunctionBinding))] + [ModelReaderWriterBuildable(typeof(AzureFunctionDefinition))] + [ModelReaderWriterBuildable(typeof(AzureFunctionDefinitionFunction))] + [ModelReaderWriterBuildable(typeof(AzureFunctionStorageQueue))] + [ModelReaderWriterBuildable(typeof(BingCustomSearchAgentTool))] + [ModelReaderWriterBuildable(typeof(BingCustomSearchConfiguration))] + [ModelReaderWriterBuildable(typeof(BingCustomSearchToolParameters))] + [ModelReaderWriterBuildable(typeof(BingGroundingAgentTool))] + [ModelReaderWriterBuildable(typeof(BingGroundingSearchConfiguration))] + [ModelReaderWriterBuildable(typeof(BingGroundingSearchToolOptions))] + [ModelReaderWriterBuildable(typeof(BrowserAutomationAgentTool))] + [ModelReaderWriterBuildable(typeof(BrowserAutomationToolConnectionParameters))] + [ModelReaderWriterBuildable(typeof(BrowserAutomationToolParameters))] + [ModelReaderWriterBuildable(typeof(CaptureStructuredOutputsTool))] + [ModelReaderWriterBuildable(typeof(ChatSummaryMemoryItem))] + [ModelReaderWriterBuildable(typeof(ContainerApplicationAgentDefinition))] + [ModelReaderWriterBuildable(typeof(ContentFilterConfiguration))] + [ModelReaderWriterBuildable(typeof(FabricDataAgentToolOptions))] + [ModelReaderWriterBuildable(typeof(FoundryOpenAIError))] + [ModelReaderWriterBuildable(typeof(HostedAgentDefinition))] + [ModelReaderWriterBuildable(typeof(ImageBasedHostedAgentDefinition))] + [ModelReaderWriterBuildable(typeof(InternalAgentResponse))] + [ModelReaderWriterBuildable(typeof(InternalAgentResponseError))] + [ModelReaderWriterBuildable(typeof(InternalAnnotation))] + [ModelReaderWriterBuildable(typeof(InternalAnnotationFileCitation))] + [ModelReaderWriterBuildable(typeof(InternalAnnotationFilePath))] + [ModelReaderWriterBuildable(typeof(InternalAnnotationUrlCitation))] + [ModelReaderWriterBuildable(typeof(InternalApproximateLocation))] + [ModelReaderWriterBuildable(typeof(InternalCodeInterpreterOutput))] + [ModelReaderWriterBuildable(typeof(InternalCodeInterpreterOutputImage))] + [ModelReaderWriterBuildable(typeof(InternalCodeInterpreterOutputLogs))] + [ModelReaderWriterBuildable(typeof(InternalCodeInterpreterTool))] + [ModelReaderWriterBuildable(typeof(InternalCodeInterpreterToolAuto))] + [ModelReaderWriterBuildable(typeof(InternalCodeInterpreterToolCallItemParam))] + [ModelReaderWriterBuildable(typeof(InternalCodeInterpreterToolCallItemResource))] + [ModelReaderWriterBuildable(typeof(InternalComparisonFilter))] + [ModelReaderWriterBuildable(typeof(InternalCompoundFilter))] + [ModelReaderWriterBuildable(typeof(InternalComputerAction))] + [ModelReaderWriterBuildable(typeof(InternalComputerActionClick))] + [ModelReaderWriterBuildable(typeof(InternalComputerActionDoubleClick))] + [ModelReaderWriterBuildable(typeof(InternalComputerActionDrag))] + [ModelReaderWriterBuildable(typeof(InternalComputerActionKeyPress))] + [ModelReaderWriterBuildable(typeof(InternalComputerActionMove))] + [ModelReaderWriterBuildable(typeof(InternalComputerActionScreenshot))] + [ModelReaderWriterBuildable(typeof(InternalComputerActionScroll))] + [ModelReaderWriterBuildable(typeof(InternalComputerActionTypeKeys))] + [ModelReaderWriterBuildable(typeof(InternalComputerActionWait))] + [ModelReaderWriterBuildable(typeof(InternalComputerToolCallItemParam))] + [ModelReaderWriterBuildable(typeof(InternalComputerToolCallItemResource))] + [ModelReaderWriterBuildable(typeof(InternalComputerToolCallOutputItemOutput))] + [ModelReaderWriterBuildable(typeof(InternalComputerToolCallOutputItemOutputComputerScreenshot))] + [ModelReaderWriterBuildable(typeof(InternalComputerToolCallOutputItemParam))] + [ModelReaderWriterBuildable(typeof(InternalComputerToolCallOutputItemResource))] + [ModelReaderWriterBuildable(typeof(InternalComputerToolCallSafetyCheck))] + [ModelReaderWriterBuildable(typeof(InternalComputerUsePreviewTool))] + [ModelReaderWriterBuildable(typeof(InternalConversationList))] + [ModelReaderWriterBuildable(typeof(InternalCoordinate))] + [ModelReaderWriterBuildable(typeof(InternalEasyInputMessage))] + [ModelReaderWriterBuildable(typeof(InternalFileSearchTool))] + [ModelReaderWriterBuildable(typeof(InternalFileSearchToolCallItemParam))] + [ModelReaderWriterBuildable(typeof(InternalFileSearchToolCallItemParamResult))] + [ModelReaderWriterBuildable(typeof(InternalFileSearchToolCallItemResource))] + [ModelReaderWriterBuildable(typeof(InternalFunctionTool))] + [ModelReaderWriterBuildable(typeof(InternalFunctionToolCallItemParam))] + [ModelReaderWriterBuildable(typeof(InternalFunctionToolCallItemResource))] + [ModelReaderWriterBuildable(typeof(InternalFunctionToolCallOutputItemParam))] + [ModelReaderWriterBuildable(typeof(InternalFunctionToolCallOutputItemResource))] + [ModelReaderWriterBuildable(typeof(InternalImageGenTool))] + [ModelReaderWriterBuildable(typeof(InternalImageGenToolCallItemParam))] + [ModelReaderWriterBuildable(typeof(InternalImageGenToolCallItemResource))] + [ModelReaderWriterBuildable(typeof(InternalImageGenToolInputImageMask))] + [ModelReaderWriterBuildable(typeof(InternalItemContent))] + [ModelReaderWriterBuildable(typeof(InternalItemContentInputAudio))] + [ModelReaderWriterBuildable(typeof(InternalItemContentInputFile))] + [ModelReaderWriterBuildable(typeof(InternalItemContentInputImage))] + [ModelReaderWriterBuildable(typeof(InternalItemContentInputText))] + [ModelReaderWriterBuildable(typeof(InternalItemContentOutputAudio))] + [ModelReaderWriterBuildable(typeof(InternalItemContentOutputText))] + [ModelReaderWriterBuildable(typeof(InternalItemContentRefusal))] + [ModelReaderWriterBuildable(typeof(InternalItemParam))] + [ModelReaderWriterBuildable(typeof(InternalItemReferenceItemParam))] + [ModelReaderWriterBuildable(typeof(InternalLocalShellToolCallItemParam))] + [ModelReaderWriterBuildable(typeof(InternalLocalShellToolCallOutputItemParam))] + [ModelReaderWriterBuildable(typeof(InternalLocation))] + [ModelReaderWriterBuildable(typeof(InternalLogProb))] + [ModelReaderWriterBuildable(typeof(InternalMCPApprovalRequestItemParam))] + [ModelReaderWriterBuildable(typeof(InternalMCPApprovalRequestItemResource))] + [ModelReaderWriterBuildable(typeof(InternalMCPApprovalResponseItemParam))] + [ModelReaderWriterBuildable(typeof(InternalMCPApprovalResponseItemResource))] + [ModelReaderWriterBuildable(typeof(InternalMCPCallItemParam))] + [ModelReaderWriterBuildable(typeof(InternalMCPCallItemResource))] + [ModelReaderWriterBuildable(typeof(InternalMCPListToolsItemParam))] + [ModelReaderWriterBuildable(typeof(InternalMCPListToolsItemResource))] + [ModelReaderWriterBuildable(typeof(InternalMCPListToolsTool))] + [ModelReaderWriterBuildable(typeof(InternalMCPTool))] + [ModelReaderWriterBuildable(typeof(InternalMCPToolAllowedTools1))] + [ModelReaderWriterBuildable(typeof(InternalMCPToolRequireApproval1))] + [ModelReaderWriterBuildable(typeof(InternalMCPToolRequireApprovalAlways))] + [ModelReaderWriterBuildable(typeof(InternalMCPToolRequireApprovalNever))] + [ModelReaderWriterBuildable(typeof(InternalRankingOptions))] + [ModelReaderWriterBuildable(typeof(InternalReasoning))] + [ModelReaderWriterBuildable(typeof(InternalReasoningItemParam))] + [ModelReaderWriterBuildable(typeof(InternalReasoningItemResource))] + [ModelReaderWriterBuildable(typeof(InternalReasoningItemSummaryPart))] + [ModelReaderWriterBuildable(typeof(InternalReasoningItemSummaryTextPart))] + [ModelReaderWriterBuildable(typeof(InternalResponsesAssistantMessageItemParam))] + [ModelReaderWriterBuildable(typeof(InternalResponsesAssistantMessageItemResource))] + [ModelReaderWriterBuildable(typeof(InternalResponsesDeveloperMessageItemParam))] + [ModelReaderWriterBuildable(typeof(InternalResponsesDeveloperMessageItemResource))] + [ModelReaderWriterBuildable(typeof(InternalResponsesMessageItemParam))] + [ModelReaderWriterBuildable(typeof(InternalResponsesMessageItemResource))] + [ModelReaderWriterBuildable(typeof(InternalResponsesSystemMessageItemParam))] + [ModelReaderWriterBuildable(typeof(InternalResponsesSystemMessageItemResource))] + [ModelReaderWriterBuildable(typeof(InternalResponsesUserMessageItemParam))] + [ModelReaderWriterBuildable(typeof(InternalResponsesUserMessageItemResource))] + [ModelReaderWriterBuildable(typeof(InternalResponseTextFormatConfiguration))] + [ModelReaderWriterBuildable(typeof(InternalResponseTextFormatConfigurationJsonObject))] + [ModelReaderWriterBuildable(typeof(InternalResponseTextFormatConfigurationJsonSchema))] + [ModelReaderWriterBuildable(typeof(InternalResponseTextFormatConfigurationText))] + [ModelReaderWriterBuildable(typeof(InternalToolChoiceObject))] + [ModelReaderWriterBuildable(typeof(InternalToolChoiceObjectCodeInterpreter))] + [ModelReaderWriterBuildable(typeof(InternalToolChoiceObjectComputer))] + [ModelReaderWriterBuildable(typeof(InternalToolChoiceObjectFileSearch))] + [ModelReaderWriterBuildable(typeof(InternalToolChoiceObjectFunction))] + [ModelReaderWriterBuildable(typeof(InternalToolChoiceObjectImageGen))] + [ModelReaderWriterBuildable(typeof(InternalToolChoiceObjectMCP))] + [ModelReaderWriterBuildable(typeof(InternalToolChoiceObjectWebSearch))] + [ModelReaderWriterBuildable(typeof(InternalTopLogProb))] + [ModelReaderWriterBuildable(typeof(InternalVectorStoreFileAttributes))] + [ModelReaderWriterBuildable(typeof(InternalWebSearchAction))] + [ModelReaderWriterBuildable(typeof(InternalWebSearchActionFind))] + [ModelReaderWriterBuildable(typeof(InternalWebSearchActionOpenPage))] + [ModelReaderWriterBuildable(typeof(InternalWebSearchActionSearch))] + [ModelReaderWriterBuildable(typeof(InternalWebSearchPreviewTool))] + [ModelReaderWriterBuildable(typeof(InternalWebSearchToolCallItemParam))] + [ModelReaderWriterBuildable(typeof(InternalWebSearchToolCallItemResource))] + [ModelReaderWriterBuildable(typeof(LocalShellAgentTool))] + [ModelReaderWriterBuildable(typeof(LocalShellAgentToolExecutionAction))] + [ModelReaderWriterBuildable(typeof(LocalShellToolCallAgentResponseItem))] + [ModelReaderWriterBuildable(typeof(LocalShellToolCallOutputAgentResponseItem))] + [ModelReaderWriterBuildable(typeof(MemoryItem))] + [ModelReaderWriterBuildable(typeof(MemorySearchItem))] + [ModelReaderWriterBuildable(typeof(MemorySearchTool))] + [ModelReaderWriterBuildable(typeof(MemorySearchToolCallItemParam))] + [ModelReaderWriterBuildable(typeof(MemorySearchToolCallResponseItem))] + [ModelReaderWriterBuildable(typeof(MemorySearchToolOptions))] + [ModelReaderWriterBuildable(typeof(MicrosoftFabricAgentTool))] + [ModelReaderWriterBuildable(typeof(OAuthConsentRequestResponseItem))] + [ModelReaderWriterBuildable(typeof(OpenAPIAgentTool))] + [ModelReaderWriterBuildable(typeof(OpenAPIAnonymousAuthenticationDetails))] + [ModelReaderWriterBuildable(typeof(OpenAPIAuthenticationDetails))] + [ModelReaderWriterBuildable(typeof(OpenAPIFunctionDefinition))] + [ModelReaderWriterBuildable(typeof(OpenAPIFunctionEntry))] + [ModelReaderWriterBuildable(typeof(OpenAPIManagedAuthenticationDetails))] + [ModelReaderWriterBuildable(typeof(OpenApiManagedSecurityScheme))] + [ModelReaderWriterBuildable(typeof(OpenAPIProjectConnectionAuthenticationDetails))] + [ModelReaderWriterBuildable(typeof(OpenAPIProjectConnectionSecurityScheme))] + [ModelReaderWriterBuildable(typeof(ProjectConversation))] + [ModelReaderWriterBuildable(typeof(ProjectConversationCreationOptions))] + [ModelReaderWriterBuildable(typeof(ProjectConversationUpdateOptions))] + [ModelReaderWriterBuildable(typeof(Prompt))] + [ModelReaderWriterBuildable(typeof(PromptAgentDefinition))] + [ModelReaderWriterBuildable(typeof(ProtocolVersionRecord))] + [ModelReaderWriterBuildable(typeof(ResponseConversation1))] + [ModelReaderWriterBuildable(typeof(ResponseIncompleteDetails1))] + [ModelReaderWriterBuildable(typeof(ResponsePromptVariables))] + [ModelReaderWriterBuildable(typeof(ResponseText))] + [ModelReaderWriterBuildable(typeof(ResponseUsage))] + [ModelReaderWriterBuildable(typeof(ResponseUsageInputTokensDetails))] + [ModelReaderWriterBuildable(typeof(ResponseUsageOutputTokensDetails))] + [ModelReaderWriterBuildable(typeof(SharepointAgentTool))] + [ModelReaderWriterBuildable(typeof(SharePointGroundingToolOptions))] + [ModelReaderWriterBuildable(typeof(StructuredInputDefinition))] + [ModelReaderWriterBuildable(typeof(StructuredOutputDefinition))] + [ModelReaderWriterBuildable(typeof(ToolProjectConnection))] + [ModelReaderWriterBuildable(typeof(UnknownAgentDefinition))] + [ModelReaderWriterBuildable(typeof(UnknownAnnotation))] + [ModelReaderWriterBuildable(typeof(UnknownCodeInterpreterOutput))] + [ModelReaderWriterBuildable(typeof(UnknownComputerAction))] + [ModelReaderWriterBuildable(typeof(UnknownComputerToolCallOutputItemOutput))] + [ModelReaderWriterBuildable(typeof(UnknownHostedAgentDefinition))] + [ModelReaderWriterBuildable(typeof(UnknownItemContent))] + [ModelReaderWriterBuildable(typeof(UnknownItemParam))] + [ModelReaderWriterBuildable(typeof(UnknownItemResource))] + [ModelReaderWriterBuildable(typeof(UnknownLocation))] + [ModelReaderWriterBuildable(typeof(UnknownMemoryItem))] + [ModelReaderWriterBuildable(typeof(UnknownOpenAPIAuthenticationDetails))] + [ModelReaderWriterBuildable(typeof(UnknownReasoningItemSummaryPart))] + [ModelReaderWriterBuildable(typeof(UnknownResponsesMessageItemParam))] + [ModelReaderWriterBuildable(typeof(UnknownResponsesMessageItemResource))] + [ModelReaderWriterBuildable(typeof(UnknownResponseTextFormatConfiguration))] + [ModelReaderWriterBuildable(typeof(UnknownTool))] + [ModelReaderWriterBuildable(typeof(UnknownToolChoiceObject))] + [ModelReaderWriterBuildable(typeof(UnknownWebSearchAction))] + [ModelReaderWriterBuildable(typeof(UserProfileMemoryItem))] + [ModelReaderWriterBuildable(typeof(WebSearchActionSearchSources))] + [ModelReaderWriterBuildable(typeof(WorkflowAgentDefinition))] + public partial class AzureAIProjectsOpenAIContext : ModelReaderWriterContext + { + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OAuthConsentRequestResponseItem.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OAuthConsentRequestResponseItem.Serialization.cs new file mode 100644 index 000000000000..c6a6c656ff46 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OAuthConsentRequestResponseItem.Serialization.cs @@ -0,0 +1,163 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// Request from the service for the user to perform OAuth consent. + public partial class OAuthConsentRequestResponseItem : AgentResponseItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal OAuthConsentRequestResponseItem() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OAuthConsentRequestResponseItem)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("consent_link"u8); + writer.WriteStringValue(ConsentLink); + writer.WritePropertyName("server_label"u8); + writer.WriteStringValue(ServerLabel); + } + + /// The JSON reader. + /// The client options for reading and writing models. + OAuthConsentRequestResponseItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (OAuthConsentRequestResponseItem)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OAuthConsentRequestResponseItem)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOAuthConsentRequestResponseItem(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OAuthConsentRequestResponseItem DeserializeOAuthConsentRequestResponseItem(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + AgentResponseItemSource createdBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string id = default; + string consentLink = default; + string serverLabel = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdBy = AgentResponseItemSource.DeserializeAgentResponseItemSource(prop.Value, options); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("consent_link"u8)) + { + consentLink = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("server_label"u8)) + { + serverLabel = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new OAuthConsentRequestResponseItem( + @type, + createdBy, + additionalBinaryDataProperties, + id, + consentLink, + serverLabel); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(OAuthConsentRequestResponseItem)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + OAuthConsentRequestResponseItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (OAuthConsentRequestResponseItem)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeOAuthConsentRequestResponseItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OAuthConsentRequestResponseItem)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OAuthConsentRequestResponseItem.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OAuthConsentRequestResponseItem.cs new file mode 100644 index 000000000000..55b72d37d0c1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OAuthConsentRequestResponseItem.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// Request from the service for the user to perform OAuth consent. + public partial class OAuthConsentRequestResponseItem : AgentResponseItem + { + /// Initializes a new instance of . + /// + /// The link the user can use to perform OAuth consent. + /// The server label for the OAuth consent request. + internal OAuthConsentRequestResponseItem(string id, string consentLink, string serverLabel) : base(AgentResponseItemKind.OauthConsentRequest, id) + { + ConsentLink = consentLink; + ServerLabel = serverLabel; + } + + /// Initializes a new instance of . + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + /// + /// The link the user can use to perform OAuth consent. + /// The server label for the OAuth consent request. + internal OAuthConsentRequestResponseItem(AgentResponseItemKind @type, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties, string id, string consentLink, string serverLabel) : base(@type, id, createdBy, additionalBinaryDataProperties) + { + ConsentLink = consentLink; + ServerLabel = serverLabel; + } + + /// Gets the Id. + public override string Id { get; } + + /// The link the user can use to perform OAuth consent. + public string ConsentLink { get; } + + /// The server label for the OAuth consent request. + public string ServerLabel { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIAgentTool.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIAgentTool.Serialization.cs new file mode 100644 index 000000000000..157ef58aaa34 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIAgentTool.Serialization.cs @@ -0,0 +1,132 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// The input definition information for an OpenAPI tool as used to configure an agent. + public partial class OpenAPIAgentTool : AgentTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal OpenAPIAgentTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAPIAgentTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("openapi"u8); + writer.WriteObjectValue(Openapi, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + OpenAPIAgentTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (OpenAPIAgentTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAPIAgentTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAPIAgentTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OpenAPIAgentTool DeserializeOpenAPIAgentTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + OpenAPIFunctionDefinition openapi = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("openapi"u8)) + { + openapi = OpenAPIFunctionDefinition.DeserializeOpenAPIFunctionDefinition(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new OpenAPIAgentTool(@type, additionalBinaryDataProperties, openapi); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(OpenAPIAgentTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + OpenAPIAgentTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (OpenAPIAgentTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeOpenAPIAgentTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAPIAgentTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIAgentTool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIAgentTool.cs new file mode 100644 index 000000000000..cdcbb1ba1475 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIAgentTool.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// The input definition information for an OpenAPI tool as used to configure an agent. + public partial class OpenAPIAgentTool : AgentTool + { + /// Initializes a new instance of . + /// The openapi function definition. + /// is null. + public OpenAPIAgentTool(OpenAPIFunctionDefinition openapi) : base(ToolType.Openapi) + { + Argument.AssertNotNull(openapi, nameof(openapi)); + + Openapi = openapi; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The openapi function definition. + internal OpenAPIAgentTool(ToolType @type, IDictionary additionalBinaryDataProperties, OpenAPIFunctionDefinition openapi) : base(@type, additionalBinaryDataProperties) + { + Openapi = openapi; + } + + /// The openapi function definition. + public OpenAPIFunctionDefinition Openapi { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIAnonymousAuthenticationDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIAnonymousAuthenticationDetails.Serialization.cs new file mode 100644 index 000000000000..26b30680fe82 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIAnonymousAuthenticationDetails.Serialization.cs @@ -0,0 +1,118 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// Security details for OpenApi anonymous authentication. + public partial class OpenAPIAnonymousAuthenticationDetails : OpenAPIAuthenticationDetails, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAPIAnonymousAuthenticationDetails)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + OpenAPIAnonymousAuthenticationDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (OpenAPIAnonymousAuthenticationDetails)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override OpenAPIAuthenticationDetails JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAPIAnonymousAuthenticationDetails)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAPIAnonymousAuthenticationDetails(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OpenAPIAnonymousAuthenticationDetails DeserializeOpenAPIAnonymousAuthenticationDetails(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenApiAuthType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new OpenApiAuthType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new OpenAPIAnonymousAuthenticationDetails(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(OpenAPIAnonymousAuthenticationDetails)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + OpenAPIAnonymousAuthenticationDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (OpenAPIAnonymousAuthenticationDetails)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override OpenAPIAuthenticationDetails PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeOpenAPIAnonymousAuthenticationDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAPIAnonymousAuthenticationDetails)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIAnonymousAuthenticationDetails.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIAnonymousAuthenticationDetails.cs new file mode 100644 index 000000000000..d60a09d5838a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIAnonymousAuthenticationDetails.cs @@ -0,0 +1,25 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// Security details for OpenApi anonymous authentication. + public partial class OpenAPIAnonymousAuthenticationDetails : OpenAPIAuthenticationDetails + { + /// Initializes a new instance of . + public OpenAPIAnonymousAuthenticationDetails() : base(OpenApiAuthType.Anonymous) + { + } + + /// Initializes a new instance of . + /// The type of authentication, must be anonymous/project_connection/managed_identity. + /// Keeps track of any properties unknown to the library. + internal OpenAPIAnonymousAuthenticationDetails(OpenApiAuthType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIAuthenticationDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIAuthenticationDetails.Serialization.cs new file mode 100644 index 000000000000..8e5ee523d7fb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIAuthenticationDetails.Serialization.cs @@ -0,0 +1,140 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// + /// authentication details for OpenApiFunctionDefinition + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// + [PersistableModelProxy(typeof(UnknownOpenAPIAuthenticationDetails))] + public abstract partial class OpenAPIAuthenticationDetails : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal OpenAPIAuthenticationDetails() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAPIAuthenticationDetails)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + OpenAPIAuthenticationDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual OpenAPIAuthenticationDetails JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAPIAuthenticationDetails)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAPIAuthenticationDetails(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OpenAPIAuthenticationDetails DeserializeOpenAPIAuthenticationDetails(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "anonymous": + return OpenAPIAnonymousAuthenticationDetails.DeserializeOpenAPIAnonymousAuthenticationDetails(element, options); + case "project_connection": + return OpenAPIProjectConnectionAuthenticationDetails.DeserializeOpenAPIProjectConnectionAuthenticationDetails(element, options); + case "managed_identity": + return OpenAPIManagedAuthenticationDetails.DeserializeOpenAPIManagedAuthenticationDetails(element, options); + } + } + return UnknownOpenAPIAuthenticationDetails.DeserializeUnknownOpenAPIAuthenticationDetails(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(OpenAPIAuthenticationDetails)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + OpenAPIAuthenticationDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual OpenAPIAuthenticationDetails PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeOpenAPIAuthenticationDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAPIAuthenticationDetails)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIAuthenticationDetails.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIAuthenticationDetails.cs new file mode 100644 index 000000000000..6076bd24a4d9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIAuthenticationDetails.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// + /// authentication details for OpenApiFunctionDefinition + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// + public abstract partial class OpenAPIAuthenticationDetails + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The type of authentication, must be anonymous/project_connection/managed_identity. + private protected OpenAPIAuthenticationDetails(OpenApiAuthType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// The type of authentication, must be anonymous/project_connection/managed_identity. + /// Keeps track of any properties unknown to the library. + internal OpenAPIAuthenticationDetails(OpenApiAuthType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The type of authentication, must be anonymous/project_connection/managed_identity. + internal OpenApiAuthType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIFunctionDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIFunctionDefinition.Serialization.cs new file mode 100644 index 000000000000..2d4e5108e346 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIFunctionDefinition.Serialization.cs @@ -0,0 +1,242 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The input definition information for an openapi function. + public partial class OpenAPIFunctionDefinition : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal OpenAPIFunctionDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAPIFunctionDefinition)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("spec"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Spec); +#else + using (JsonDocument document = JsonDocument.Parse(Spec)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + writer.WritePropertyName("auth"u8); + writer.WriteObjectValue(Auth, options); + if (Optional.IsCollectionDefined(DefaultParams)) + { + writer.WritePropertyName("default_params"u8); + writer.WriteStartArray(); + foreach (string item in DefaultParams) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Functions)) + { + writer.WritePropertyName("functions"u8); + writer.WriteStartArray(); + foreach (OpenAPIFunctionEntry item in Functions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + OpenAPIFunctionDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual OpenAPIFunctionDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAPIFunctionDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAPIFunctionDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OpenAPIFunctionDefinition DeserializeOpenAPIFunctionDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string description = default; + BinaryData spec = default; + OpenAPIAuthenticationDetails auth = default; + IList defaultParams = default; + IReadOnlyList functions = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("spec"u8)) + { + spec = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("auth"u8)) + { + auth = OpenAPIAuthenticationDetails.DeserializeOpenAPIAuthenticationDetails(prop.Value, options); + continue; + } + if (prop.NameEquals("default_params"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + defaultParams = array; + continue; + } + if (prop.NameEquals("functions"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(OpenAPIFunctionEntry.DeserializeOpenAPIFunctionEntry(item, options)); + } + functions = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new OpenAPIFunctionDefinition( + name, + description, + spec, + auth, + defaultParams ?? new ChangeTrackingList(), + functions ?? new ChangeTrackingList(), + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(OpenAPIFunctionDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + OpenAPIFunctionDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual OpenAPIFunctionDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeOpenAPIFunctionDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAPIFunctionDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIFunctionDefinition.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIFunctionDefinition.cs new file mode 100644 index 000000000000..5351ec64518b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIFunctionDefinition.cs @@ -0,0 +1,97 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The input definition information for an openapi function. + public partial class OpenAPIFunctionDefinition + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The name of the function to be called. + /// The openapi function shape, described as a JSON Schema object. + /// Open API authentication details. + /// , or is null. + public OpenAPIFunctionDefinition(string name, BinaryData spec, OpenAPIAuthenticationDetails auth) + { + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(spec, nameof(spec)); + Argument.AssertNotNull(auth, nameof(auth)); + + Name = name; + Spec = spec; + Auth = auth; + DefaultParams = new ChangeTrackingList(); + Functions = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The name of the function to be called. + /// A description of what the function does, used by the model to choose when and how to call the function. + /// The openapi function shape, described as a JSON Schema object. + /// Open API authentication details. + /// List of OpenAPI spec parameters that will use user-provided defaults. + /// List of function definitions used by OpenApi tool. + /// Keeps track of any properties unknown to the library. + internal OpenAPIFunctionDefinition(string name, string description, BinaryData spec, OpenAPIAuthenticationDetails auth, IList defaultParams, IReadOnlyList functions, IDictionary additionalBinaryDataProperties) + { + Name = name; + Description = description; + Spec = spec; + Auth = auth; + DefaultParams = defaultParams; + Functions = functions; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The name of the function to be called. + public string Name { get; set; } + + /// A description of what the function does, used by the model to choose when and how to call the function. + public string Description { get; set; } + + /// + /// The openapi function shape, described as a JSON Schema object. + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData Spec { get; set; } + + /// Open API authentication details. + public OpenAPIAuthenticationDetails Auth { get; set; } + + /// List of OpenAPI spec parameters that will use user-provided defaults. + public IList DefaultParams { get; } + + /// List of function definitions used by OpenApi tool. + public IReadOnlyList Functions { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIFunctionEntry.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIFunctionEntry.Serialization.cs new file mode 100644 index 000000000000..ed3cd39228e6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIFunctionEntry.Serialization.cs @@ -0,0 +1,165 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The OpenAPIFunctionEntry. + public partial class OpenAPIFunctionEntry : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal OpenAPIFunctionEntry() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAPIFunctionEntry)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("parameters"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Parameters); +#else + using (JsonDocument document = JsonDocument.Parse(Parameters)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + OpenAPIFunctionEntry IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual OpenAPIFunctionEntry JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAPIFunctionEntry)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAPIFunctionEntry(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OpenAPIFunctionEntry DeserializeOpenAPIFunctionEntry(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string description = default; + BinaryData parameters = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("parameters"u8)) + { + parameters = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new OpenAPIFunctionEntry(name, description, parameters, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(OpenAPIFunctionEntry)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + OpenAPIFunctionEntry IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual OpenAPIFunctionEntry PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeOpenAPIFunctionEntry(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAPIFunctionEntry)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIFunctionEntry.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIFunctionEntry.cs new file mode 100644 index 000000000000..e25cbbe72a54 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIFunctionEntry.cs @@ -0,0 +1,77 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The OpenAPIFunctionEntry. + public partial class OpenAPIFunctionEntry + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The name of the function to be called. + /// The parameters the functions accepts, described as a JSON Schema object. + /// or is null. + public OpenAPIFunctionEntry(string name, BinaryData parameters) + { + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(parameters, nameof(parameters)); + + Name = name; + Parameters = parameters; + } + + /// Initializes a new instance of . + /// The name of the function to be called. + /// A description of what the function does, used by the model to choose when and how to call the function. + /// The parameters the functions accepts, described as a JSON Schema object. + /// Keeps track of any properties unknown to the library. + internal OpenAPIFunctionEntry(string name, string description, BinaryData parameters, IDictionary additionalBinaryDataProperties) + { + Name = name; + Description = description; + Parameters = parameters; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The name of the function to be called. + public string Name { get; set; } + + /// A description of what the function does, used by the model to choose when and how to call the function. + public string Description { get; set; } + + /// + /// The parameters the functions accepts, described as a JSON Schema object. + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData Parameters { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIManagedAuthenticationDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIManagedAuthenticationDetails.Serialization.cs new file mode 100644 index 000000000000..2543cbc49bc7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIManagedAuthenticationDetails.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// Security details for OpenApi managed_identity authentication. + public partial class OpenAPIManagedAuthenticationDetails : OpenAPIAuthenticationDetails, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal OpenAPIManagedAuthenticationDetails() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAPIManagedAuthenticationDetails)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("security_scheme"u8); + writer.WriteObjectValue(SecurityScheme, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + OpenAPIManagedAuthenticationDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (OpenAPIManagedAuthenticationDetails)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override OpenAPIAuthenticationDetails JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAPIManagedAuthenticationDetails)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAPIManagedAuthenticationDetails(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OpenAPIManagedAuthenticationDetails DeserializeOpenAPIManagedAuthenticationDetails(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenApiAuthType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + OpenApiManagedSecurityScheme securityScheme = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new OpenApiAuthType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("security_scheme"u8)) + { + securityScheme = OpenApiManagedSecurityScheme.DeserializeOpenApiManagedSecurityScheme(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new OpenAPIManagedAuthenticationDetails(@type, additionalBinaryDataProperties, securityScheme); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(OpenAPIManagedAuthenticationDetails)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + OpenAPIManagedAuthenticationDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (OpenAPIManagedAuthenticationDetails)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override OpenAPIAuthenticationDetails PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeOpenAPIManagedAuthenticationDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAPIManagedAuthenticationDetails)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIManagedAuthenticationDetails.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIManagedAuthenticationDetails.cs new file mode 100644 index 000000000000..2c000367a24c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIManagedAuthenticationDetails.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// Security details for OpenApi managed_identity authentication. + public partial class OpenAPIManagedAuthenticationDetails : OpenAPIAuthenticationDetails + { + /// Initializes a new instance of . + /// Connection auth security details. + /// is null. + public OpenAPIManagedAuthenticationDetails(OpenApiManagedSecurityScheme securityScheme) : base(OpenApiAuthType.ManagedIdentity) + { + Argument.AssertNotNull(securityScheme, nameof(securityScheme)); + + SecurityScheme = securityScheme; + } + + /// Initializes a new instance of . + /// The type of authentication, must be anonymous/project_connection/managed_identity. + /// Keeps track of any properties unknown to the library. + /// Connection auth security details. + internal OpenAPIManagedAuthenticationDetails(OpenApiAuthType @type, IDictionary additionalBinaryDataProperties, OpenApiManagedSecurityScheme securityScheme) : base(@type, additionalBinaryDataProperties) + { + SecurityScheme = securityScheme; + } + + /// Connection auth security details. + public OpenApiManagedSecurityScheme SecurityScheme { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIProjectConnectionAuthenticationDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIProjectConnectionAuthenticationDetails.Serialization.cs new file mode 100644 index 000000000000..94356acf8466 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIProjectConnectionAuthenticationDetails.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// Security details for OpenApi project connection authentication. + public partial class OpenAPIProjectConnectionAuthenticationDetails : OpenAPIAuthenticationDetails, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal OpenAPIProjectConnectionAuthenticationDetails() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAPIProjectConnectionAuthenticationDetails)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("security_scheme"u8); + writer.WriteObjectValue(SecurityScheme, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + OpenAPIProjectConnectionAuthenticationDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (OpenAPIProjectConnectionAuthenticationDetails)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override OpenAPIAuthenticationDetails JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAPIProjectConnectionAuthenticationDetails)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAPIProjectConnectionAuthenticationDetails(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OpenAPIProjectConnectionAuthenticationDetails DeserializeOpenAPIProjectConnectionAuthenticationDetails(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenApiAuthType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + OpenAPIProjectConnectionSecurityScheme securityScheme = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new OpenApiAuthType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("security_scheme"u8)) + { + securityScheme = OpenAPIProjectConnectionSecurityScheme.DeserializeOpenAPIProjectConnectionSecurityScheme(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new OpenAPIProjectConnectionAuthenticationDetails(@type, additionalBinaryDataProperties, securityScheme); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(OpenAPIProjectConnectionAuthenticationDetails)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + OpenAPIProjectConnectionAuthenticationDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (OpenAPIProjectConnectionAuthenticationDetails)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override OpenAPIAuthenticationDetails PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeOpenAPIProjectConnectionAuthenticationDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAPIProjectConnectionAuthenticationDetails)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIProjectConnectionAuthenticationDetails.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIProjectConnectionAuthenticationDetails.cs new file mode 100644 index 000000000000..0044ff9cdd05 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIProjectConnectionAuthenticationDetails.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// Security details for OpenApi project connection authentication. + public partial class OpenAPIProjectConnectionAuthenticationDetails : OpenAPIAuthenticationDetails + { + /// Initializes a new instance of . + /// Project connection auth security details. + /// is null. + public OpenAPIProjectConnectionAuthenticationDetails(OpenAPIProjectConnectionSecurityScheme securityScheme) : base(OpenApiAuthType.ProjectConnection) + { + Argument.AssertNotNull(securityScheme, nameof(securityScheme)); + + SecurityScheme = securityScheme; + } + + /// Initializes a new instance of . + /// The type of authentication, must be anonymous/project_connection/managed_identity. + /// Keeps track of any properties unknown to the library. + /// Project connection auth security details. + internal OpenAPIProjectConnectionAuthenticationDetails(OpenApiAuthType @type, IDictionary additionalBinaryDataProperties, OpenAPIProjectConnectionSecurityScheme securityScheme) : base(@type, additionalBinaryDataProperties) + { + SecurityScheme = securityScheme; + } + + /// Project connection auth security details. + public OpenAPIProjectConnectionSecurityScheme SecurityScheme { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIProjectConnectionSecurityScheme.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIProjectConnectionSecurityScheme.Serialization.cs new file mode 100644 index 000000000000..7334d7c4f9ef --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIProjectConnectionSecurityScheme.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// Security scheme for OpenApi managed_identity authentication. + public partial class OpenAPIProjectConnectionSecurityScheme : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal OpenAPIProjectConnectionSecurityScheme() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAPIProjectConnectionSecurityScheme)} does not support writing '{format}' format."); + } + writer.WritePropertyName("project_connection_id"u8); + writer.WriteStringValue(ProjectConnectionId); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + OpenAPIProjectConnectionSecurityScheme IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual OpenAPIProjectConnectionSecurityScheme JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAPIProjectConnectionSecurityScheme)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAPIProjectConnectionSecurityScheme(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OpenAPIProjectConnectionSecurityScheme DeserializeOpenAPIProjectConnectionSecurityScheme(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string projectConnectionId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("project_connection_id"u8)) + { + projectConnectionId = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new OpenAPIProjectConnectionSecurityScheme(projectConnectionId, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(OpenAPIProjectConnectionSecurityScheme)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + OpenAPIProjectConnectionSecurityScheme IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual OpenAPIProjectConnectionSecurityScheme PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeOpenAPIProjectConnectionSecurityScheme(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAPIProjectConnectionSecurityScheme)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIProjectConnectionSecurityScheme.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIProjectConnectionSecurityScheme.cs new file mode 100644 index 000000000000..12848b2594a7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenAPIProjectConnectionSecurityScheme.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// Security scheme for OpenApi managed_identity authentication. + public partial class OpenAPIProjectConnectionSecurityScheme + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Project connection id for Project Connection auth type. + /// is null. + public OpenAPIProjectConnectionSecurityScheme(string projectConnectionId) + { + Argument.AssertNotNull(projectConnectionId, nameof(projectConnectionId)); + + ProjectConnectionId = projectConnectionId; + } + + /// Initializes a new instance of . + /// Project connection id for Project Connection auth type. + /// Keeps track of any properties unknown to the library. + internal OpenAPIProjectConnectionSecurityScheme(string projectConnectionId, IDictionary additionalBinaryDataProperties) + { + ProjectConnectionId = projectConnectionId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Project connection id for Project Connection auth type. + public string ProjectConnectionId { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenApiAuthType.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenApiAuthType.cs new file mode 100644 index 000000000000..07e8fccf0612 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenApiAuthType.cs @@ -0,0 +1,74 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects.OpenAI +{ + /// + /// Authentication type for OpenApi endpoint. Allowed types are: + /// - Anonymous (no authentication required) + /// - Project Connection (requires project_connection_id to endpoint, as setup in AI Foundry) + /// - Managed_Identity (requires audience for identity based auth) + /// + internal readonly partial struct OpenApiAuthType : IEquatable + { + private readonly string _value; + private const string AnonymousValue = "anonymous"; + private const string ProjectConnectionValue = "project_connection"; + private const string ManagedIdentityValue = "managed_identity"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public OpenApiAuthType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Anonymous. + public static OpenApiAuthType Anonymous { get; } = new OpenApiAuthType(AnonymousValue); + + /// Gets the ProjectConnection. + public static OpenApiAuthType ProjectConnection { get; } = new OpenApiAuthType(ProjectConnectionValue); + + /// Gets the ManagedIdentity. + public static OpenApiAuthType ManagedIdentity { get; } = new OpenApiAuthType(ManagedIdentityValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(OpenApiAuthType left, OpenApiAuthType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(OpenApiAuthType left, OpenApiAuthType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator OpenApiAuthType(string value) => new OpenApiAuthType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator OpenApiAuthType?(string value) => value == null ? null : new OpenApiAuthType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OpenApiAuthType other && Equals(other); + + /// + public bool Equals(OpenApiAuthType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenApiManagedSecurityScheme.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenApiManagedSecurityScheme.Serialization.cs new file mode 100644 index 000000000000..8793648ba2cc --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenApiManagedSecurityScheme.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// Security scheme for OpenApi managed_identity authentication. + public partial class OpenApiManagedSecurityScheme : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal OpenApiManagedSecurityScheme() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiManagedSecurityScheme)} does not support writing '{format}' format."); + } + writer.WritePropertyName("audience"u8); + writer.WriteStringValue(Audience); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + OpenApiManagedSecurityScheme IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual OpenApiManagedSecurityScheme JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiManagedSecurityScheme)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenApiManagedSecurityScheme(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OpenApiManagedSecurityScheme DeserializeOpenApiManagedSecurityScheme(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string audience = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("audience"u8)) + { + audience = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new OpenApiManagedSecurityScheme(audience, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(OpenApiManagedSecurityScheme)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + OpenApiManagedSecurityScheme IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual OpenApiManagedSecurityScheme PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeOpenApiManagedSecurityScheme(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenApiManagedSecurityScheme)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenApiManagedSecurityScheme.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenApiManagedSecurityScheme.cs new file mode 100644 index 000000000000..8e1adcf63ebf --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/OpenApiManagedSecurityScheme.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// Security scheme for OpenApi managed_identity authentication. + public partial class OpenApiManagedSecurityScheme + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Authentication scope for managed_identity auth type. + /// is null. + public OpenApiManagedSecurityScheme(string audience) + { + Argument.AssertNotNull(audience, nameof(audience)); + + Audience = audience; + } + + /// Initializes a new instance of . + /// Authentication scope for managed_identity auth type. + /// Keeps track of any properties unknown to the library. + internal OpenApiManagedSecurityScheme(string audience, IDictionary additionalBinaryDataProperties) + { + Audience = audience; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Authentication scope for managed_identity auth type. + public string Audience { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProjectConversation.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProjectConversation.Serialization.cs new file mode 100644 index 000000000000..8cdf591661c0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProjectConversation.Serialization.cs @@ -0,0 +1,198 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The ProjectConversation. + public partial class ProjectConversation : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ProjectConversation() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProjectConversation)} does not support writing '{format}' format."); + } + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object); + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + if (Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"u8); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ProjectConversation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ProjectConversation JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProjectConversation)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProjectConversation(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ProjectConversation DeserializeProjectConversation(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string @object = default; + DateTimeOffset createdAt = default; + IDictionary metadata = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("object"u8)) + { + @object = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_at"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64()); + continue; + } + if (prop.NameEquals("metadata"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + metadata = new ChangeTrackingDictionary(); + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + metadata = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ProjectConversation(id, @object, createdAt, metadata, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(ProjectConversation)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ProjectConversation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ProjectConversation PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeProjectConversation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProjectConversation)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProjectConversation.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProjectConversation.cs new file mode 100644 index 000000000000..0e87d4aeca70 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProjectConversation.cs @@ -0,0 +1,72 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// The ProjectConversation. + public partial class ProjectConversation + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The unique ID of the conversation. + /// + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + internal ProjectConversation(string id, DateTimeOffset createdAt, IDictionary metadata) + { + Id = id; + CreatedAt = createdAt; + Metadata = metadata; + } + + /// Initializes a new instance of . + /// The unique ID of the conversation. + /// The object type, which is always 'conversation'. + /// + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + /// Keeps track of any properties unknown to the library. + internal ProjectConversation(string id, string @object, DateTimeOffset createdAt, IDictionary metadata, IDictionary additionalBinaryDataProperties) + { + Id = id; + Object = @object; + CreatedAt = createdAt; + Metadata = metadata; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The unique ID of the conversation. + public string Id { get; } + + /// Gets the CreatedAt. + public DateTimeOffset CreatedAt { get; } + + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + public IDictionary Metadata { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProjectConversationCreationOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProjectConversationCreationOptions.Serialization.cs new file mode 100644 index 000000000000..0e03b1f71f11 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProjectConversationCreationOptions.Serialization.cs @@ -0,0 +1,176 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// Create a conversation. + public partial class ProjectConversationCreationOptions : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProjectConversationCreationOptions)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsCollectionDefined(Items)) + { + writer.WritePropertyName("items"u8); + SerializeItemsValue(writer, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ProjectConversationCreationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ProjectConversationCreationOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProjectConversationCreationOptions)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProjectConversationCreationOptions(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ProjectConversationCreationOptions DeserializeProjectConversationCreationOptions(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary metadata = default; + IList items = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("metadata"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + metadata = dictionary; + continue; + } + if (prop.NameEquals("items"u8)) + { + DeserializeItemsValue(prop, ref items); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ProjectConversationCreationOptions(metadata ?? new ChangeTrackingDictionary(), items ?? new ChangeTrackingList(), additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(ProjectConversationCreationOptions)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ProjectConversationCreationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ProjectConversationCreationOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeProjectConversationCreationOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProjectConversationCreationOptions)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProjectConversationCreationOptions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProjectConversationCreationOptions.cs new file mode 100644 index 000000000000..6fee3be53582 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProjectConversationCreationOptions.cs @@ -0,0 +1,26 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// Create a conversation. + public partial class ProjectConversationCreationOptions + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + public IDictionary Metadata { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProjectConversationUpdateOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProjectConversationUpdateOptions.Serialization.cs new file mode 100644 index 000000000000..6173aa0df635 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProjectConversationUpdateOptions.Serialization.cs @@ -0,0 +1,164 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// Update a conversation. + public partial class ProjectConversationUpdateOptions : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProjectConversationUpdateOptions)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ProjectConversationUpdateOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ProjectConversationUpdateOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProjectConversationUpdateOptions)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProjectConversationUpdateOptions(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ProjectConversationUpdateOptions DeserializeProjectConversationUpdateOptions(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary metadata = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("metadata"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + metadata = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ProjectConversationUpdateOptions(metadata ?? new ChangeTrackingDictionary(), additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(ProjectConversationUpdateOptions)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ProjectConversationUpdateOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ProjectConversationUpdateOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeProjectConversationUpdateOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProjectConversationUpdateOptions)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProjectConversationUpdateOptions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProjectConversationUpdateOptions.cs new file mode 100644 index 000000000000..a92475640285 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProjectConversationUpdateOptions.cs @@ -0,0 +1,42 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// Update a conversation. + public partial class ProjectConversationUpdateOptions + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + /// Keeps track of any properties unknown to the library. + internal ProjectConversationUpdateOptions(IDictionary metadata, IDictionary additionalBinaryDataProperties) + { + Metadata = metadata; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + public IDictionary Metadata { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProjectsOpenAIModelFactory.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProjectsOpenAIModelFactory.cs new file mode 100644 index 000000000000..c1374fc51a24 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProjectsOpenAIModelFactory.cs @@ -0,0 +1,862 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// A factory class for creating instances of the models for mocking. + public static partial class ProjectsOpenAIModelFactory + { + /// + /// The AgentDefinition. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , and . + /// + /// + /// Configuration for Responsible AI (RAI) content filtering and safety features. + /// A new instance for mocking. + public static AgentDefinition AgentDefinition(string kind = default, ContentFilterConfiguration contentFilterConfiguration = default) + { + return new UnknownAgentDefinition(new AgentKind(kind), contentFilterConfiguration, additionalBinaryDataProperties: null); + } + + /// Configuration for Responsible AI (RAI) content filtering and safety features. + /// The name of the RAI policy to apply. + /// A new instance for mocking. + public static ContentFilterConfiguration ContentFilterConfiguration(string policyName = default) + { + return new ContentFilterConfiguration(policyName, additionalBinaryDataProperties: null); + } + + /// The workflow agent definition. + /// Configuration for Responsible AI (RAI) content filtering and safety features. + /// The CSDL YAML definition of the workflow. + /// A new instance for mocking. + public static WorkflowAgentDefinition WorkflowAgentDefinition(ContentFilterConfiguration contentFilterConfiguration = default, string workflowYaml = default) + { + return new WorkflowAgentDefinition(AgentKind.Workflow, contentFilterConfiguration, additionalBinaryDataProperties: null, workflowYaml); + } + + /// The hosted agent definition. + /// Configuration for Responsible AI (RAI) content filtering and safety features. + /// + /// An array of tools the hosted agent's model may call while generating a response. You + /// can specify which tool to use by setting the `tool_choice` parameter. + /// + /// The protocols that the agent supports for ingress communication of the containers. + /// The CPU configuration for the hosted agent. + /// The memory configuration for the hosted agent. + /// Environment variables to set in the hosted agent container. + /// A new instance for mocking. + public static HostedAgentDefinition HostedAgentDefinition(ContentFilterConfiguration contentFilterConfiguration = default, IEnumerable tools = default, IEnumerable containerProtocolVersions = default, string cpu = default, string memory = default, IDictionary environmentVariables = default) + { + tools ??= new ChangeTrackingList(); + containerProtocolVersions ??= new ChangeTrackingList(); + environmentVariables ??= new ChangeTrackingDictionary(); + + return new HostedAgentDefinition( + AgentKind.Hosted, + contentFilterConfiguration, + additionalBinaryDataProperties: null, + tools.ToList(), + containerProtocolVersions.ToList(), + cpu, + memory, + environmentVariables); + } + + /// + /// The AgentTool. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , , , , , , , , , and . + /// + /// + /// A new instance for mocking. + public static AgentTool AgentTool(string @type = default) + { + return new UnknownTool(new ToolType(@type), additionalBinaryDataProperties: null); + } + + /// A tool that allows the model to execute shell commands in a local environment. + /// A new instance for mocking. + public static LocalShellAgentTool LocalShellAgentTool() + { + return new LocalShellAgentTool(ToolType.LocalShell, additionalBinaryDataProperties: null); + } + + /// The input definition information for a bing grounding search tool as used to configure an agent. + /// The bing grounding search tool parameters. + /// A new instance for mocking. + public static BingGroundingAgentTool BingGroundingAgentTool(BingGroundingSearchToolOptions bingGrounding = default) + { + return new BingGroundingAgentTool(ToolType.BingGrounding, additionalBinaryDataProperties: null, bingGrounding); + } + + /// The bing grounding search tool parameters. + /// + /// The search configurations attached to this tool. There can be a maximum of 1 + /// search configuration resource attached to the tool. + /// + /// A new instance for mocking. + public static BingGroundingSearchToolOptions BingGroundingSearchToolOptions(IEnumerable searchConfigurations = default) + { + searchConfigurations ??= new ChangeTrackingList(); + + return new BingGroundingSearchToolOptions(searchConfigurations.ToList(), additionalBinaryDataProperties: null); + } + + /// Search configuration for Bing Grounding. + /// Project connection id for grounding with bing search. + /// The market where the results come from. + /// The language to use for user interface strings when calling Bing API. + /// The number of search results to return in the bing api response. + /// Filter search results by a specific time range. See [accepted values here](https://learn.microsoft.com/bing/search-apis/bing-web-search/reference/query-parameters). + /// A new instance for mocking. + public static BingGroundingSearchConfiguration BingGroundingSearchConfiguration(string projectConnectionId = default, string market = default, string setLang = default, long? count = default, string freshness = default) + { + return new BingGroundingSearchConfiguration( + projectConnectionId, + market, + setLang, + count, + freshness, + additionalBinaryDataProperties: null); + } + + /// The input definition information for a Microsoft Fabric tool as used to configure an agent. + /// The fabric data agent tool parameters. + /// A new instance for mocking. + public static MicrosoftFabricAgentTool MicrosoftFabricAgentTool(FabricDataAgentToolOptions fabricDataagentPreview = default) + { + return new MicrosoftFabricAgentTool(ToolType.FabricDataagentPreview, additionalBinaryDataProperties: null, fabricDataagentPreview); + } + + /// The fabric data agent tool parameters. + /// + /// The project connections attached to this tool. There can be a maximum of 1 connection + /// resource attached to the tool. + /// + /// A new instance for mocking. + public static FabricDataAgentToolOptions FabricDataAgentToolOptions(IEnumerable projectConnections = default) + { + projectConnections ??= new ChangeTrackingList(); + + return new FabricDataAgentToolOptions(projectConnections.ToList(), additionalBinaryDataProperties: null); + } + + /// A project connection resource. + /// A project connection in a ToolProjectConnectionList attached to this tool. + /// A new instance for mocking. + public static ToolProjectConnection ToolProjectConnection(string projectConnectionId = default) + { + return new ToolProjectConnection(projectConnectionId, additionalBinaryDataProperties: null); + } + + /// The input definition information for a sharepoint tool as used to configure an agent. + /// The sharepoint grounding tool parameters. + /// A new instance for mocking. + public static SharepointAgentTool SharepointAgentTool(SharePointGroundingToolOptions sharepointGroundingPreview = default) + { + return new SharepointAgentTool(ToolType.SharepointGroundingPreview, additionalBinaryDataProperties: null, sharepointGroundingPreview); + } + + /// The sharepoint grounding tool parameters. + /// + /// The project connections attached to this tool. There can be a maximum of 1 connection + /// resource attached to the tool. + /// + /// A new instance for mocking. + public static SharePointGroundingToolOptions SharePointGroundingToolOptions(IEnumerable projectConnections = default) + { + projectConnections ??= new ChangeTrackingList(); + + return new SharePointGroundingToolOptions(projectConnections.ToList(), additionalBinaryDataProperties: null); + } + + /// The input definition information for an Azure AI search tool as used to configure an agent. + /// The azure ai search index resource. + /// A new instance for mocking. + public static AzureAISearchAgentTool AzureAISearchAgentTool(AzureAISearchToolOptions options = default) + { + return new AzureAISearchAgentTool(ToolType.AzureAiSearch, additionalBinaryDataProperties: null, options); + } + + /// A set of index resources used by the `azure_ai_search` tool. + /// + /// The indices attached to this agent. There can be a maximum of 1 index + /// resource attached to the agent. + /// + /// A new instance for mocking. + public static AzureAISearchToolOptions AzureAISearchToolOptions(IEnumerable indexes = default) + { + indexes ??= new ChangeTrackingList(); + + return new AzureAISearchToolOptions(indexes.ToList(), additionalBinaryDataProperties: null); + } + + /// A AI Search Index resource. + /// An index connection ID in an IndexResource attached to this agent. + /// The name of an index in an IndexResource attached to this agent. + /// Type of query in an AIIndexResource attached to this agent. + /// Number of documents to retrieve from search and present to the model. + /// filter string for search resource. [Learn more here](https://learn.microsoft.com/azure/search/search-filters). + /// Index asset id for search resource. + /// A new instance for mocking. + public static AzureAISearchToolIndex AzureAISearchToolIndex(string projectConnectionId = default, string indexName = default, AzureAISearchQueryType? queryType = default, int? topK = default, string filter = default, string indexAssetId = default) + { + return new AzureAISearchToolIndex( + projectConnectionId, + indexName, + queryType, + topK, + filter, + indexAssetId, + additionalBinaryDataProperties: null); + } + + /// The input definition information for an OpenAPI tool as used to configure an agent. + /// The openapi function definition. + /// A new instance for mocking. + public static OpenAPIAgentTool OpenAPIAgentTool(OpenAPIFunctionDefinition openapi = default) + { + return new OpenAPIAgentTool(ToolType.Openapi, additionalBinaryDataProperties: null, openapi); + } + + /// The input definition information for an openapi function. + /// The name of the function to be called. + /// A description of what the function does, used by the model to choose when and how to call the function. + /// The openapi function shape, described as a JSON Schema object. + /// Open API authentication details. + /// List of OpenAPI spec parameters that will use user-provided defaults. + /// List of function definitions used by OpenApi tool. + /// A new instance for mocking. + public static OpenAPIFunctionDefinition OpenAPIFunctionDefinition(string name = default, string description = default, BinaryData spec = default, OpenAPIAuthenticationDetails auth = default, IEnumerable defaultParams = default, IEnumerable functions = default) + { + defaultParams ??= new ChangeTrackingList(); + functions ??= new ChangeTrackingList(); + + return new OpenAPIFunctionDefinition( + name, + description, + spec, + auth, + defaultParams.ToList(), + functions.ToList(), + additionalBinaryDataProperties: null); + } + + /// + /// authentication details for OpenApiFunctionDefinition + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// + /// The type of authentication, must be anonymous/project_connection/managed_identity. + /// A new instance for mocking. + public static OpenAPIAuthenticationDetails OpenAPIAuthenticationDetails(string @type = default) + { + return new UnknownOpenAPIAuthenticationDetails(new OpenApiAuthType(@type), additionalBinaryDataProperties: null); + } + + /// Security details for OpenApi anonymous authentication. + /// A new instance for mocking. + public static OpenAPIAnonymousAuthenticationDetails OpenAPIAnonymousAuthenticationDetails() + { + return new OpenAPIAnonymousAuthenticationDetails(OpenApiAuthType.Anonymous, additionalBinaryDataProperties: null); + } + + /// Security details for OpenApi project connection authentication. + /// Project connection auth security details. + /// A new instance for mocking. + public static OpenAPIProjectConnectionAuthenticationDetails OpenAPIProjectConnectionAuthenticationDetails(OpenAPIProjectConnectionSecurityScheme securityScheme = default) + { + return new OpenAPIProjectConnectionAuthenticationDetails(OpenApiAuthType.ProjectConnection, additionalBinaryDataProperties: null, securityScheme); + } + + /// Security scheme for OpenApi managed_identity authentication. + /// Project connection id for Project Connection auth type. + /// A new instance for mocking. + public static OpenAPIProjectConnectionSecurityScheme OpenAPIProjectConnectionSecurityScheme(string projectConnectionId = default) + { + return new OpenAPIProjectConnectionSecurityScheme(projectConnectionId, additionalBinaryDataProperties: null); + } + + /// Security details for OpenApi managed_identity authentication. + /// Connection auth security details. + /// A new instance for mocking. + public static OpenAPIManagedAuthenticationDetails OpenAPIManagedAuthenticationDetails(OpenApiManagedSecurityScheme securityScheme = default) + { + return new OpenAPIManagedAuthenticationDetails(OpenApiAuthType.ManagedIdentity, additionalBinaryDataProperties: null, securityScheme); + } + + /// Security scheme for OpenApi managed_identity authentication. + /// Authentication scope for managed_identity auth type. + /// A new instance for mocking. + public static OpenApiManagedSecurityScheme OpenApiManagedSecurityScheme(string audience = default) + { + return new OpenApiManagedSecurityScheme(audience, additionalBinaryDataProperties: null); + } + + /// The OpenAPIFunctionEntry. + /// The name of the function to be called. + /// A description of what the function does, used by the model to choose when and how to call the function. + /// The parameters the functions accepts, described as a JSON Schema object. + /// A new instance for mocking. + public static OpenAPIFunctionEntry OpenAPIFunctionEntry(string name = default, string description = default, BinaryData parameters = default) + { + return new OpenAPIFunctionEntry(name, description, parameters, additionalBinaryDataProperties: null); + } + + /// The input definition information for a Bing custom search tool as used to configure an agent. + /// The bing custom search tool parameters. + /// A new instance for mocking. + public static BingCustomSearchAgentTool BingCustomSearchAgentTool(BingCustomSearchToolParameters bingCustomSearchPreview = default) + { + return new BingCustomSearchAgentTool(ToolType.BingCustomSearchPreview, additionalBinaryDataProperties: null, bingCustomSearchPreview); + } + + /// The bing custom search tool parameters. + /// + /// The project connections attached to this tool. There can be a maximum of 1 connection + /// resource attached to the tool. + /// + /// A new instance for mocking. + public static BingCustomSearchToolParameters BingCustomSearchToolParameters(IEnumerable searchConfigurations = default) + { + searchConfigurations ??= new ChangeTrackingList(); + + return new BingCustomSearchToolParameters(searchConfigurations.ToList(), additionalBinaryDataProperties: null); + } + + /// A bing custom search configuration. + /// Project connection id for grounding with bing search. + /// Name of the custom configuration instance given to config. + /// The market where the results come from. + /// The language to use for user interface strings when calling Bing API. + /// The number of search results to return in the bing api response. + /// Filter search results by a specific time range. See [accepted values here](https://learn.microsoft.com/bing/search-apis/bing-web-search/reference/query-parameters). + /// A new instance for mocking. + public static BingCustomSearchConfiguration BingCustomSearchConfiguration(string projectConnectionId = default, string instanceName = default, string market = default, string setLang = default, long? count = default, string freshness = default) + { + return new BingCustomSearchConfiguration( + projectConnectionId, + instanceName, + market, + setLang, + count, + freshness, + additionalBinaryDataProperties: null); + } + + /// The input definition information for a Browser Automation Tool, as used to configure an Agent. + /// The Browser Automation Tool parameters. + /// A new instance for mocking. + public static BrowserAutomationAgentTool BrowserAutomationAgentTool(BrowserAutomationToolParameters browserAutomationPreview = default) + { + return new BrowserAutomationAgentTool(ToolType.BrowserAutomationPreview, additionalBinaryDataProperties: null, browserAutomationPreview); + } + + /// Definition of input parameters for the Browser Automation Tool. + /// The project connection parameters associated with the Browser Automation Tool. + /// A new instance for mocking. + public static BrowserAutomationToolParameters BrowserAutomationToolParameters(BrowserAutomationToolConnectionParameters connection = default) + { + return new BrowserAutomationToolParameters(connection, additionalBinaryDataProperties: null); + } + + /// Definition of input parameters for the connection used by the Browser Automation Tool. + /// The ID of the project connection to your Azure Playwright resource. + /// A new instance for mocking. + public static BrowserAutomationToolConnectionParameters BrowserAutomationToolConnectionParameters(string projectConnectionId = default) + { + return new BrowserAutomationToolConnectionParameters(projectConnectionId, additionalBinaryDataProperties: null); + } + + /// The input definition information for an Azure Function Tool, as used to configure an Agent. + /// The Azure Function Tool definition. + /// A new instance for mocking. + public static AzureFunctionAgentTool AzureFunctionAgentTool(AzureFunctionDefinition azureFunction = default) + { + return new AzureFunctionAgentTool(ToolType.AzureFunction, additionalBinaryDataProperties: null, azureFunction); + } + + /// The definition of Azure function. + /// The definition of azure function and its parameters. + /// Input storage queue. The queue storage trigger runs a function as messages are added to it. + /// Output storage queue. The function writes output to this queue when the input items are processed. + /// A new instance for mocking. + public static AzureFunctionDefinition AzureFunctionDefinition(AzureFunctionDefinitionFunction function = default, AzureFunctionBinding inputBinding = default, AzureFunctionBinding outputBinding = default) + { + return new AzureFunctionDefinition(function, inputBinding, outputBinding, additionalBinaryDataProperties: null); + } + + /// The AzureFunctionDefinitionFunction. + /// The name of the function to be called. + /// A description of what the function does, used by the model to choose when and how to call the function. + /// The parameters the functions accepts, described as a JSON Schema object. + /// A new instance for mocking. + public static AzureFunctionDefinitionFunction AzureFunctionDefinitionFunction(string name = default, string description = default, BinaryData parameters = default) + { + return new AzureFunctionDefinitionFunction(name, description, parameters, additionalBinaryDataProperties: null); + } + + /// The structure for keeping storage queue name and URI. + /// Storage queue. + /// A new instance for mocking. + public static AzureFunctionBinding AzureFunctionBinding(AzureFunctionStorageQueue storageQueue = default) + { + return new AzureFunctionBinding("storage_queue", storageQueue, additionalBinaryDataProperties: null); + } + + /// The structure for keeping storage queue name and URI. + /// URI to the Azure Storage Queue service allowing you to manipulate a queue. + /// The name of an Azure function storage queue. + /// A new instance for mocking. + public static AzureFunctionStorageQueue AzureFunctionStorageQueue(string queueServiceEndpoint = default, string queueName = default) + { + return new AzureFunctionStorageQueue(queueServiceEndpoint, queueName, additionalBinaryDataProperties: null); + } + + /// A tool for capturing structured outputs. + /// The structured outputs to capture from the model. + /// A new instance for mocking. + public static CaptureStructuredOutputsTool CaptureStructuredOutputsTool(StructuredOutputDefinition outputs = default) + { + return new CaptureStructuredOutputsTool(ToolType.CaptureStructuredOutputs, additionalBinaryDataProperties: null, outputs); + } + + /// A structured output that can be produced by the agent. + /// The name of the structured output. + /// A description of the output to emit. Used by the model to determine when to emit the output. + /// The JSON schema for the structured output. + /// Whether to enforce strict validation. Default `true`. + /// A new instance for mocking. + public static StructuredOutputDefinition StructuredOutputDefinition(string name = default, string description = default, BinaryData schema = default, bool? strict = default) + { + return new StructuredOutputDefinition(name, description, schema, strict, additionalBinaryDataProperties: null); + } + + /// An agent implementing the A2A protocol. + /// Base URL of the agent. + /// + /// The path to the agent card relative to the `base_url`. + /// If not provided, defaults to `/.well-known/agent-card.json` + /// + /// + /// The connection ID in the project for the A2A server. + /// The connection stores authentication and other connection details needed to connect to the A2A server. + /// + /// A new instance for mocking. + public static A2ATool A2ATool(Uri baseUri = default, string agentCardPath = default, string projectConnectionId = default) + { + return new A2ATool(ToolType.A2aPreview, additionalBinaryDataProperties: null, baseUri, agentCardPath, projectConnectionId); + } + + /// A tool for integrating memories into the agent. + /// The name of the memory store to use. + /// + /// The namespace used to group and isolate memories, such as a user ID. + /// Limits which memories can be retrieved or updated. + /// Use special variable `{{$userId}}` to scope memories to the current signed-in user. + /// + /// Options for searching the memory store. + /// Time to wait before updating memories after inactivity (seconds). Default 300. + /// A new instance for mocking. + public static MemorySearchTool MemorySearchTool(string memoryStoreName = default, string scope = default, MemorySearchToolOptions searchOptions = default, int? updateDelay = default) + { + return new MemorySearchTool( + ToolType.MemorySearch, + additionalBinaryDataProperties: null, + memoryStoreName, + scope, + searchOptions, + updateDelay); + } + + /// Memory search options. + /// Maximum number of memory items to return. + /// A new instance for mocking. + public static MemorySearchToolOptions MemorySearchToolOptions(int? maxMemories = default) + { + return new MemorySearchToolOptions(maxMemories, additionalBinaryDataProperties: null); + } + + /// A record mapping for a single protocol and its version. + /// The protocol type. + /// The version string for the protocol, e.g. 'v0.1.1'. + /// A new instance for mocking. + public static ProtocolVersionRecord ProtocolVersionRecord(AgentCommunicationMethod protocol = default, string version = default) + { + return new ProtocolVersionRecord(protocol, version, additionalBinaryDataProperties: null); + } + + /// The image-based deployment definition for a hosted agent. + /// Configuration for Responsible AI (RAI) content filtering and safety features. + /// + /// An array of tools the hosted agent's model may call while generating a response. You + /// can specify which tool to use by setting the `tool_choice` parameter. + /// + /// The protocols that the agent supports for ingress communication of the containers. + /// The CPU configuration for the hosted agent. + /// The memory configuration for the hosted agent. + /// Environment variables to set in the hosted agent container. + /// The image for the hosted agent. + /// A new instance for mocking. + public static ImageBasedHostedAgentDefinition ImageBasedHostedAgentDefinition(ContentFilterConfiguration contentFilterConfiguration = default, IEnumerable tools = default, IEnumerable containerProtocolVersions = default, string cpu = default, string memory = default, IDictionary environmentVariables = default, string image = default) + { + tools ??= new ChangeTrackingList(); + containerProtocolVersions ??= new ChangeTrackingList(); + environmentVariables ??= new ChangeTrackingDictionary(); + + return new ImageBasedHostedAgentDefinition( + AgentKind.Hosted, + contentFilterConfiguration, + additionalBinaryDataProperties: null, + tools.ToList(), + containerProtocolVersions.ToList(), + cpu, + memory, + environmentVariables, + image); + } + + /// The container app agent definition. + /// Configuration for Responsible AI (RAI) content filtering and safety features. + /// The protocols that the agent supports for ingress communication of the containers. + /// The resource ID of the Azure Container App that hosts this agent. Not mutable across versions. + /// The suffix to apply to the app subdomain when sending ingress to the agent. This can be a label (e.g., '---current'), a specific revision (e.g., '--0000001'), or empty to use the default endpoint for the container app. + /// A new instance for mocking. + public static ContainerApplicationAgentDefinition ContainerApplicationAgentDefinition(ContentFilterConfiguration contentFilterConfiguration = default, IEnumerable containerProtocolVersions = default, string containerAppResourceId = default, string ingressSubdomainSuffix = default) + { + containerProtocolVersions ??= new ChangeTrackingList(); + + return new ContainerApplicationAgentDefinition( + AgentKind.ContainerApp, + contentFilterConfiguration, + additionalBinaryDataProperties: null, + containerProtocolVersions.ToList(), + containerAppResourceId, + ingressSubdomainSuffix); + } + + /// An structured input that can participate in prompt template substitutions and tool argument binding. + /// A human-readable description of the input. + /// The default value for the input if no run-time value is provided. + /// The JSON schema for the structured input (optional). + /// Whether the input property is required when the agent is invoked. + /// A new instance for mocking. + public static StructuredInputDefinition StructuredInputDefinition(string description = default, BinaryData defaultValue = default, BinaryData schema = default, bool? isRequired = default) + { + return new StructuredInputDefinition(description, defaultValue, schema, isRequired, additionalBinaryDataProperties: null); + } + + /// The AgentRecord. + /// The unique identifier of the agent. + /// The name of the agent. + /// The latest version of the agent. + /// A new instance for mocking. + public static AgentRecord AgentRecord(string id = default, string name = default, AgentObjectVersions versions = default) + { + return new AgentRecord("agent", id, name, versions, additionalBinaryDataProperties: null); + } + + /// The AgentObjectVersions. + /// + /// A new instance for mocking. + public static AgentObjectVersions AgentObjectVersions(AgentVersion latest = default) + { + return new AgentObjectVersions(latest, additionalBinaryDataProperties: null); + } + + /// The AgentVersion. + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + /// The unique identifier of the agent version. + /// The name of the agent. Name can be used to retrieve/update/delete the agent. + /// The version identifier of the agent. Agents are immutable and every update creates a new version while keeping the name same. + /// A human-readable description of the agent. + /// The Unix timestamp (seconds) when the agent was created. + /// + /// A new instance for mocking. + public static AgentVersion AgentVersion(IDictionary metadata = default, string id = default, string name = default, string version = default, string description = default, DateTimeOffset createdAt = default, AgentDefinition definition = default) + { + metadata ??= new ChangeTrackingDictionary(); + + return new AgentVersion( + metadata, + "agent.version", + id, + name, + version, + description, + createdAt, + definition, + additionalBinaryDataProperties: null); + } + + /// Execute a shell command on the server. + /// The command to run. + /// Optional timeout in milliseconds for the command. + /// Optional working directory to run the command in. + /// Environment variables to set for the command. + /// Optional user to run the command as. + /// A new instance for mocking. + public static LocalShellAgentToolExecutionAction LocalShellAgentToolExecutionAction(IEnumerable command = default, int? timeoutMs = default, string workingDirectory = default, IDictionary env = default, string user = default) + { + command ??= new ChangeTrackingList(); + env ??= new ChangeTrackingDictionary(); + + return new LocalShellAgentToolExecutionAction( + "exec", + command.ToList(), + timeoutMs, + workingDirectory, + env, + user, + additionalBinaryDataProperties: null); + } + + /// A retrieved memory item from memory search. + /// Retrieved memory item. + /// A new instance for mocking. + public static MemorySearchItem MemorySearchItem(MemoryItem memoryItem = default) + { + return new MemorySearchItem(memoryItem, additionalBinaryDataProperties: null); + } + + /// + /// A single memory item stored in the memory store, containing content and metadata. + /// Please note this is the abstract base class. The derived classes available for instantiation are: . + /// + /// The unique ID of the memory item. + /// The last update time of the memory item. + /// The namespace that logically groups and isolates memories, such as a user ID. + /// The content of the memory. + /// The kind of the memory item. + /// A new instance for mocking. + public static MemoryItem MemoryItem(string memoryId = default, DateTimeOffset updatedAt = default, string scope = default, string content = default, string kind = default) + { + return new UnknownMemoryItem( + memoryId, + updatedAt, + scope, + content, + new MemoryItemKind(kind), + additionalBinaryDataProperties: null); + } + + /// A memory item containing a summary extracted from conversations. + /// The unique ID of the memory item. + /// The last update time of the memory item. + /// The namespace that logically groups and isolates memories, such as a user ID. + /// The content of the memory. + /// A new instance for mocking. + public static ChatSummaryMemoryItem ChatSummaryMemoryItem(string memoryId = default, DateTimeOffset updatedAt = default, string scope = default, string content = default) + { + return new ChatSummaryMemoryItem( + memoryId, + updatedAt, + scope, + content, + MemoryItemKind.ChatSummary, + additionalBinaryDataProperties: null); + } + + /// + /// Content item used to generate a response. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , , , and . + /// + /// + /// + /// The information about the creator of the item. + /// A new instance for mocking. + public static AgentResponseItem AgentResponseItem(string @type = default, string id = default, AgentResponseItemSource createdBy = default) + { + return new UnknownItemResource(new AgentResponseItemKind(@type), id, createdBy, additionalBinaryDataProperties: null); + } + + /// The AgentResponseItemSource. + /// The agent that created the item. + /// The response on which the item is created. + /// A new instance for mocking. + public static AgentResponseItemSource AgentResponseItemSource(AgentInfo agent = default, string responseId = default) + { + return new AgentResponseItemSource(agent, responseId, additionalBinaryDataProperties: null); + } + + /// The AgentInfo. + /// The name of the agent. + /// The version identifier of the agent. + /// A new instance for mocking. + public static AgentInfo AgentInfo(string name = default, string version = default) + { + return new AgentInfo("agent_id", name, version, additionalBinaryDataProperties: null); + } + + /// The AgentStructuredOutputsResponseItem. + /// + /// The information about the creator of the item. + /// The structured output captured during the response. + /// A new instance for mocking. + public static AgentStructuredOutputsResponseItem AgentStructuredOutputsResponseItem(string id = default, AgentResponseItemSource createdBy = default, BinaryData output = default) + { + return new AgentStructuredOutputsResponseItem(AgentResponseItemKind.StructuredOutputs, id, createdBy, additionalBinaryDataProperties: null, output); + } + + /// The AgentWorkflowActionResponseItem. + /// + /// The information about the creator of the item. + /// The kind of CSDL action (e.g., 'SetVariable', 'InvokeAzureAgent'). + /// Unique identifier for the action. + /// ID of the parent action if this is a nested action. + /// ID of the previous action if this action follows another. + /// Status of the action (e.g., 'in_progress', 'completed', 'failed', 'cancelled'). + /// A new instance for mocking. + public static AgentWorkflowActionResponseItem AgentWorkflowActionResponseItem(string id = default, AgentResponseItemSource createdBy = default, string kind = default, string actionId = default, string parentActionId = default, string previousActionId = default, AgentWorkflowActionStatus? status = default) + { + return new AgentWorkflowActionResponseItem( + AgentResponseItemKind.WorkflowAction, + id, + createdBy, + additionalBinaryDataProperties: null, + kind, + actionId, + parentActionId, + previousActionId, + status); + } + + /// Request from the service for the user to perform OAuth consent. + /// The information about the creator of the item. + /// + /// The link the user can use to perform OAuth consent. + /// The server label for the OAuth consent request. + /// A new instance for mocking. + public static OAuthConsentRequestResponseItem OAuthConsentRequestResponseItem(AgentResponseItemSource createdBy = default, string id = default, string consentLink = default, string serverLabel = default) + { + return new OAuthConsentRequestResponseItem( + AgentResponseItemKind.OauthConsentRequest, + createdBy, + additionalBinaryDataProperties: null, + id, + consentLink, + serverLabel); + } + + /// + /// A tool call to run a command on the local shell. + /// + /// + /// + /// The information about the creator of the item. + /// + /// The unique ID of the local shell tool call generated by the model. + /// + /// A new instance for mocking. + public static LocalShellToolCallAgentResponseItem LocalShellToolCallAgentResponseItem(string id = default, AgentResponseItemSource createdBy = default, LocalShellAgentToolCallStatus status = default, string callId = default, LocalShellAgentToolExecutionAction action = default) + { + return new LocalShellToolCallAgentResponseItem( + AgentResponseItemKind.LocalShellCall, + id, + createdBy, + additionalBinaryDataProperties: null, + status, + callId, + action); + } + + /// + /// The output of a local shell tool call. + /// + /// + /// + /// The information about the creator of the item. + /// + /// A JSON string of the output of the local shell tool call. + /// A new instance for mocking. + public static LocalShellToolCallOutputAgentResponseItem LocalShellToolCallOutputAgentResponseItem(string id = default, AgentResponseItemSource createdBy = default, LocalShellAgentToolCallStatus status = default, string output = default) + { + return new LocalShellToolCallOutputAgentResponseItem( + AgentResponseItemKind.LocalShellCallOutput, + id, + createdBy, + additionalBinaryDataProperties: null, + status, + output); + } + + /// The MemorySearchToolCallResponseItem. + /// + /// The information about the creator of the item. + /// + /// The status of the memory search tool call. One of `in_progress`, + /// `searching`, `completed`, `incomplete` or `failed`, + /// + /// The results returned from the memory search. + /// A new instance for mocking. + public static MemorySearchToolCallResponseItem MemorySearchToolCallResponseItem(string id = default, AgentResponseItemSource createdBy = default, MemorySearchToolCallStatus status = default, IEnumerable results = default) + { + results ??= new ChangeTrackingList(); + + return new MemorySearchToolCallResponseItem( + AgentResponseItemKind.MemorySearchCall, + id, + createdBy, + additionalBinaryDataProperties: null, + status, + results.ToList()); + } + + /// The AgentReference. + /// The name of the agent. + /// The version identifier of the agent. + /// A new instance for mocking. + public static AgentReference AgentReference(string name = default, string version = default) + { + return new AgentReference("agent_reference", name, version, additionalBinaryDataProperties: null); + } + + /// The ProjectConversation. + /// The unique ID of the conversation. + /// + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + /// A new instance for mocking. + public static ProjectConversation ProjectConversation(string id = default, DateTimeOffset createdAt = default, IDictionary metadata = default) + { + metadata ??= new ChangeTrackingDictionary(); + + return new ProjectConversation(id, "conversation", createdAt, metadata, additionalBinaryDataProperties: null); + } + + /// Update a conversation. + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + /// A new instance for mocking. + public static ProjectConversationUpdateOptions ProjectConversationUpdateOptions(IDictionary metadata = default) + { + metadata ??= new ChangeTrackingDictionary(); + + return new ProjectConversationUpdateOptions(metadata, additionalBinaryDataProperties: null); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Prompt.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Prompt.Serialization.cs new file mode 100644 index 000000000000..1d2599443413 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Prompt.Serialization.cs @@ -0,0 +1,175 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + /// + /// Reference to a prompt template and its variables. + /// [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts). + /// + internal partial class Prompt : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal Prompt() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Prompt)} does not support writing '{format}' format."); + } + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + if (Optional.IsDefined(Version)) + { + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + } + if (Optional.IsDefined(Variables)) + { + writer.WritePropertyName("variables"u8); + writer.WriteObjectValue(Variables, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + Prompt IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual Prompt JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Prompt)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePrompt(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static Prompt DeserializePrompt(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string version = default; + ResponsePromptVariables variables = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("version"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + version = null; + continue; + } + version = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("variables"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + variables = null; + continue; + } + variables = ResponsePromptVariables.DeserializeResponsePromptVariables(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new Prompt(id, version, variables, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(Prompt)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + Prompt IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual Prompt PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializePrompt(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Prompt)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Prompt.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Prompt.cs new file mode 100644 index 000000000000..33b3ac1bbc2c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/Prompt.cs @@ -0,0 +1,48 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + /// + /// Reference to a prompt template and its variables. + /// [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts). + /// + internal partial class Prompt + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The unique identifier of the prompt template to use. + internal Prompt(string id) + { + Id = id; + } + + /// Initializes a new instance of . + /// The unique identifier of the prompt template to use. + /// Optional version of the prompt template. + /// + /// Keeps track of any properties unknown to the library. + internal Prompt(string id, string version, ResponsePromptVariables variables, IDictionary additionalBinaryDataProperties) + { + Id = id; + Version = version; + Variables = variables; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The unique identifier of the prompt template to use. + public string Id { get; } + + /// Optional version of the prompt template. + public string Version { get; } + + /// Gets the Variables. + public ResponsePromptVariables Variables { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/PromptAgentDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/PromptAgentDefinition.Serialization.cs new file mode 100644 index 000000000000..c1ee57e43ebf --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/PromptAgentDefinition.Serialization.cs @@ -0,0 +1,265 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// The prompt agent definition. + public partial class PromptAgentDefinition : AgentDefinition, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal PromptAgentDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PromptAgentDefinition)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model); + if (Optional.IsDefined(Instructions)) + { + writer.WritePropertyName("instructions"u8); + writer.WriteStringValue(Instructions); + } + if (Optional.IsDefined(Temperature)) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + if (Optional.IsDefined(TopP)) + { + writer.WritePropertyName("top_p"u8); + writer.WriteNumberValue(TopP.Value); + } + if (Optional.IsDefined(ReasoningOptions)) + { + writer.WritePropertyName("reasoning"u8); + writer.WriteObjectValue(ReasoningOptions, options); + } + if (Optional.IsCollectionDefined(Tools)) + { + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (global::OpenAI.Responses.ResponseTool item in Tools) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(TextOptions)) + { + writer.WritePropertyName("text"u8); + writer.WriteObjectValue(TextOptions, options); + } + if (Optional.IsCollectionDefined(StructuredInputs)) + { + writer.WritePropertyName("structured_inputs"u8); + writer.WriteStartObject(); + foreach (var item in StructuredInputs) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + PromptAgentDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (PromptAgentDefinition)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PromptAgentDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePromptAgentDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PromptAgentDefinition DeserializePromptAgentDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentKind kind = default; + ContentFilterConfiguration contentFilterConfiguration = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string model = default; + string instructions = default; + float? temperature = default; + float? topP = default; + global::OpenAI.Responses.ResponseReasoningOptions reasoningOptions = default; + IList tools = default; + global::OpenAI.Responses.ResponseTextOptions textOptions = default; + IDictionary structuredInputs = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("kind"u8)) + { + kind = new AgentKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("rai_config"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + contentFilterConfiguration = ContentFilterConfiguration.DeserializeContentFilterConfiguration(prop.Value, options); + continue; + } + if (prop.NameEquals("model"u8)) + { + model = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("instructions"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + instructions = null; + continue; + } + instructions = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("temperature"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + temperature = null; + continue; + } + temperature = prop.Value.GetSingle(); + continue; + } + if (prop.NameEquals("top_p"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + topP = null; + continue; + } + topP = prop.Value.GetSingle(); + continue; + } + if (prop.NameEquals("reasoning"u8)) + { + DeserializeReasoningValue(prop, ref reasoningOptions); + continue; + } + if (prop.NameEquals("tools"u8)) + { + DeserializeToolsValue(prop, ref tools); + continue; + } + if (prop.NameEquals("text"u8)) + { + DeserializeTextValue(prop, ref textOptions); + continue; + } + if (prop.NameEquals("structured_inputs"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + dictionary.Add(prop0.Name, StructuredInputDefinition.DeserializeStructuredInputDefinition(prop0.Value, options)); + } + structuredInputs = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PromptAgentDefinition( + kind, + contentFilterConfiguration, + additionalBinaryDataProperties, + model, + instructions, + temperature, + topP, + reasoningOptions, + tools ?? new ChangeTrackingList(), + textOptions, + structuredInputs ?? new ChangeTrackingDictionary()); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(PromptAgentDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + PromptAgentDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (PromptAgentDefinition)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializePromptAgentDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PromptAgentDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/PromptAgentDefinition.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/PromptAgentDefinition.cs new file mode 100644 index 000000000000..0cb400d672f4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/PromptAgentDefinition.cs @@ -0,0 +1,37 @@ +// + +#nullable disable + +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// The prompt agent definition. + public partial class PromptAgentDefinition : AgentDefinition + { + /// The model deployment to use for this agent. + public string Model { get; set; } + + /// A system (or developer) message inserted into the model's context. + public string Instructions { get; set; } + + /// + /// 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. + /// We generally recommend altering this or `top_p` but not both. + /// + public float? Temperature { get; set; } + + /// + /// 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. + /// + public float? TopP { get; set; } + + /// Set of structured inputs that can participate in prompt template substitution or tool argument bindings. + public IDictionary StructuredInputs { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProtocolVersionRecord.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProtocolVersionRecord.Serialization.cs new file mode 100644 index 000000000000..2da1f5fcf8af --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProtocolVersionRecord.Serialization.cs @@ -0,0 +1,147 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// A record mapping for a single protocol and its version. + public partial class ProtocolVersionRecord : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ProtocolVersionRecord() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProtocolVersionRecord)} does not support writing '{format}' format."); + } + writer.WritePropertyName("protocol"u8); + writer.WriteStringValue(Protocol.ToString()); + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ProtocolVersionRecord IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ProtocolVersionRecord JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProtocolVersionRecord)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProtocolVersionRecord(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ProtocolVersionRecord DeserializeProtocolVersionRecord(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentCommunicationMethod protocol = default; + string version = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("protocol"u8)) + { + protocol = new AgentCommunicationMethod(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("version"u8)) + { + version = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ProtocolVersionRecord(protocol, version, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(ProtocolVersionRecord)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ProtocolVersionRecord IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ProtocolVersionRecord PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeProtocolVersionRecord(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProtocolVersionRecord)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProtocolVersionRecord.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProtocolVersionRecord.cs new file mode 100644 index 000000000000..088419beaef2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ProtocolVersionRecord.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// A record mapping for a single protocol and its version. + public partial class ProtocolVersionRecord + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The protocol type. + /// The version string for the protocol, e.g. 'v0.1.1'. + /// is null. + public ProtocolVersionRecord(AgentCommunicationMethod protocol, string version) + { + Argument.AssertNotNull(version, nameof(version)); + + Protocol = protocol; + Version = version; + } + + /// Initializes a new instance of . + /// The protocol type. + /// The version string for the protocol, e.g. 'v0.1.1'. + /// Keeps track of any properties unknown to the library. + internal ProtocolVersionRecord(AgentCommunicationMethod protocol, string version, IDictionary additionalBinaryDataProperties) + { + Protocol = protocol; + Version = version; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The protocol type. + public AgentCommunicationMethod Protocol { get; set; } + + /// The version string for the protocol, e.g. 'v0.1.1'. + public string Version { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/RankingOptionsRanker.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/RankingOptionsRanker.cs new file mode 100644 index 000000000000..2cfc1cf7caa6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/RankingOptionsRanker.cs @@ -0,0 +1,65 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct RankingOptionsRanker : IEquatable + { + private readonly string _value; + private const string AutoValue = "auto"; + private const string Default20241115Value = "default-2024-11-15"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public RankingOptionsRanker(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Auto. + public static RankingOptionsRanker Auto { get; } = new RankingOptionsRanker(AutoValue); + + /// Gets the Default20241115. + public static RankingOptionsRanker Default20241115 { get; } = new RankingOptionsRanker(Default20241115Value); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(RankingOptionsRanker left, RankingOptionsRanker right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(RankingOptionsRanker left, RankingOptionsRanker right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator RankingOptionsRanker(string value) => new RankingOptionsRanker(value); + + /// Converts a string to a . + /// The value. + public static implicit operator RankingOptionsRanker?(string value) => value == null ? null : new RankingOptionsRanker(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RankingOptionsRanker other && Equals(other); + + /// + public bool Equals(RankingOptionsRanker other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ReasoningEffort.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ReasoningEffort.cs new file mode 100644 index 000000000000..41f60c12a515 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ReasoningEffort.cs @@ -0,0 +1,69 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct ReasoningEffort : IEquatable + { + private readonly string _value; + private const string LowValue = "low"; + private const string MediumValue = "medium"; + private const string HighValue = "high"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ReasoningEffort(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Low. + public static ReasoningEffort Low { get; } = new ReasoningEffort(LowValue); + + /// Gets the Medium. + public static ReasoningEffort Medium { get; } = new ReasoningEffort(MediumValue); + + /// Gets the High. + public static ReasoningEffort High { get; } = new ReasoningEffort(HighValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ReasoningEffort left, ReasoningEffort right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ReasoningEffort left, ReasoningEffort right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ReasoningEffort(string value) => new ReasoningEffort(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ReasoningEffort?(string value) => value == null ? null : new ReasoningEffort(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ReasoningEffort other && Equals(other); + + /// + public bool Equals(ReasoningEffort other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ReasoningGenerateSummary.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ReasoningGenerateSummary.cs new file mode 100644 index 000000000000..2057ec8c3de2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ReasoningGenerateSummary.cs @@ -0,0 +1,69 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct ReasoningGenerateSummary : IEquatable + { + private readonly string _value; + private const string AutoValue = "auto"; + private const string ConciseValue = "concise"; + private const string DetailedValue = "detailed"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ReasoningGenerateSummary(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Auto. + public static ReasoningGenerateSummary Auto { get; } = new ReasoningGenerateSummary(AutoValue); + + /// Gets the Concise. + public static ReasoningGenerateSummary Concise { get; } = new ReasoningGenerateSummary(ConciseValue); + + /// Gets the Detailed. + public static ReasoningGenerateSummary Detailed { get; } = new ReasoningGenerateSummary(DetailedValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ReasoningGenerateSummary left, ReasoningGenerateSummary right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ReasoningGenerateSummary left, ReasoningGenerateSummary right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ReasoningGenerateSummary(string value) => new ReasoningGenerateSummary(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ReasoningGenerateSummary?(string value) => value == null ? null : new ReasoningGenerateSummary(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ReasoningGenerateSummary other && Equals(other); + + /// + public bool Equals(ReasoningGenerateSummary other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ReasoningItemSummaryPartType.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ReasoningItemSummaryPartType.cs new file mode 100644 index 000000000000..3fecad30d302 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ReasoningItemSummaryPartType.cs @@ -0,0 +1,62 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + /// + internal readonly partial struct ReasoningItemSummaryPartType : IEquatable + { + private readonly string _value; + private const string SummaryTextValue = "summary_text"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ReasoningItemSummaryPartType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the SummaryText. + public static ReasoningItemSummaryPartType SummaryText { get; } = new ReasoningItemSummaryPartType(SummaryTextValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ReasoningItemSummaryPartType left, ReasoningItemSummaryPartType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ReasoningItemSummaryPartType left, ReasoningItemSummaryPartType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ReasoningItemSummaryPartType(string value) => new ReasoningItemSummaryPartType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ReasoningItemSummaryPartType?(string value) => value == null ? null : new ReasoningItemSummaryPartType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ReasoningItemSummaryPartType other && Equals(other); + + /// + public bool Equals(ReasoningItemSummaryPartType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ReasoningSummary.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ReasoningSummary.cs new file mode 100644 index 000000000000..03dfe6189ca9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ReasoningSummary.cs @@ -0,0 +1,69 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct ReasoningSummary : IEquatable + { + private readonly string _value; + private const string AutoValue = "auto"; + private const string ConciseValue = "concise"; + private const string DetailedValue = "detailed"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ReasoningSummary(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Auto. + public static ReasoningSummary Auto { get; } = new ReasoningSummary(AutoValue); + + /// Gets the Concise. + public static ReasoningSummary Concise { get; } = new ReasoningSummary(ConciseValue); + + /// Gets the Detailed. + public static ReasoningSummary Detailed { get; } = new ReasoningSummary(DetailedValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ReasoningSummary left, ReasoningSummary right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ReasoningSummary left, ReasoningSummary right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ReasoningSummary(string value) => new ReasoningSummary(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ReasoningSummary?(string value) => value == null ? null : new ReasoningSummary(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ReasoningSummary other && Equals(other); + + /// + public bool Equals(ReasoningSummary other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseConversation1.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseConversation1.Serialization.cs new file mode 100644 index 000000000000..a256c3b40228 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseConversation1.Serialization.cs @@ -0,0 +1,140 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + /// The ResponseConversation1. + internal partial class ResponseConversation1 : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ResponseConversation1() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResponseConversation1)} does not support writing '{format}' format."); + } + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ResponseConversation1 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResponseConversation1 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResponseConversation1)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResponseConversation1(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ResponseConversation1 DeserializeResponseConversation1(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ResponseConversation1(id, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(ResponseConversation1)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ResponseConversation1 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResponseConversation1 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeResponseConversation1(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResponseConversation1)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseConversation1.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseConversation1.cs new file mode 100644 index 000000000000..ad9b9f46fd08 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseConversation1.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + /// The ResponseConversation1. + internal partial class ResponseConversation1 + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + internal ResponseConversation1(string id) + { + Id = id; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal ResponseConversation1(string id, IDictionary additionalBinaryDataProperties) + { + Id = id; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Id. + public string Id { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseErrorCode.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseErrorCode.Serialization.cs new file mode 100644 index 000000000000..f89aab9de3d5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseErrorCode.Serialization.cs @@ -0,0 +1,113 @@ +// + +#nullable disable + +using System; + +namespace OpenAI +{ + internal static partial class ResponseErrorCodeExtensions + { + /// The value to serialize. + public static string ToSerialString(this ResponseErrorCode value) => value switch + { + ResponseErrorCode.ServerError => "server_error", + ResponseErrorCode.RateLimitExceeded => "rate_limit_exceeded", + ResponseErrorCode.InvalidPrompt => "invalid_prompt", + ResponseErrorCode.VectorStoreTimeout => "vector_store_timeout", + ResponseErrorCode.InvalidImage => "invalid_image", + ResponseErrorCode.InvalidImageFormat => "invalid_image_format", + ResponseErrorCode.InvalidBase64Image => "invalid_base64_image", + ResponseErrorCode.InvalidImageUrl => "invalid_image_url", + ResponseErrorCode.ImageTooLarge => "image_too_large", + ResponseErrorCode.ImageTooSmall => "image_too_small", + ResponseErrorCode.ImageParseError => "image_parse_error", + ResponseErrorCode.ImageContentPolicyViolation => "image_content_policy_violation", + ResponseErrorCode.InvalidImageMode => "invalid_image_mode", + ResponseErrorCode.ImageFileTooLarge => "image_file_too_large", + ResponseErrorCode.UnsupportedImageMediaType => "unsupported_image_media_type", + ResponseErrorCode.EmptyImageFile => "empty_image_file", + ResponseErrorCode.FailedToDownloadImage => "failed_to_download_image", + ResponseErrorCode.ImageFileNotFound => "image_file_not_found", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ResponseErrorCode value.") + }; + + /// The value to deserialize. + public static ResponseErrorCode ToResponseErrorCode(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "server_error")) + { + return ResponseErrorCode.ServerError; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "rate_limit_exceeded")) + { + return ResponseErrorCode.RateLimitExceeded; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "invalid_prompt")) + { + return ResponseErrorCode.InvalidPrompt; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "vector_store_timeout")) + { + return ResponseErrorCode.VectorStoreTimeout; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "invalid_image")) + { + return ResponseErrorCode.InvalidImage; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "invalid_image_format")) + { + return ResponseErrorCode.InvalidImageFormat; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "invalid_base64_image")) + { + return ResponseErrorCode.InvalidBase64Image; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "invalid_image_url")) + { + return ResponseErrorCode.InvalidImageUrl; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "image_too_large")) + { + return ResponseErrorCode.ImageTooLarge; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "image_too_small")) + { + return ResponseErrorCode.ImageTooSmall; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "image_parse_error")) + { + return ResponseErrorCode.ImageParseError; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "image_content_policy_violation")) + { + return ResponseErrorCode.ImageContentPolicyViolation; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "invalid_image_mode")) + { + return ResponseErrorCode.InvalidImageMode; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "image_file_too_large")) + { + return ResponseErrorCode.ImageFileTooLarge; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "unsupported_image_media_type")) + { + return ResponseErrorCode.UnsupportedImageMediaType; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "empty_image_file")) + { + return ResponseErrorCode.EmptyImageFile; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "failed_to_download_image")) + { + return ResponseErrorCode.FailedToDownloadImage; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "image_file_not_found")) + { + return ResponseErrorCode.ImageFileNotFound; + } + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ResponseErrorCode value."); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseErrorCode.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseErrorCode.cs new file mode 100644 index 000000000000..9fc09a99a32b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseErrorCode.cs @@ -0,0 +1,47 @@ +// + +#nullable disable + +namespace OpenAI +{ + /// The error code for the response. + internal enum ResponseErrorCode + { + /// ServerError. + ServerError, + /// RateLimitExceeded. + RateLimitExceeded, + /// InvalidPrompt. + InvalidPrompt, + /// VectorStoreTimeout. + VectorStoreTimeout, + /// InvalidImage. + InvalidImage, + /// InvalidImageFormat. + InvalidImageFormat, + /// InvalidBase64Image. + InvalidBase64Image, + /// InvalidImageUrl. + InvalidImageUrl, + /// ImageTooLarge. + ImageTooLarge, + /// ImageTooSmall. + ImageTooSmall, + /// ImageParseError. + ImageParseError, + /// ImageContentPolicyViolation. + ImageContentPolicyViolation, + /// InvalidImageMode. + InvalidImageMode, + /// ImageFileTooLarge. + ImageFileTooLarge, + /// UnsupportedImageMediaType. + UnsupportedImageMediaType, + /// EmptyImageFile. + EmptyImageFile, + /// FailedToDownloadImage. + FailedToDownloadImage, + /// ImageFileNotFound. + ImageFileNotFound + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseIncompleteDetails1.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseIncompleteDetails1.Serialization.cs new file mode 100644 index 000000000000..65941957d00c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseIncompleteDetails1.Serialization.cs @@ -0,0 +1,142 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + /// The ResponseIncompleteDetails1. + internal partial class ResponseIncompleteDetails1 : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResponseIncompleteDetails1)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Reason)) + { + writer.WritePropertyName("reason"u8); + writer.WriteStringValue(Reason.Value.ToSerialString()); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ResponseIncompleteDetails1 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResponseIncompleteDetails1 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResponseIncompleteDetails1)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResponseIncompleteDetails1(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ResponseIncompleteDetails1 DeserializeResponseIncompleteDetails1(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResponseIncompleteDetailsReason? reason = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("reason"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + reason = prop.Value.GetString().ToResponseIncompleteDetailsReason(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ResponseIncompleteDetails1(reason, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(ResponseIncompleteDetails1)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ResponseIncompleteDetails1 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResponseIncompleteDetails1 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeResponseIncompleteDetails1(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResponseIncompleteDetails1)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseIncompleteDetails1.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseIncompleteDetails1.cs new file mode 100644 index 000000000000..ab438d8ece3c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseIncompleteDetails1.cs @@ -0,0 +1,33 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + /// The ResponseIncompleteDetails1. + internal partial class ResponseIncompleteDetails1 + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal ResponseIncompleteDetails1() + { + } + + /// Initializes a new instance of . + /// The reason why the response is incomplete. + /// Keeps track of any properties unknown to the library. + internal ResponseIncompleteDetails1(ResponseIncompleteDetailsReason? reason, IDictionary additionalBinaryDataProperties) + { + Reason = reason; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The reason why the response is incomplete. + public ResponseIncompleteDetailsReason? Reason { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseIncompleteDetailsReason.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseIncompleteDetailsReason.Serialization.cs new file mode 100644 index 000000000000..6f0a1e2d30e2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseIncompleteDetailsReason.Serialization.cs @@ -0,0 +1,33 @@ +// + +#nullable disable + +using System; + +namespace OpenAI +{ + internal static partial class ResponseIncompleteDetailsReasonExtensions + { + /// The value to serialize. + public static string ToSerialString(this ResponseIncompleteDetailsReason value) => value switch + { + ResponseIncompleteDetailsReason.MaxOutputTokens => "max_output_tokens", + ResponseIncompleteDetailsReason.ContentFilter => "content_filter", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ResponseIncompleteDetailsReason value.") + }; + + /// The value to deserialize. + public static ResponseIncompleteDetailsReason ToResponseIncompleteDetailsReason(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "max_output_tokens")) + { + return ResponseIncompleteDetailsReason.MaxOutputTokens; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "content_filter")) + { + return ResponseIncompleteDetailsReason.ContentFilter; + } + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ResponseIncompleteDetailsReason value."); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseIncompleteDetailsReason.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseIncompleteDetailsReason.cs new file mode 100644 index 000000000000..a5e6056e73de --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseIncompleteDetailsReason.cs @@ -0,0 +1,15 @@ +// + +#nullable disable + +namespace OpenAI +{ + /// + internal enum ResponseIncompleteDetailsReason + { + /// MaxOutputTokens. + MaxOutputTokens, + /// ContentFilter. + ContentFilter + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponsePromptVariables.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponsePromptVariables.Serialization.cs new file mode 100644 index 000000000000..ad8a3ad96400 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponsePromptVariables.Serialization.cs @@ -0,0 +1,125 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.ObjectModel; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + /// + /// Optional map of values to substitute in for variables in your + /// prompt. The substitution values can either be strings, or other + /// Response input types like images or files. + /// + internal partial class ResponsePromptVariables : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResponsePromptVariables)} does not support writing '{format}' format."); + } + foreach (var item in AdditionalProperties) + { + 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 + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ResponsePromptVariables IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResponsePromptVariables JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResponsePromptVariables)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResponsePromptVariables(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ResponsePromptVariables DeserializeResponsePromptVariables(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ChangeTrackingDictionary additionalProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + additionalProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + return new ResponsePromptVariables(new ReadOnlyDictionary(additionalProperties)); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(ResponsePromptVariables)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ResponsePromptVariables IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResponsePromptVariables PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeResponsePromptVariables(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResponsePromptVariables)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponsePromptVariables.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponsePromptVariables.cs new file mode 100644 index 000000000000..22b032ea8405 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponsePromptVariables.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + /// + /// Optional map of values to substitute in for variables in your + /// prompt. The substitution values can either be strings, or other + /// Response input types like images or files. + /// + internal partial class ResponsePromptVariables + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal ResponsePromptVariables() + { + _additionalBinaryDataProperties = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// + internal ResponsePromptVariables(IReadOnlyDictionary additionalProperties) + { + _additionalBinaryDataProperties = new ChangeTrackingDictionary(additionalProperties); + } + + /// Gets the AdditionalProperties. + public IReadOnlyDictionary AdditionalProperties => new ReadOnlyDictionary(_additionalBinaryDataProperties); + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseText.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseText.Serialization.cs new file mode 100644 index 000000000000..068877b78322 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseText.Serialization.cs @@ -0,0 +1,142 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + /// The ResponseText. + internal partial class ResponseText : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResponseText)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Format)) + { + writer.WritePropertyName("format"u8); + writer.WriteObjectValue(Format, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ResponseText IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResponseText JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResponseText)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResponseText(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ResponseText DeserializeResponseText(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalResponseTextFormatConfiguration format = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("format"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + format = InternalResponseTextFormatConfiguration.DeserializeInternalResponseTextFormatConfiguration(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ResponseText(format, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(ResponseText)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ResponseText IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResponseText PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeResponseText(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResponseText)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseText.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseText.cs new file mode 100644 index 000000000000..5d68dfbddaca --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseText.cs @@ -0,0 +1,33 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + /// The ResponseText. + internal partial class ResponseText + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal ResponseText() + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal ResponseText(InternalResponseTextFormatConfiguration format, IDictionary additionalBinaryDataProperties) + { + Format = format; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Format. + public InternalResponseTextFormatConfiguration Format { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseTextFormatConfigurationType.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseTextFormatConfigurationType.cs new file mode 100644 index 000000000000..48ea6bf5ba8f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseTextFormatConfigurationType.cs @@ -0,0 +1,84 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + /// + /// An object specifying the format that the model must output. + /// + /// Configuring `{ "type": "json_schema" }` enables Structured Outputs, + /// which ensures the model will match your supplied JSON schema. Learn more in the + /// [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + /// + /// The default format is `{ "type": "text" }` with no additional options. + /// + /// **Not recommended for gpt-4o and newer models:** + /// + /// Setting to `{ "type": "json_object" }` enables the older JSON mode, which + /// ensures the message the model generates is valid JSON. Using `json_schema` + /// is preferred for models that support it. + /// + internal readonly partial struct ResponseTextFormatConfigurationType : IEquatable + { + private readonly string _value; + private const string TextValue = "text"; + private const string JsonSchemaValue = "json_schema"; + private const string JsonObjectValue = "json_object"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ResponseTextFormatConfigurationType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Text. + public static ResponseTextFormatConfigurationType Text { get; } = new ResponseTextFormatConfigurationType(TextValue); + + /// Gets the JsonSchema. + public static ResponseTextFormatConfigurationType JsonSchema { get; } = new ResponseTextFormatConfigurationType(JsonSchemaValue); + + /// Gets the JsonObject. + public static ResponseTextFormatConfigurationType JsonObject { get; } = new ResponseTextFormatConfigurationType(JsonObjectValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ResponseTextFormatConfigurationType left, ResponseTextFormatConfigurationType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ResponseTextFormatConfigurationType left, ResponseTextFormatConfigurationType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ResponseTextFormatConfigurationType(string value) => new ResponseTextFormatConfigurationType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ResponseTextFormatConfigurationType?(string value) => value == null ? null : new ResponseTextFormatConfigurationType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ResponseTextFormatConfigurationType other && Equals(other); + + /// + public bool Equals(ResponseTextFormatConfigurationType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseTruncation.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseTruncation.Serialization.cs new file mode 100644 index 000000000000..6830e8eaeabf --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseTruncation.Serialization.cs @@ -0,0 +1,33 @@ +// + +#nullable disable + +using System; + +namespace OpenAI +{ + internal static partial class ResponseTruncationExtensions + { + /// The value to serialize. + public static string ToSerialString(this ResponseTruncation value) => value switch + { + ResponseTruncation.Auto => "auto", + ResponseTruncation.Disabled => "disabled", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ResponseTruncation value.") + }; + + /// The value to deserialize. + public static ResponseTruncation ToResponseTruncation(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "auto")) + { + return ResponseTruncation.Auto; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "disabled")) + { + return ResponseTruncation.Disabled; + } + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ResponseTruncation value."); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseTruncation.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseTruncation.cs new file mode 100644 index 000000000000..f17fcea1d95e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseTruncation.cs @@ -0,0 +1,15 @@ +// + +#nullable disable + +namespace OpenAI +{ + /// + internal enum ResponseTruncation + { + /// Auto. + Auto, + /// Disabled. + Disabled + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseUsage.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseUsage.Serialization.cs new file mode 100644 index 000000000000..a4de8cfb6922 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseUsage.Serialization.cs @@ -0,0 +1,181 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + /// + /// Represents token usage details including input tokens, output tokens, + /// a breakdown of output tokens, and the total tokens used. + /// + internal partial class ResponseUsage : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ResponseUsage() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResponseUsage)} does not support writing '{format}' format."); + } + writer.WritePropertyName("input_tokens"u8); + writer.WriteNumberValue(InputTokens); + writer.WritePropertyName("input_tokens_details"u8); + writer.WriteObjectValue(InputTokensDetails, options); + writer.WritePropertyName("output_tokens"u8); + writer.WriteNumberValue(OutputTokens); + writer.WritePropertyName("output_tokens_details"u8); + writer.WriteObjectValue(OutputTokensDetails, options); + writer.WritePropertyName("total_tokens"u8); + writer.WriteNumberValue(TotalTokens); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ResponseUsage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResponseUsage JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResponseUsage)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResponseUsage(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ResponseUsage DeserializeResponseUsage(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int inputTokens = default; + ResponseUsageInputTokensDetails inputTokensDetails = default; + int outputTokens = default; + ResponseUsageOutputTokensDetails outputTokensDetails = default; + int totalTokens = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("input_tokens"u8)) + { + inputTokens = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("input_tokens_details"u8)) + { + inputTokensDetails = ResponseUsageInputTokensDetails.DeserializeResponseUsageInputTokensDetails(prop.Value, options); + continue; + } + if (prop.NameEquals("output_tokens"u8)) + { + outputTokens = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("output_tokens_details"u8)) + { + outputTokensDetails = ResponseUsageOutputTokensDetails.DeserializeResponseUsageOutputTokensDetails(prop.Value, options); + continue; + } + if (prop.NameEquals("total_tokens"u8)) + { + totalTokens = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ResponseUsage( + inputTokens, + inputTokensDetails, + outputTokens, + outputTokensDetails, + totalTokens, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(ResponseUsage)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ResponseUsage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResponseUsage PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeResponseUsage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResponseUsage)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseUsage.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseUsage.cs new file mode 100644 index 000000000000..0e20f783e807 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseUsage.cs @@ -0,0 +1,66 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + /// + /// Represents token usage details including input tokens, output tokens, + /// a breakdown of output tokens, and the total tokens used. + /// + internal partial class ResponseUsage + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The number of input tokens. + /// A detailed breakdown of the input tokens. + /// The number of output tokens. + /// A detailed breakdown of the output tokens. + /// The total number of tokens used. + internal ResponseUsage(int inputTokens, ResponseUsageInputTokensDetails inputTokensDetails, int outputTokens, ResponseUsageOutputTokensDetails outputTokensDetails, int totalTokens) + { + InputTokens = inputTokens; + InputTokensDetails = inputTokensDetails; + OutputTokens = outputTokens; + OutputTokensDetails = outputTokensDetails; + TotalTokens = totalTokens; + } + + /// Initializes a new instance of . + /// The number of input tokens. + /// A detailed breakdown of the input tokens. + /// The number of output tokens. + /// A detailed breakdown of the output tokens. + /// The total number of tokens used. + /// Keeps track of any properties unknown to the library. + internal ResponseUsage(int inputTokens, ResponseUsageInputTokensDetails inputTokensDetails, int outputTokens, ResponseUsageOutputTokensDetails outputTokensDetails, int totalTokens, IDictionary additionalBinaryDataProperties) + { + InputTokens = inputTokens; + InputTokensDetails = inputTokensDetails; + OutputTokens = outputTokens; + OutputTokensDetails = outputTokensDetails; + TotalTokens = totalTokens; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The number of input tokens. + public int InputTokens { get; } + + /// A detailed breakdown of the input tokens. + public ResponseUsageInputTokensDetails InputTokensDetails { get; } + + /// The number of output tokens. + public int OutputTokens { get; } + + /// A detailed breakdown of the output tokens. + public ResponseUsageOutputTokensDetails OutputTokensDetails { get; } + + /// The total number of tokens used. + public int TotalTokens { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseUsageInputTokensDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseUsageInputTokensDetails.Serialization.cs new file mode 100644 index 000000000000..2ac386795705 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseUsageInputTokensDetails.Serialization.cs @@ -0,0 +1,140 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + /// The ResponseUsageInputTokensDetails. + internal partial class ResponseUsageInputTokensDetails : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ResponseUsageInputTokensDetails() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResponseUsageInputTokensDetails)} does not support writing '{format}' format."); + } + writer.WritePropertyName("cached_tokens"u8); + writer.WriteNumberValue(CachedTokens); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ResponseUsageInputTokensDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResponseUsageInputTokensDetails JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResponseUsageInputTokensDetails)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResponseUsageInputTokensDetails(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ResponseUsageInputTokensDetails DeserializeResponseUsageInputTokensDetails(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int cachedTokens = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("cached_tokens"u8)) + { + cachedTokens = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ResponseUsageInputTokensDetails(cachedTokens, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(ResponseUsageInputTokensDetails)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ResponseUsageInputTokensDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResponseUsageInputTokensDetails PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeResponseUsageInputTokensDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResponseUsageInputTokensDetails)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseUsageInputTokensDetails.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseUsageInputTokensDetails.cs new file mode 100644 index 000000000000..b3560d4d2228 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseUsageInputTokensDetails.cs @@ -0,0 +1,44 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + /// The ResponseUsageInputTokensDetails. + internal partial class ResponseUsageInputTokensDetails + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// The number of tokens that were retrieved from the cache. + /// [More on prompt caching](https://platform.openai.com/docs/guides/prompt-caching). + /// + internal ResponseUsageInputTokensDetails(int cachedTokens) + { + CachedTokens = cachedTokens; + } + + /// Initializes a new instance of . + /// + /// The number of tokens that were retrieved from the cache. + /// [More on prompt caching](https://platform.openai.com/docs/guides/prompt-caching). + /// + /// Keeps track of any properties unknown to the library. + internal ResponseUsageInputTokensDetails(int cachedTokens, IDictionary additionalBinaryDataProperties) + { + CachedTokens = cachedTokens; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// The number of tokens that were retrieved from the cache. + /// [More on prompt caching](https://platform.openai.com/docs/guides/prompt-caching). + /// + public int CachedTokens { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseUsageOutputTokensDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseUsageOutputTokensDetails.Serialization.cs new file mode 100644 index 000000000000..b721370f8745 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseUsageOutputTokensDetails.Serialization.cs @@ -0,0 +1,140 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + /// The ResponseUsageOutputTokensDetails. + internal partial class ResponseUsageOutputTokensDetails : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ResponseUsageOutputTokensDetails() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResponseUsageOutputTokensDetails)} does not support writing '{format}' format."); + } + writer.WritePropertyName("reasoning_tokens"u8); + writer.WriteNumberValue(ReasoningTokens); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ResponseUsageOutputTokensDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResponseUsageOutputTokensDetails JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResponseUsageOutputTokensDetails)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResponseUsageOutputTokensDetails(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ResponseUsageOutputTokensDetails DeserializeResponseUsageOutputTokensDetails(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int reasoningTokens = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("reasoning_tokens"u8)) + { + reasoningTokens = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ResponseUsageOutputTokensDetails(reasoningTokens, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(ResponseUsageOutputTokensDetails)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ResponseUsageOutputTokensDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResponseUsageOutputTokensDetails PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeResponseUsageOutputTokensDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResponseUsageOutputTokensDetails)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseUsageOutputTokensDetails.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseUsageOutputTokensDetails.cs new file mode 100644 index 000000000000..2088aaa447a3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponseUsageOutputTokensDetails.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + /// The ResponseUsageOutputTokensDetails. + internal partial class ResponseUsageOutputTokensDetails + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The number of reasoning tokens. + internal ResponseUsageOutputTokensDetails(int reasoningTokens) + { + ReasoningTokens = reasoningTokens; + } + + /// Initializes a new instance of . + /// The number of reasoning tokens. + /// Keeps track of any properties unknown to the library. + internal ResponseUsageOutputTokensDetails(int reasoningTokens, IDictionary additionalBinaryDataProperties) + { + ReasoningTokens = reasoningTokens; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The number of reasoning tokens. + public int ReasoningTokens { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponsesMessageItemResourceStatus.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponsesMessageItemResourceStatus.cs new file mode 100644 index 000000000000..007797e7d884 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponsesMessageItemResourceStatus.cs @@ -0,0 +1,69 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct ResponsesMessageItemResourceStatus : IEquatable + { + private readonly string _value; + private const string InProgressValue = "in_progress"; + private const string CompletedValue = "completed"; + private const string IncompleteValue = "incomplete"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ResponsesMessageItemResourceStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the InProgress. + public static ResponsesMessageItemResourceStatus InProgress { get; } = new ResponsesMessageItemResourceStatus(InProgressValue); + + /// Gets the Completed. + public static ResponsesMessageItemResourceStatus Completed { get; } = new ResponsesMessageItemResourceStatus(CompletedValue); + + /// Gets the Incomplete. + public static ResponsesMessageItemResourceStatus Incomplete { get; } = new ResponsesMessageItemResourceStatus(IncompleteValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ResponsesMessageItemResourceStatus left, ResponsesMessageItemResourceStatus right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ResponsesMessageItemResourceStatus left, ResponsesMessageItemResourceStatus right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ResponsesMessageItemResourceStatus(string value) => new ResponsesMessageItemResourceStatus(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ResponsesMessageItemResourceStatus?(string value) => value == null ? null : new ResponsesMessageItemResourceStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ResponsesMessageItemResourceStatus other && Equals(other); + + /// + public bool Equals(ResponsesMessageItemResourceStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponsesMessageRole.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponsesMessageRole.cs new file mode 100644 index 000000000000..309185fc41a8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ResponsesMessageRole.cs @@ -0,0 +1,73 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct ResponsesMessageRole : IEquatable + { + private readonly string _value; + private const string SystemValue = "system"; + private const string DeveloperValue = "developer"; + private const string UserValue = "user"; + private const string AssistantValue = "assistant"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ResponsesMessageRole(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the System. + public static ResponsesMessageRole System { get; } = new ResponsesMessageRole(SystemValue); + + /// Gets the Developer. + public static ResponsesMessageRole Developer { get; } = new ResponsesMessageRole(DeveloperValue); + + /// Gets the User. + public static ResponsesMessageRole User { get; } = new ResponsesMessageRole(UserValue); + + /// Gets the Assistant. + public static ResponsesMessageRole Assistant { get; } = new ResponsesMessageRole(AssistantValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ResponsesMessageRole left, ResponsesMessageRole right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ResponsesMessageRole left, ResponsesMessageRole right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ResponsesMessageRole(string value) => new ResponsesMessageRole(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ResponsesMessageRole?(string value) => value == null ? null : new ResponsesMessageRole(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ResponsesMessageRole other && Equals(other); + + /// + public bool Equals(ResponsesMessageRole other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ServiceTier.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ServiceTier.Serialization.cs new file mode 100644 index 000000000000..d76145e75667 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ServiceTier.Serialization.cs @@ -0,0 +1,48 @@ +// + +#nullable disable + +using System; + +namespace OpenAI +{ + internal static partial class ServiceTierExtensions + { + /// The value to serialize. + public static string ToSerialString(this ServiceTier value) => value switch + { + ServiceTier.Auto => "auto", + ServiceTier.Default => "default", + ServiceTier.Flex => "flex", + ServiceTier.Scale => "scale", + ServiceTier.Priority => "priority", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ServiceTier value.") + }; + + /// The value to deserialize. + public static ServiceTier ToServiceTier(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "auto")) + { + return ServiceTier.Auto; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "default")) + { + return ServiceTier.Default; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "flex")) + { + return ServiceTier.Flex; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "scale")) + { + return ServiceTier.Scale; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "priority")) + { + return ServiceTier.Priority; + } + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ServiceTier value."); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ServiceTier.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ServiceTier.cs new file mode 100644 index 000000000000..8ef6d4f097b9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ServiceTier.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +namespace OpenAI +{ + /// + /// Specifies the processing type used for serving the request. + /// * If set to 'auto', then the request will be processed with the service tier + /// configured in the Project settings. Unless otherwise configured, the Project will use 'default'. + /// * If set to 'default', then the request will be processed with the standard + /// pricing and performance for the selected model. + /// * If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' + /// or 'priority', then the request will be processed with the corresponding service + /// tier. [Contact sales](https://openai.com/contact-sales) to learn more about Priority processing. + /// * When not set, the default behavior is 'auto'. + /// + /// When the `service_tier` parameter is set, the response body will include the `service_tier` + /// value based on the processing mode actually used to serve the request. This response value + /// may be different from the value set in the parameter. + /// + internal enum ServiceTier + { + /// Auto. + Auto, + /// Default. + Default, + /// Flex. + Flex, + /// Scale. + Scale, + /// Priority. + Priority + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/SharePointGroundingToolOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/SharePointGroundingToolOptions.Serialization.cs new file mode 100644 index 000000000000..e2febde6c983 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/SharePointGroundingToolOptions.Serialization.cs @@ -0,0 +1,151 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The sharepoint grounding tool parameters. + public partial class SharePointGroundingToolOptions : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SharePointGroundingToolOptions)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(ProjectConnections)) + { + writer.WritePropertyName("project_connections"u8); + writer.WriteStartArray(); + foreach (ToolProjectConnection item in ProjectConnections) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + SharePointGroundingToolOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SharePointGroundingToolOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SharePointGroundingToolOptions)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSharePointGroundingToolOptions(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SharePointGroundingToolOptions DeserializeSharePointGroundingToolOptions(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList projectConnections = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("project_connections"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ToolProjectConnection.DeserializeToolProjectConnection(item, options)); + } + projectConnections = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SharePointGroundingToolOptions(projectConnections ?? new ChangeTrackingList(), additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(SharePointGroundingToolOptions)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + SharePointGroundingToolOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SharePointGroundingToolOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeSharePointGroundingToolOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SharePointGroundingToolOptions)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/SharePointGroundingToolOptions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/SharePointGroundingToolOptions.cs new file mode 100644 index 000000000000..ab11f4e47f33 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/SharePointGroundingToolOptions.cs @@ -0,0 +1,40 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// The sharepoint grounding tool parameters. + public partial class SharePointGroundingToolOptions + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public SharePointGroundingToolOptions() + { + ProjectConnections = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// The project connections attached to this tool. There can be a maximum of 1 connection + /// resource attached to the tool. + /// + /// Keeps track of any properties unknown to the library. + internal SharePointGroundingToolOptions(IList projectConnections, IDictionary additionalBinaryDataProperties) + { + ProjectConnections = projectConnections; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// The project connections attached to this tool. There can be a maximum of 1 connection + /// resource attached to the tool. + /// + public IList ProjectConnections { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/SharepointAgentTool.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/SharepointAgentTool.Serialization.cs new file mode 100644 index 000000000000..e463cc25ec7f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/SharepointAgentTool.Serialization.cs @@ -0,0 +1,132 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// The input definition information for a sharepoint tool as used to configure an agent. + public partial class SharepointAgentTool : AgentTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal SharepointAgentTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SharepointAgentTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("sharepoint_grounding_preview"u8); + writer.WriteObjectValue(SharepointGroundingPreview, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + SharepointAgentTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (SharepointAgentTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SharepointAgentTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSharepointAgentTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SharepointAgentTool DeserializeSharepointAgentTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + SharePointGroundingToolOptions sharepointGroundingPreview = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("sharepoint_grounding_preview"u8)) + { + sharepointGroundingPreview = SharePointGroundingToolOptions.DeserializeSharePointGroundingToolOptions(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SharepointAgentTool(@type, additionalBinaryDataProperties, sharepointGroundingPreview); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(SharepointAgentTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + SharepointAgentTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (SharepointAgentTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeSharepointAgentTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SharepointAgentTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/SharepointAgentTool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/SharepointAgentTool.cs new file mode 100644 index 000000000000..5bd53eccd596 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/SharepointAgentTool.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects.OpenAI +{ + /// The input definition information for a sharepoint tool as used to configure an agent. + public partial class SharepointAgentTool : AgentTool + { + /// Initializes a new instance of . + /// The sharepoint grounding tool parameters. + /// is null. + public SharepointAgentTool(SharePointGroundingToolOptions sharepointGroundingPreview) : base(ToolType.SharepointGroundingPreview) + { + Argument.AssertNotNull(sharepointGroundingPreview, nameof(sharepointGroundingPreview)); + + SharepointGroundingPreview = sharepointGroundingPreview; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The sharepoint grounding tool parameters. + internal SharepointAgentTool(ToolType @type, IDictionary additionalBinaryDataProperties, SharePointGroundingToolOptions sharepointGroundingPreview) : base(@type, additionalBinaryDataProperties) + { + SharepointGroundingPreview = sharepointGroundingPreview; + } + + /// The sharepoint grounding tool parameters. + public SharePointGroundingToolOptions SharepointGroundingPreview { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/StructuredInputDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/StructuredInputDefinition.Serialization.cs new file mode 100644 index 000000000000..7ed3a632d373 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/StructuredInputDefinition.Serialization.cs @@ -0,0 +1,196 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// An structured input that can participate in prompt template substitutions and tool argument binding. + public partial class StructuredInputDefinition : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StructuredInputDefinition)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(DefaultValue)) + { + writer.WritePropertyName("default_value"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(DefaultValue); +#else + using (JsonDocument document = JsonDocument.Parse(DefaultValue)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (Optional.IsDefined(Schema)) + { + writer.WritePropertyName("schema"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Schema); +#else + using (JsonDocument document = JsonDocument.Parse(Schema)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (Optional.IsDefined(IsRequired)) + { + writer.WritePropertyName("required"u8); + writer.WriteBooleanValue(IsRequired.Value); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + StructuredInputDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual StructuredInputDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StructuredInputDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStructuredInputDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static StructuredInputDefinition DeserializeStructuredInputDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string description = default; + BinaryData defaultValue = default; + BinaryData schema = default; + bool? isRequired = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("default_value"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + defaultValue = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("schema"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + schema = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("required"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isRequired = prop.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new StructuredInputDefinition(description, defaultValue, schema, isRequired, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(StructuredInputDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + StructuredInputDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual StructuredInputDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeStructuredInputDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StructuredInputDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/StructuredInputDefinition.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/StructuredInputDefinition.cs new file mode 100644 index 000000000000..6de618bf8b4e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/StructuredInputDefinition.cs @@ -0,0 +1,96 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// An structured input that can participate in prompt template substitutions and tool argument binding. + public partial class StructuredInputDefinition + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public StructuredInputDefinition() + { + } + + /// Initializes a new instance of . + /// A human-readable description of the input. + /// The default value for the input if no run-time value is provided. + /// The JSON schema for the structured input (optional). + /// Whether the input property is required when the agent is invoked. + /// Keeps track of any properties unknown to the library. + internal StructuredInputDefinition(string description, BinaryData defaultValue, BinaryData schema, bool? isRequired, IDictionary additionalBinaryDataProperties) + { + Description = description; + DefaultValue = defaultValue; + Schema = schema; + IsRequired = isRequired; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// A human-readable description of the input. + public string Description { get; set; } + + /// + /// The default value for the input if no run-time value is provided. + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData DefaultValue { get; set; } + + /// + /// The JSON schema for the structured input (optional). + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData Schema { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/StructuredOutputDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/StructuredOutputDefinition.Serialization.cs new file mode 100644 index 000000000000..c2b660d24c0f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/StructuredOutputDefinition.Serialization.cs @@ -0,0 +1,182 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// A structured output that can be produced by the agent. + public partial class StructuredOutputDefinition : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal StructuredOutputDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StructuredOutputDefinition)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + writer.WritePropertyName("schema"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Schema); +#else + using (JsonDocument document = JsonDocument.Parse(Schema)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + if (Optional.IsDefined(Strict)) + { + writer.WritePropertyName("strict"u8); + writer.WriteBooleanValue(Strict.Value); + } + else + { + writer.WriteNull("strict"u8); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + StructuredOutputDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual StructuredOutputDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StructuredOutputDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStructuredOutputDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static StructuredOutputDefinition DeserializeStructuredOutputDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string description = default; + BinaryData schema = default; + bool? strict = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("schema"u8)) + { + schema = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("strict"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + strict = null; + continue; + } + strict = prop.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new StructuredOutputDefinition(name, description, schema, strict, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(StructuredOutputDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + StructuredOutputDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual StructuredOutputDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeStructuredOutputDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StructuredOutputDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/StructuredOutputDefinition.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/StructuredOutputDefinition.cs new file mode 100644 index 000000000000..af62be2eccdd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/StructuredOutputDefinition.cs @@ -0,0 +1,87 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// A structured output that can be produced by the agent. + public partial class StructuredOutputDefinition + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The name of the structured output. + /// A description of the output to emit. Used by the model to determine when to emit the output. + /// The JSON schema for the structured output. + /// Whether to enforce strict validation. Default `true`. + /// , or is null. + public StructuredOutputDefinition(string name, string description, BinaryData schema, bool? strict) + { + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(description, nameof(description)); + Argument.AssertNotNull(schema, nameof(schema)); + + Name = name; + Description = description; + Schema = schema; + Strict = strict; + } + + /// Initializes a new instance of . + /// The name of the structured output. + /// A description of the output to emit. Used by the model to determine when to emit the output. + /// The JSON schema for the structured output. + /// Whether to enforce strict validation. Default `true`. + /// Keeps track of any properties unknown to the library. + internal StructuredOutputDefinition(string name, string description, BinaryData schema, bool? strict, IDictionary additionalBinaryDataProperties) + { + Name = name; + Description = description; + Schema = schema; + Strict = strict; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The name of the structured output. + public string Name { get; set; } + + /// A description of the output to emit. Used by the model to determine when to emit the output. + public string Description { get; set; } + + /// + /// The JSON schema for the structured output. + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData Schema { get; set; } + + /// Whether to enforce strict validation. Default `true`. + public bool? Strict { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ToolChoiceObjectType.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ToolChoiceObjectType.cs new file mode 100644 index 000000000000..05586ed20e3b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ToolChoiceObjectType.cs @@ -0,0 +1,89 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + /// + /// Indicates that the model should use a built-in tool to generate a response. + /// [Learn more about built-in tools](https://platform.openai.com/docs/guides/tools). + /// + internal readonly partial struct ToolChoiceObjectType : IEquatable + { + private readonly string _value; + private const string FileSearchValue = "file_search"; + private const string FunctionValue = "function"; + private const string ComputerValue = "computer_use_preview"; + private const string WebSearchValue = "web_search_preview"; + private const string ImageGenerationValue = "image_generation"; + private const string CodeInterpreterValue = "code_interpreter"; + private const string McpValue = "mcp"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ToolChoiceObjectType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the FileSearch. + public static ToolChoiceObjectType FileSearch { get; } = new ToolChoiceObjectType(FileSearchValue); + + /// Gets the Function. + public static ToolChoiceObjectType Function { get; } = new ToolChoiceObjectType(FunctionValue); + + /// Gets the Computer. + public static ToolChoiceObjectType Computer { get; } = new ToolChoiceObjectType(ComputerValue); + + /// Gets the WebSearch. + public static ToolChoiceObjectType WebSearch { get; } = new ToolChoiceObjectType(WebSearchValue); + + /// Gets the ImageGeneration. + public static ToolChoiceObjectType ImageGeneration { get; } = new ToolChoiceObjectType(ImageGenerationValue); + + /// Gets the CodeInterpreter. + public static ToolChoiceObjectType CodeInterpreter { get; } = new ToolChoiceObjectType(CodeInterpreterValue); + + /// Gets the Mcp. + public static ToolChoiceObjectType Mcp { get; } = new ToolChoiceObjectType(McpValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ToolChoiceObjectType left, ToolChoiceObjectType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ToolChoiceObjectType left, ToolChoiceObjectType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ToolChoiceObjectType(string value) => new ToolChoiceObjectType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ToolChoiceObjectType?(string value) => value == null ? null : new ToolChoiceObjectType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ToolChoiceObjectType other && Equals(other); + + /// + public bool Equals(ToolChoiceObjectType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ToolChoiceOptions.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ToolChoiceOptions.cs new file mode 100644 index 000000000000..a0f6a984367d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ToolChoiceOptions.cs @@ -0,0 +1,69 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct ToolChoiceOptions : IEquatable + { + private readonly string _value; + private const string NoneValue = "none"; + private const string AutoValue = "auto"; + private const string RequiredValue = "required"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ToolChoiceOptions(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the None. + public static ToolChoiceOptions None { get; } = new ToolChoiceOptions(NoneValue); + + /// Gets the Auto. + public static ToolChoiceOptions Auto { get; } = new ToolChoiceOptions(AutoValue); + + /// Gets the Required. + public static ToolChoiceOptions Required { get; } = new ToolChoiceOptions(RequiredValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ToolChoiceOptions left, ToolChoiceOptions right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ToolChoiceOptions left, ToolChoiceOptions right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ToolChoiceOptions(string value) => new ToolChoiceOptions(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ToolChoiceOptions?(string value) => value == null ? null : new ToolChoiceOptions(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ToolChoiceOptions other && Equals(other); + + /// + public bool Equals(ToolChoiceOptions other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ToolProjectConnection.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ToolProjectConnection.Serialization.cs new file mode 100644 index 000000000000..60cd07d5074f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ToolProjectConnection.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// A project connection resource. + public partial class ToolProjectConnection : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ToolProjectConnection() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ToolProjectConnection)} does not support writing '{format}' format."); + } + writer.WritePropertyName("project_connection_id"u8); + writer.WriteStringValue(ProjectConnectionId); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ToolProjectConnection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ToolProjectConnection JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ToolProjectConnection)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeToolProjectConnection(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ToolProjectConnection DeserializeToolProjectConnection(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string projectConnectionId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("project_connection_id"u8)) + { + projectConnectionId = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ToolProjectConnection(projectConnectionId, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(ToolProjectConnection)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ToolProjectConnection IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ToolProjectConnection PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeToolProjectConnection(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ToolProjectConnection)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ToolProjectConnection.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ToolProjectConnection.cs new file mode 100644 index 000000000000..6dc6812301a0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ToolProjectConnection.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// A project connection resource. + public partial class ToolProjectConnection + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// A project connection in a ToolProjectConnectionList attached to this tool. + /// is null. + public ToolProjectConnection(string projectConnectionId) + { + Argument.AssertNotNull(projectConnectionId, nameof(projectConnectionId)); + + ProjectConnectionId = projectConnectionId; + } + + /// Initializes a new instance of . + /// A project connection in a ToolProjectConnectionList attached to this tool. + /// Keeps track of any properties unknown to the library. + internal ToolProjectConnection(string projectConnectionId, IDictionary additionalBinaryDataProperties) + { + ProjectConnectionId = projectConnectionId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// A project connection in a ToolProjectConnectionList attached to this tool. + public string ProjectConnectionId { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ToolType.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ToolType.cs new file mode 100644 index 000000000000..89704f3f6992 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/ToolType.cs @@ -0,0 +1,134 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + /// A tool that can be used to generate a response. + internal readonly partial struct ToolType : IEquatable + { + private readonly string _value; + private const string FileSearchValue = "file_search"; + private const string FunctionValue = "function"; + private const string ComputerUsePreviewValue = "computer_use_preview"; + private const string WebSearchPreviewValue = "web_search_preview"; + private const string McpValue = "mcp"; + private const string CodeInterpreterValue = "code_interpreter"; + private const string ImageGenerationValue = "image_generation"; + private const string LocalShellValue = "local_shell"; + private const string BingGroundingValue = "bing_grounding"; + private const string BrowserAutomationPreviewValue = "browser_automation_preview"; + private const string FabricDataagentPreviewValue = "fabric_dataagent_preview"; + private const string SharepointGroundingPreviewValue = "sharepoint_grounding_preview"; + private const string AzureAiSearchValue = "azure_ai_search"; + private const string OpenapiValue = "openapi"; + private const string BingCustomSearchPreviewValue = "bing_custom_search_preview"; + private const string CaptureStructuredOutputsValue = "capture_structured_outputs"; + private const string A2aPreviewValue = "a2a_preview"; + private const string AzureFunctionValue = "azure_function"; + private const string MemorySearchValue = "memory_search"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ToolType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the FileSearch. + public static ToolType FileSearch { get; } = new ToolType(FileSearchValue); + + /// Gets the Function. + public static ToolType Function { get; } = new ToolType(FunctionValue); + + /// Gets the ComputerUsePreview. + public static ToolType ComputerUsePreview { get; } = new ToolType(ComputerUsePreviewValue); + + /// Gets the WebSearchPreview. + public static ToolType WebSearchPreview { get; } = new ToolType(WebSearchPreviewValue); + + /// Gets the Mcp. + public static ToolType Mcp { get; } = new ToolType(McpValue); + + /// Gets the CodeInterpreter. + public static ToolType CodeInterpreter { get; } = new ToolType(CodeInterpreterValue); + + /// Gets the ImageGeneration. + public static ToolType ImageGeneration { get; } = new ToolType(ImageGenerationValue); + + /// Gets the LocalShell. + public static ToolType LocalShell { get; } = new ToolType(LocalShellValue); + + /// Gets the BingGrounding. + public static ToolType BingGrounding { get; } = new ToolType(BingGroundingValue); + + /// Gets the BrowserAutomationPreview. + public static ToolType BrowserAutomationPreview { get; } = new ToolType(BrowserAutomationPreviewValue); + + /// Gets the FabricDataagentPreview. + public static ToolType FabricDataagentPreview { get; } = new ToolType(FabricDataagentPreviewValue); + + /// Gets the SharepointGroundingPreview. + public static ToolType SharepointGroundingPreview { get; } = new ToolType(SharepointGroundingPreviewValue); + + /// Gets the AzureAiSearch. + public static ToolType AzureAiSearch { get; } = new ToolType(AzureAiSearchValue); + + /// Gets the Openapi. + public static ToolType Openapi { get; } = new ToolType(OpenapiValue); + + /// Gets the BingCustomSearchPreview. + public static ToolType BingCustomSearchPreview { get; } = new ToolType(BingCustomSearchPreviewValue); + + /// Gets the CaptureStructuredOutputs. + public static ToolType CaptureStructuredOutputs { get; } = new ToolType(CaptureStructuredOutputsValue); + + /// Gets the A2aPreview. + public static ToolType A2aPreview { get; } = new ToolType(A2aPreviewValue); + + /// Gets the AzureFunction. + public static ToolType AzureFunction { get; } = new ToolType(AzureFunctionValue); + + /// Gets the MemorySearch. + public static ToolType MemorySearch { get; } = new ToolType(MemorySearchValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ToolType left, ToolType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ToolType left, ToolType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ToolType(string value) => new ToolType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ToolType?(string value) => value == null ? null : new ToolType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ToolType other && Equals(other); + + /// + public bool Equals(ToolType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownAgentDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownAgentDefinition.Serialization.cs new file mode 100644 index 000000000000..c77c38e3edf5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownAgentDefinition.Serialization.cs @@ -0,0 +1,132 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + internal partial class UnknownAgentDefinition : AgentDefinition, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownAgentDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentDefinition)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownAgentDefinition DeserializeUnknownAgentDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentKind kind = default; + ContentFilterConfiguration contentFilterConfiguration = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("kind"u8)) + { + kind = new AgentKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("rai_config"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + contentFilterConfiguration = ContentFilterConfiguration.DeserializeContentFilterConfiguration(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownAgentDefinition(kind, contentFilterConfiguration, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(AgentDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AgentDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownAgentDefinition.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownAgentDefinition.cs new file mode 100644 index 000000000000..74b2da2856ad --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownAgentDefinition.cs @@ -0,0 +1,20 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + internal partial class UnknownAgentDefinition : AgentDefinition + { + /// Initializes a new instance of . + /// + /// Configuration for Responsible AI (RAI) content filtering and safety features. + /// Keeps track of any properties unknown to the library. + internal UnknownAgentDefinition(AgentKind kind, ContentFilterConfiguration contentFilterConfiguration, IDictionary additionalBinaryDataProperties) : base(kind != default ? kind : "unknown", contentFilterConfiguration, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownAnnotation.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownAnnotation.Serialization.cs new file mode 100644 index 000000000000..a41475e6a567 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownAnnotation.Serialization.cs @@ -0,0 +1,123 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class UnknownAnnotation : InternalAnnotation, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownAnnotation() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAnnotation)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalAnnotation JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAnnotation)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAnnotation(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownAnnotation DeserializeUnknownAnnotation(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AnnotationType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AnnotationType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownAnnotation(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalAnnotation)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalAnnotation PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAnnotation)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownAnnotation.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownAnnotation.cs new file mode 100644 index 000000000000..3d6ece197010 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownAnnotation.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class UnknownAnnotation : InternalAnnotation + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal UnknownAnnotation(AnnotationType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownCodeInterpreterOutput.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownCodeInterpreterOutput.Serialization.cs new file mode 100644 index 000000000000..6bdfdc0f98b5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownCodeInterpreterOutput.Serialization.cs @@ -0,0 +1,123 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class UnknownCodeInterpreterOutput : InternalCodeInterpreterOutput, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownCodeInterpreterOutput() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutput)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalCodeInterpreterOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalCodeInterpreterOutput JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutput)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCodeInterpreterOutput(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownCodeInterpreterOutput DeserializeUnknownCodeInterpreterOutput(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CodeInterpreterOutputType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToCodeInterpreterOutputType(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownCodeInterpreterOutput(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutput)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalCodeInterpreterOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalCodeInterpreterOutput PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalCodeInterpreterOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutput)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownCodeInterpreterOutput.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownCodeInterpreterOutput.cs new file mode 100644 index 000000000000..afacd4028ae6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownCodeInterpreterOutput.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class UnknownCodeInterpreterOutput : InternalCodeInterpreterOutput + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal UnknownCodeInterpreterOutput(CodeInterpreterOutputType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownComputerAction.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownComputerAction.Serialization.cs new file mode 100644 index 000000000000..4ca8ab1b7a98 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownComputerAction.Serialization.cs @@ -0,0 +1,123 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class UnknownComputerAction : InternalComputerAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownComputerAction() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerAction)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalComputerAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerAction)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerAction(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownComputerAction DeserializeUnknownComputerAction(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComputerActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToComputerActionType(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownComputerAction(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerAction)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalComputerAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerAction)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownComputerAction.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownComputerAction.cs new file mode 100644 index 000000000000..13160759b2fd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownComputerAction.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class UnknownComputerAction : InternalComputerAction + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal UnknownComputerAction(ComputerActionType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownComputerToolCallOutputItemOutput.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownComputerToolCallOutputItemOutput.Serialization.cs new file mode 100644 index 000000000000..54097522c76e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownComputerToolCallOutputItemOutput.Serialization.cs @@ -0,0 +1,123 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class UnknownComputerToolCallOutputItemOutput : InternalComputerToolCallOutputItemOutput, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownComputerToolCallOutputItemOutput() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemOutput)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerToolCallOutputItemOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalComputerToolCallOutputItemOutput JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemOutput)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerToolCallOutputItemOutput(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownComputerToolCallOutputItemOutput DeserializeUnknownComputerToolCallOutputItemOutput(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComputerToolCallOutputItemOutputType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ComputerToolCallOutputItemOutputType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownComputerToolCallOutputItemOutput(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemOutput)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerToolCallOutputItemOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalComputerToolCallOutputItemOutput PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerToolCallOutputItemOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemOutput)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownComputerToolCallOutputItemOutput.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownComputerToolCallOutputItemOutput.cs new file mode 100644 index 000000000000..0ca2f89e123e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownComputerToolCallOutputItemOutput.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class UnknownComputerToolCallOutputItemOutput : InternalComputerToolCallOutputItemOutput + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal UnknownComputerToolCallOutputItemOutput(ComputerToolCallOutputItemOutputType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownHostedAgentDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownHostedAgentDefinition.Serialization.cs new file mode 100644 index 000000000000..fe234c88f373 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownHostedAgentDefinition.Serialization.cs @@ -0,0 +1,200 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + internal partial class UnknownHostedAgentDefinition : HostedAgentDefinition, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownHostedAgentDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(HostedAgentDefinition)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + HostedAgentDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (UnknownHostedAgentDefinition)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(HostedAgentDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeHostedAgentDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownHostedAgentDefinition DeserializeUnknownHostedAgentDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentKind kind = default; + ContentFilterConfiguration contentFilterConfiguration = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList tools = default; + IList containerProtocolVersions = default; + string cpu = default; + string memory = default; + IDictionary environmentVariables = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("kind"u8)) + { + kind = new AgentKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("rai_config"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + contentFilterConfiguration = ContentFilterConfiguration.DeserializeContentFilterConfiguration(prop.Value, options); + continue; + } + if (prop.NameEquals("tools"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(AgentTool.DeserializeAgentTool(item, options)); + } + tools = array; + continue; + } + if (prop.NameEquals("container_protocol_versions"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ProtocolVersionRecord.DeserializeProtocolVersionRecord(item, options)); + } + containerProtocolVersions = array; + continue; + } + if (prop.NameEquals("cpu"u8)) + { + cpu = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("memory"u8)) + { + memory = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("environment_variables"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + environmentVariables = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownHostedAgentDefinition( + kind, + contentFilterConfiguration, + additionalBinaryDataProperties, + tools ?? new ChangeTrackingList(), + containerProtocolVersions, + cpu, + memory, + environmentVariables ?? new ChangeTrackingDictionary()); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(HostedAgentDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + HostedAgentDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (UnknownHostedAgentDefinition)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeHostedAgentDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(HostedAgentDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownHostedAgentDefinition.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownHostedAgentDefinition.cs new file mode 100644 index 000000000000..db8cea94fa1f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownHostedAgentDefinition.cs @@ -0,0 +1,28 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + internal partial class UnknownHostedAgentDefinition : HostedAgentDefinition + { + /// Initializes a new instance of . + /// + /// Configuration for Responsible AI (RAI) content filtering and safety features. + /// Keeps track of any properties unknown to the library. + /// + /// An array of tools the hosted agent's model may call while generating a response. You + /// can specify which tool to use by setting the `tool_choice` parameter. + /// + /// The protocols that the agent supports for ingress communication of the containers. + /// The CPU configuration for the hosted agent. + /// The memory configuration for the hosted agent. + /// Environment variables to set in the hosted agent container. + internal UnknownHostedAgentDefinition(AgentKind kind, ContentFilterConfiguration contentFilterConfiguration, IDictionary additionalBinaryDataProperties, IList tools, IList containerProtocolVersions, string cpu, string memory, IDictionary environmentVariables) : base(kind != default ? kind : "unknown", contentFilterConfiguration, additionalBinaryDataProperties, tools, containerProtocolVersions, cpu, memory, environmentVariables) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownItemContent.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownItemContent.Serialization.cs new file mode 100644 index 000000000000..b862ca59a3fc --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownItemContent.Serialization.cs @@ -0,0 +1,123 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class UnknownItemContent : InternalItemContent, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownItemContent() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContent)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalItemContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalItemContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownItemContent DeserializeUnknownItemContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemContentType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToItemContentType(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownItemContent(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalItemContent)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalItemContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalItemContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalItemContent)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownItemContent.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownItemContent.cs new file mode 100644 index 000000000000..a5cc285369fd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownItemContent.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class UnknownItemContent : InternalItemContent + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal UnknownItemContent(ItemContentType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownItemParam.Serialization.cs new file mode 100644 index 000000000000..d5ed1a581472 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownItemParam.Serialization.cs @@ -0,0 +1,123 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class UnknownItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownItemParam DeserializeUnknownItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownItemParam(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownItemParam.cs new file mode 100644 index 000000000000..aa5829c3a88b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownItemParam.cs @@ -0,0 +1,20 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class UnknownItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal UnknownItemParam(AgentResponseItemKind @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownItemResource.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownItemResource.Serialization.cs new file mode 100644 index 000000000000..713d3743e690 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownItemResource.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class UnknownItemResource : AgentResponseItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownItemResource() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentResponseItem)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentResponseItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentResponseItem)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentResponseItem(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownItemResource DeserializeUnknownItemResource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + string id = default; + AgentResponseItemSource createdBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdBy = AgentResponseItemSource.DeserializeAgentResponseItemSource(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownItemResource(@type, id, createdBy, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(AgentResponseItem)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AgentResponseItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentResponseItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentResponseItem)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownItemResource.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownItemResource.cs new file mode 100644 index 000000000000..d45b71a607eb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownItemResource.cs @@ -0,0 +1,22 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class UnknownItemResource : AgentResponseItem + { + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + internal UnknownItemResource(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", id, createdBy, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownLocation.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownLocation.Serialization.cs new file mode 100644 index 000000000000..7624bb1ffd84 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownLocation.Serialization.cs @@ -0,0 +1,123 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class UnknownLocation : InternalLocation, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownLocation() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalLocation)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalLocation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalLocation JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalLocation)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalLocation(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownLocation DeserializeUnknownLocation(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + LocationType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new LocationType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownLocation(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalLocation)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalLocation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalLocation PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalLocation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalLocation)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownLocation.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownLocation.cs new file mode 100644 index 000000000000..6f998e65800f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownLocation.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class UnknownLocation : InternalLocation + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal UnknownLocation(LocationType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownMemoryItem.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownMemoryItem.Serialization.cs new file mode 100644 index 000000000000..56f1f991aa00 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownMemoryItem.Serialization.cs @@ -0,0 +1,152 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + internal partial class UnknownMemoryItem : MemoryItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownMemoryItem() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryItem)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemoryItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override MemoryItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryItem)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemoryItem(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownMemoryItem DeserializeUnknownMemoryItem(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string memoryId = default; + DateTimeOffset updatedAt = default; + string scope = default; + string content = default; + MemoryItemKind kind = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("memory_id"u8)) + { + memoryId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("updated_at"u8)) + { + updatedAt = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64()); + continue; + } + if (prop.NameEquals("scope"u8)) + { + scope = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("content"u8)) + { + content = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("kind"u8)) + { + kind = new MemoryItemKind(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownMemoryItem( + memoryId, + updatedAt, + scope, + content, + kind, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(MemoryItem)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemoryItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override MemoryItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemoryItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemoryItem)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownMemoryItem.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownMemoryItem.cs new file mode 100644 index 000000000000..3abc09823634 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownMemoryItem.cs @@ -0,0 +1,23 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + internal partial class UnknownMemoryItem : MemoryItem + { + /// Initializes a new instance of . + /// The unique ID of the memory item. + /// The last update time of the memory item. + /// The namespace that logically groups and isolates memories, such as a user ID. + /// The content of the memory. + /// The kind of the memory item. + /// Keeps track of any properties unknown to the library. + internal UnknownMemoryItem(string memoryId, DateTimeOffset updatedAt, string scope, string content, MemoryItemKind kind, IDictionary additionalBinaryDataProperties) : base(memoryId, updatedAt, scope, content, kind != default ? kind : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownOpenAPIAuthenticationDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownOpenAPIAuthenticationDetails.Serialization.cs new file mode 100644 index 000000000000..c78f53b023e5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownOpenAPIAuthenticationDetails.Serialization.cs @@ -0,0 +1,122 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + internal partial class UnknownOpenAPIAuthenticationDetails : OpenAPIAuthenticationDetails, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownOpenAPIAuthenticationDetails() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAPIAuthenticationDetails)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + OpenAPIAuthenticationDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override OpenAPIAuthenticationDetails JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenAPIAuthenticationDetails)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenAPIAuthenticationDetails(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownOpenAPIAuthenticationDetails DeserializeUnknownOpenAPIAuthenticationDetails(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenApiAuthType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new OpenApiAuthType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownOpenAPIAuthenticationDetails(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(OpenAPIAuthenticationDetails)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + OpenAPIAuthenticationDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override OpenAPIAuthenticationDetails PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeOpenAPIAuthenticationDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenAPIAuthenticationDetails)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownOpenAPIAuthenticationDetails.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownOpenAPIAuthenticationDetails.cs new file mode 100644 index 000000000000..83d56d3f65ae --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownOpenAPIAuthenticationDetails.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + internal partial class UnknownOpenAPIAuthenticationDetails : OpenAPIAuthenticationDetails + { + /// Initializes a new instance of . + /// The type of authentication, must be anonymous/project_connection/managed_identity. + /// Keeps track of any properties unknown to the library. + internal UnknownOpenAPIAuthenticationDetails(OpenApiAuthType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownReasoningItemSummaryPart.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownReasoningItemSummaryPart.Serialization.cs new file mode 100644 index 000000000000..6a1c8ef26b8b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownReasoningItemSummaryPart.Serialization.cs @@ -0,0 +1,123 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class UnknownReasoningItemSummaryPart : InternalReasoningItemSummaryPart, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownReasoningItemSummaryPart() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalReasoningItemSummaryPart)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalReasoningItemSummaryPart IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalReasoningItemSummaryPart JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalReasoningItemSummaryPart)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalReasoningItemSummaryPart(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownReasoningItemSummaryPart DeserializeUnknownReasoningItemSummaryPart(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ReasoningItemSummaryPartType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ReasoningItemSummaryPartType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownReasoningItemSummaryPart(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalReasoningItemSummaryPart)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalReasoningItemSummaryPart IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalReasoningItemSummaryPart PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalReasoningItemSummaryPart(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalReasoningItemSummaryPart)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownReasoningItemSummaryPart.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownReasoningItemSummaryPart.cs new file mode 100644 index 000000000000..9695a3c70b5e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownReasoningItemSummaryPart.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class UnknownReasoningItemSummaryPart : InternalReasoningItemSummaryPart + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal UnknownReasoningItemSummaryPart(ReasoningItemSummaryPartType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownResponseTextFormatConfiguration.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownResponseTextFormatConfiguration.Serialization.cs new file mode 100644 index 000000000000..6e095c4039a3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownResponseTextFormatConfiguration.Serialization.cs @@ -0,0 +1,123 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class UnknownResponseTextFormatConfiguration : InternalResponseTextFormatConfiguration, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownResponseTextFormatConfiguration() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfiguration)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponseTextFormatConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalResponseTextFormatConfiguration JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfiguration)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponseTextFormatConfiguration(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownResponseTextFormatConfiguration DeserializeUnknownResponseTextFormatConfiguration(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResponseTextFormatConfigurationType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ResponseTextFormatConfigurationType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownResponseTextFormatConfiguration(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfiguration)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponseTextFormatConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalResponseTextFormatConfiguration PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponseTextFormatConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfiguration)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownResponseTextFormatConfiguration.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownResponseTextFormatConfiguration.cs new file mode 100644 index 000000000000..552f7432b6b5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownResponseTextFormatConfiguration.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class UnknownResponseTextFormatConfiguration : InternalResponseTextFormatConfiguration + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal UnknownResponseTextFormatConfiguration(ResponseTextFormatConfigurationType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownResponsesMessageItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownResponsesMessageItemParam.Serialization.cs new file mode 100644 index 000000000000..43daaedba631 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownResponsesMessageItemParam.Serialization.cs @@ -0,0 +1,129 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class UnknownResponsesMessageItemParam : InternalResponsesMessageItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownResponsesMessageItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesMessageItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponsesMessageItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (UnknownResponsesMessageItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesMessageItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponsesMessageItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownResponsesMessageItemParam DeserializeUnknownResponsesMessageItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ResponsesMessageRole role = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("role"u8)) + { + role = new ResponsesMessageRole(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownResponsesMessageItemParam(@type, additionalBinaryDataProperties, role); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponsesMessageItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponsesMessageItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (UnknownResponsesMessageItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponsesMessageItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponsesMessageItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownResponsesMessageItemParam.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownResponsesMessageItemParam.cs new file mode 100644 index 000000000000..67c42bd27259 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownResponsesMessageItemParam.cs @@ -0,0 +1,21 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class UnknownResponsesMessageItemParam : InternalResponsesMessageItemParam + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The role associated with the message. + internal UnknownResponsesMessageItemParam(AgentResponseItemKind @type, IDictionary additionalBinaryDataProperties, ResponsesMessageRole role) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties, role != default ? role : "unknown") + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownResponsesMessageItemResource.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownResponsesMessageItemResource.Serialization.cs new file mode 100644 index 000000000000..d0f61495ba95 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownResponsesMessageItemResource.Serialization.cs @@ -0,0 +1,157 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class UnknownResponsesMessageItemResource : InternalResponsesMessageItemResource, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownResponsesMessageItemResource() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesMessageItemResource)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponsesMessageItemResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (UnknownResponsesMessageItemResource)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentResponseItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesMessageItemResource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponsesMessageItemResource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownResponsesMessageItemResource DeserializeUnknownResponsesMessageItemResource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentResponseItemKind @type = default; + string id = default; + AgentResponseItemSource createdBy = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ResponsesMessageItemResourceStatus status = default; + ResponsesMessageRole role = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AgentResponseItemKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdBy = AgentResponseItemSource.DeserializeAgentResponseItemSource(prop.Value, options); + continue; + } + if (prop.NameEquals("status"u8)) + { + status = new ResponsesMessageItemResourceStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("role"u8)) + { + role = new ResponsesMessageRole(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownResponsesMessageItemResource( + @type, + id, + createdBy, + additionalBinaryDataProperties, + status, + role); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponsesMessageItemResource)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponsesMessageItemResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (UnknownResponsesMessageItemResource)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentResponseItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponsesMessageItemResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponsesMessageItemResource)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownResponsesMessageItemResource.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownResponsesMessageItemResource.cs new file mode 100644 index 000000000000..f5b02f5bdaa6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownResponsesMessageItemResource.cs @@ -0,0 +1,27 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class UnknownResponsesMessageItemResource : InternalResponsesMessageItemResource + { + /// Initializes a new instance of . + /// + /// + /// The information about the creator of the item. + /// Keeps track of any properties unknown to the library. + /// + /// The status of the item. One of `in_progress`, `completed`, or + /// `incomplete`. Populated when items are returned via API. + /// + /// The role associated with the message. + internal UnknownResponsesMessageItemResource(AgentResponseItemKind @type, string id, AgentResponseItemSource createdBy, IDictionary additionalBinaryDataProperties, ResponsesMessageItemResourceStatus status, ResponsesMessageRole role) : base(@type != default ? @type : "unknown", id, createdBy, additionalBinaryDataProperties, status, role != default ? role : "unknown") + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownTool.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownTool.Serialization.cs new file mode 100644 index 000000000000..86ab6af296f4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownTool.Serialization.cs @@ -0,0 +1,123 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class UnknownTool : AgentTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownTool DeserializeUnknownTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownTool(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(AgentTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AgentTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownTool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownTool.cs new file mode 100644 index 000000000000..a8232d6c632b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownTool.cs @@ -0,0 +1,20 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class UnknownTool : AgentTool + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal UnknownTool(ToolType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownToolChoiceObject.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownToolChoiceObject.Serialization.cs new file mode 100644 index 000000000000..b30685e50837 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownToolChoiceObject.Serialization.cs @@ -0,0 +1,123 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class UnknownToolChoiceObject : InternalToolChoiceObject, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownToolChoiceObject() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalToolChoiceObject)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalToolChoiceObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalToolChoiceObject JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalToolChoiceObject)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalToolChoiceObject(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownToolChoiceObject DeserializeUnknownToolChoiceObject(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolChoiceObjectType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolChoiceObjectType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownToolChoiceObject(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalToolChoiceObject)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalToolChoiceObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalToolChoiceObject PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalToolChoiceObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalToolChoiceObject)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownToolChoiceObject.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownToolChoiceObject.cs new file mode 100644 index 000000000000..7663235ae747 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownToolChoiceObject.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class UnknownToolChoiceObject : InternalToolChoiceObject + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal UnknownToolChoiceObject(ToolChoiceObjectType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownWebSearchAction.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownWebSearchAction.Serialization.cs new file mode 100644 index 000000000000..f26a09fa26c8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownWebSearchAction.Serialization.cs @@ -0,0 +1,123 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal partial class UnknownWebSearchAction : InternalWebSearchAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownWebSearchAction() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchAction)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalWebSearchAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalWebSearchAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchAction)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalWebSearchAction(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownWebSearchAction DeserializeUnknownWebSearchAction(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + WebSearchActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToWebSearchActionType(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownWebSearchAction(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(InternalWebSearchAction)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalWebSearchAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalWebSearchAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalWebSearchAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalWebSearchAction)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownWebSearchAction.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownWebSearchAction.cs new file mode 100644 index 000000000000..6414375bba85 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UnknownWebSearchAction.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class UnknownWebSearchAction : InternalWebSearchAction + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal UnknownWebSearchAction(WebSearchActionType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UserProfileMemoryItem.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UserProfileMemoryItem.Serialization.cs new file mode 100644 index 000000000000..a952a35b9c92 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UserProfileMemoryItem.Serialization.cs @@ -0,0 +1,153 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace Azure.AI.Projects +{ + internal partial class UserProfileMemoryItem : MemoryItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UserProfileMemoryItem() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UserProfileMemoryItem)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + UserProfileMemoryItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (UserProfileMemoryItem)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override MemoryItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UserProfileMemoryItem)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUserProfileMemoryItem(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UserProfileMemoryItem DeserializeUserProfileMemoryItem(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string memoryId = default; + DateTimeOffset updatedAt = default; + string scope = default; + string content = default; + MemoryItemKind kind = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("memory_id"u8)) + { + memoryId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("updated_at"u8)) + { + updatedAt = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64()); + continue; + } + if (prop.NameEquals("scope"u8)) + { + scope = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("content"u8)) + { + content = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("kind"u8)) + { + kind = new MemoryItemKind(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UserProfileMemoryItem( + memoryId, + updatedAt, + scope, + content, + kind, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(UserProfileMemoryItem)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + UserProfileMemoryItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (UserProfileMemoryItem)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override MemoryItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeUserProfileMemoryItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UserProfileMemoryItem)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UserProfileMemoryItem.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UserProfileMemoryItem.cs new file mode 100644 index 000000000000..fa4266f4eaec --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/UserProfileMemoryItem.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace Azure.AI.Projects +{ + internal partial class UserProfileMemoryItem : MemoryItem + { + /// Initializes a new instance of . + /// The unique ID of the memory item. + /// The last update time of the memory item. + /// The namespace that logically groups and isolates memories, such as a user ID. + /// The content of the memory. + /// , or is null. + public UserProfileMemoryItem(string memoryId, DateTimeOffset updatedAt, string scope, string content) : base(memoryId, updatedAt, scope, content, MemoryItemKind.UserProfile) + { + Argument.AssertNotNull(memoryId, nameof(memoryId)); + Argument.AssertNotNull(scope, nameof(scope)); + Argument.AssertNotNull(content, nameof(content)); + + } + + /// Initializes a new instance of . + /// The unique ID of the memory item. + /// The last update time of the memory item. + /// The namespace that logically groups and isolates memories, such as a user ID. + /// The content of the memory. + /// The kind of the memory item. + /// Keeps track of any properties unknown to the library. + internal UserProfileMemoryItem(string memoryId, DateTimeOffset updatedAt, string scope, string content, MemoryItemKind kind, IDictionary additionalBinaryDataProperties) : base(memoryId, updatedAt, scope, content, kind, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/WebSearchActionSearchSources.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/WebSearchActionSearchSources.Serialization.cs new file mode 100644 index 000000000000..841f71e774bc --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/WebSearchActionSearchSources.Serialization.cs @@ -0,0 +1,148 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + /// The WebSearchActionSearchSources. + internal partial class WebSearchActionSearchSources : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal WebSearchActionSearchSources() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WebSearchActionSearchSources)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Url); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + WebSearchActionSearchSources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual WebSearchActionSearchSources JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WebSearchActionSearchSources)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWebSearchActionSearchSources(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static WebSearchActionSearchSources DeserializeWebSearchActionSearchSources(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = default; + string url = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("url"u8)) + { + url = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new WebSearchActionSearchSources(@type, url, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(WebSearchActionSearchSources)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + WebSearchActionSearchSources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual WebSearchActionSearchSources PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeWebSearchActionSearchSources(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WebSearchActionSearchSources)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/WebSearchActionSearchSources.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/WebSearchActionSearchSources.cs new file mode 100644 index 000000000000..9453c60acbbf --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/WebSearchActionSearchSources.cs @@ -0,0 +1,44 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + /// The WebSearchActionSearchSources. + internal partial class WebSearchActionSearchSources + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// is null. + public WebSearchActionSearchSources(string url) + { + Argument.AssertNotNull(url, nameof(url)); + + Url = url; + } + + /// Initializes a new instance of . + /// + /// + /// Keeps track of any properties unknown to the library. + internal WebSearchActionSearchSources(string @type, string url, IDictionary additionalBinaryDataProperties) + { + Type = @type; + Url = url; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Type. + internal string Type { get; } = "url"; + + /// Gets the Url. + public string Url { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/WebSearchActionType.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/WebSearchActionType.Serialization.cs new file mode 100644 index 000000000000..d45f668c8e23 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/WebSearchActionType.Serialization.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; + +namespace OpenAI +{ + internal static partial class WebSearchActionTypeExtensions + { + /// The value to serialize. + public static string ToSerialString(this WebSearchActionType value) => value switch + { + WebSearchActionType.Search => "search", + WebSearchActionType.OpenPage => "open_page", + WebSearchActionType.Find => "find", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown WebSearchActionType value.") + }; + + /// The value to deserialize. + public static WebSearchActionType ToWebSearchActionType(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "search")) + { + return WebSearchActionType.Search; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "open_page")) + { + return WebSearchActionType.OpenPage; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "find")) + { + return WebSearchActionType.Find; + } + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown WebSearchActionType value."); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/WebSearchActionType.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/WebSearchActionType.cs new file mode 100644 index 000000000000..93f691047824 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/WebSearchActionType.cs @@ -0,0 +1,17 @@ +// + +#nullable disable + +namespace OpenAI +{ + /// + internal enum WebSearchActionType + { + /// Search. + Search, + /// OpenPage. + OpenPage, + /// Find. + Find + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/WebSearchPreviewToolSearchContextSize.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/WebSearchPreviewToolSearchContextSize.cs new file mode 100644 index 000000000000..f27ea57a5d51 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/WebSearchPreviewToolSearchContextSize.cs @@ -0,0 +1,69 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct WebSearchPreviewToolSearchContextSize : IEquatable + { + private readonly string _value; + private const string LowValue = "low"; + private const string MediumValue = "medium"; + private const string HighValue = "high"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public WebSearchPreviewToolSearchContextSize(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Low. + public static WebSearchPreviewToolSearchContextSize Low { get; } = new WebSearchPreviewToolSearchContextSize(LowValue); + + /// Gets the Medium. + public static WebSearchPreviewToolSearchContextSize Medium { get; } = new WebSearchPreviewToolSearchContextSize(MediumValue); + + /// Gets the High. + public static WebSearchPreviewToolSearchContextSize High { get; } = new WebSearchPreviewToolSearchContextSize(HighValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(WebSearchPreviewToolSearchContextSize left, WebSearchPreviewToolSearchContextSize right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(WebSearchPreviewToolSearchContextSize left, WebSearchPreviewToolSearchContextSize right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator WebSearchPreviewToolSearchContextSize(string value) => new WebSearchPreviewToolSearchContextSize(value); + + /// Converts a string to a . + /// The value. + public static implicit operator WebSearchPreviewToolSearchContextSize?(string value) => value == null ? null : new WebSearchPreviewToolSearchContextSize(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is WebSearchPreviewToolSearchContextSize other && Equals(other); + + /// + public bool Equals(WebSearchPreviewToolSearchContextSize other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/WebSearchToolCallItemResourceStatus.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/WebSearchToolCallItemResourceStatus.cs new file mode 100644 index 000000000000..ecde087fb7f0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/WebSearchToolCallItemResourceStatus.cs @@ -0,0 +1,73 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects.OpenAI; + +namespace OpenAI +{ + internal readonly partial struct WebSearchToolCallItemResourceStatus : IEquatable + { + private readonly string _value; + private const string InProgressValue = "in_progress"; + private const string SearchingValue = "searching"; + private const string CompletedValue = "completed"; + private const string FailedValue = "failed"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public WebSearchToolCallItemResourceStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the InProgress. + public static WebSearchToolCallItemResourceStatus InProgress { get; } = new WebSearchToolCallItemResourceStatus(InProgressValue); + + /// Gets the Searching. + public static WebSearchToolCallItemResourceStatus Searching { get; } = new WebSearchToolCallItemResourceStatus(SearchingValue); + + /// Gets the Completed. + public static WebSearchToolCallItemResourceStatus Completed { get; } = new WebSearchToolCallItemResourceStatus(CompletedValue); + + /// Gets the Failed. + public static WebSearchToolCallItemResourceStatus Failed { get; } = new WebSearchToolCallItemResourceStatus(FailedValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(WebSearchToolCallItemResourceStatus left, WebSearchToolCallItemResourceStatus right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(WebSearchToolCallItemResourceStatus left, WebSearchToolCallItemResourceStatus right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator WebSearchToolCallItemResourceStatus(string value) => new WebSearchToolCallItemResourceStatus(value); + + /// Converts a string to a . + /// The value. + public static implicit operator WebSearchToolCallItemResourceStatus?(string value) => value == null ? null : new WebSearchToolCallItemResourceStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is WebSearchToolCallItemResourceStatus other && Equals(other); + + /// + public bool Equals(WebSearchToolCallItemResourceStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/WorkflowAgentDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/WorkflowAgentDefinition.Serialization.cs new file mode 100644 index 000000000000..7dfa6207f189 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/WorkflowAgentDefinition.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI +{ + /// The workflow agent definition. + public partial class WorkflowAgentDefinition : AgentDefinition, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WorkflowAgentDefinition)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(WorkflowYaml)) + { + writer.WritePropertyName("workflow"u8); + writer.WriteStringValue(WorkflowYaml); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + WorkflowAgentDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (WorkflowAgentDefinition)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AgentDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WorkflowAgentDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWorkflowAgentDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static WorkflowAgentDefinition DeserializeWorkflowAgentDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentKind kind = default; + ContentFilterConfiguration contentFilterConfiguration = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string workflowYaml = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("kind"u8)) + { + kind = new AgentKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("rai_config"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + contentFilterConfiguration = ContentFilterConfiguration.DeserializeContentFilterConfiguration(prop.Value, options); + continue; + } + if (prop.NameEquals("workflow"u8)) + { + workflowYaml = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new WorkflowAgentDefinition(kind, contentFilterConfiguration, additionalBinaryDataProperties, workflowYaml); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsOpenAIContext.Default); + default: + throw new FormatException($"The model {nameof(WorkflowAgentDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + WorkflowAgentDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (WorkflowAgentDefinition)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AgentDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeWorkflowAgentDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WorkflowAgentDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/WorkflowAgentDefinition.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/WorkflowAgentDefinition.cs new file mode 100644 index 000000000000..d39562a5bd64 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Generated/WorkflowAgentDefinition.cs @@ -0,0 +1,23 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects.OpenAI +{ + /// The workflow agent definition. + public partial class WorkflowAgentDefinition : AgentDefinition + { + /// Initializes a new instance of . + /// + /// Configuration for Responsible AI (RAI) content filtering and safety features. + /// Keeps track of any properties unknown to the library. + /// The CSDL YAML definition of the workflow. + internal WorkflowAgentDefinition(AgentKind kind, ContentFilterConfiguration contentFilterConfiguration, IDictionary additionalBinaryDataProperties, string workflowYaml) : base(kind, contentFilterConfiguration, additionalBinaryDataProperties) + { + WorkflowYaml = workflowYaml; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Properties/AssemblyInfo.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..d194bed477a3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Properties/AssemblyInfo.cs @@ -0,0 +1,2 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Telemetry/OpenTelemetryConstants.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Telemetry/OpenTelemetryConstants.cs new file mode 100644 index 000000000000..de18e8a02c76 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Telemetry/OpenTelemetryConstants.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +//namespace Azure.AI.Projects.OpenAI.Telemetry; + +//internal class OpenTelemetryConstants +//{ +// // follow OpenTelemetry GenAI semantic conventions: +// // https://github.com/open-telemetry/semantic-conventions/tree/v1.27.0/docs/gen-ai + +// public const string ErrorTypeKey = "error.type"; +// public const string ErrorMessageKey = "error.message"; + +// public const string AzNamespaceKey = "az.namespace"; +// public const string ServerAddressKey = "server.address"; +// public const string ServerPortKey = "server.port"; + +// public const string GenAiClientOperationDurationMetricName = "gen_ai.client.operation.duration"; +// public const string GenAiClientTokenUsageMetricName = "gen_ai.client.token.usage"; + +// public const string GenAiOperationNameKey = "gen_ai.operation.name"; + +// public const string GenAiRequestMaxTokensKey = "gen_ai.request.max_tokens"; +// public const string GenAiRequestModelKey = "gen_ai.request.model"; +// public const string GenAiAgentNameKey = "gen_ai.agent.name"; +// public const string GenAiRequestTemperatureKey = "gen_ai.request.temperature"; +// public const string GenAiRequestTopPKey = "gen_ai.request.top_p"; + +// public const string GenAiResponseModelKey = "gen_ai.response.model"; +// public const string GenAiResponseVersionKey = "gen_ai.agent.version"; + +// public const string GenAiSystemKey = "gen_ai.system"; +// public const string GenAiSystemValue = "az.AI.Projects.OpenAI"; +// public const string GenAiProviderKey = "gen_ai.provider"; +// public const string GenAiProviderValue = "azure.AI.Projects.OpenAI"; + +// public const string GenAiTokenTypeKey = "gen_ai.token.type"; + +// public const string GenAiUsageInputTokensKey = "gen_ai.usage.input_tokens"; +// public const string GenAiUsageOutputTokensKey = "gen_ai.usage.output_tokens"; +// public const string GenAiAgentIdKey = "gen_ai.agent.id"; +// public const string GenAiThreadIdKey = "gen_ai.thread.id"; +// public const string GenAiMessageIdKey = "gen_ai.message.id"; +// public const string GenAiMessageStatusKey = "gen_ai.message.status"; +// public const string GenAiRunIdKey = "gen_ai.thread.run.id"; +// public const string GenAiRunStatusKey = "gen_ai.thread.run.status"; +// public const string GenAiRunStepStatusKey = "gen_ai.run_step.status"; +// public const string GenAiRunStepStartTimestampKey = "gen_ai.run_step.start.timestamp"; +// public const string GenAiRunStepEndTimestampKey = "gen_ai.run_step.end.timestamp"; + +// public const string GenAiEventContent = "gen_ai.event.content"; +// public const string GenAiChoice = "gen_ai.choice"; + +// public const string AzureRpNamespaceValue = "Microsoft.CognitiveServices"; + +// public const string OperationNameValueCreateAgent = "create_agent"; +// public const string OperationNameValueCreateThread = "create_thread"; +// public const string OperationNameValueCreateMessage = "create_message"; +// public const string OperationNameValueStartThreadRun = "start_thread_run"; +// public const string OperationNameValueGetThreadRun = "get_thread_run"; +// public const string OperationNameValueExecuteTool = "execute_tool"; +// public const string OperationNameValueListMessage = "list_messages"; +// public const string OperationNameValueListRunSteps = "list_run_steps"; +// public const string OperationNameValueSubmitToolOutputs = "submit_tool_outputs"; +// public const string OperationNameValueProcessThreadRun = "process_thread_run"; + +// public const string EventNameSystemMessage = "gen_ai.system.message"; +// public const string EventNameUserMessage = "gen_ai.user.message"; +// public const string EventNameAssistantMessage = "gen_ai.assistant.message"; + +// public const string ClientName = "Azure.AI.Projects.OpenAI.AgentClient"; +// public const string EnableOpenTelemetrySwitch = "Azure.Experimental.EnableActivitySource"; +// public const string TraceContentsSwitch = "Azure.Experimental.TraceGenAIMessageContent"; +// public const string TraceContentsEnvironmentVariable = "OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT"; +// public const string EnableOpenTelemetryEnvironmentVariable = "AZURE_EXPERIMENTAL_ENABLE_ACTIVITY_SOURCE"; + +// public const string GenAiRequestReasoningEffort = "gen_ai.request.reasoning.effort"; +// public const string GenAiRequestReasoningSummary = "gen_ai.request.reasoning.summary"; +// public const string GenAiRequestStructuredInputs = "gen_ai.request.structured_inputs"; +// public const string GenAiAgentVersion = "gen_ai.agent.version"; +//} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Telemetry/OpenTelemetryScope.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Telemetry/OpenTelemetryScope.cs new file mode 100644 index 000000000000..1858f429eba1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Telemetry/OpenTelemetryScope.cs @@ -0,0 +1,321 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +//using System; +//using System.Collections.Generic; +//using System.Diagnostics; +//using System.Diagnostics.Metrics; +//using System.Text.Encodings.Web; +//using System.Text.Json; +//using System.Text.Json.Serialization; +//using System.Threading; +//using System.Threading.Tasks; +//using Azure.Core; +//using static Azure.AI.Projects.OpenAI.Telemetry.OpenTelemetryConstants; + +//namespace Azure.AI.Projects.OpenAI.Telemetry; + +//internal class OpenTelemetryScope : IDisposable +//{ +// internal enum OpenTelemetryScopeType +// { +// Unknown, +// CreateAgent, +// CreateThread, +// CreateMessage, +// CreateRun, +// ListMessages, +// SubmitToolOutputs, +// ListRunSteps +// } + +// /// +// /// Activity source is used to save events and log the tags. +// /// On the ApplicationInsights events are logged to traces table. +// /// The tags are not logged, but are shown in the console. +// /// +// private static readonly ActivitySource s_agentSource = new(ClientName); +// /// +// /// Add histograms to log metrics. +// /// On the ApplicationInsights metrics are logged to customMetrics table. +// /// +// private static readonly Meter s_meter = new Meter(ClientName); +// private static readonly Histogram s_duration = s_meter.CreateHistogram( +// GenAiClientOperationDurationMetricName, "s", "Measures GenAI operation duration."); +// private static readonly Histogram s_tokens = s_meter.CreateHistogram( +// GenAiClientTokenUsageMetricName, "{token}", "Measures the number of input and output token used."); +// private static readonly JsonSerializerOptions s_jsonOptions = new JsonSerializerOptions +// { +// DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, +// Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping // Allow non-ASCII characters +// }; + +// private readonly Activity _activity; +// private readonly Stopwatch _duration; +// private readonly TagList _commonTags; +// private static bool s_traceContent = AppContextSwitchHelper.GetConfigValue( +// TraceContentsSwitch, +// TraceContentsEnvironmentVariable); +// private static bool s_enableTelemetry = AppContextSwitchHelper.GetConfigValue( +// EnableOpenTelemetrySwitch, +// EnableOpenTelemetryEnvironmentVariable); +// // private RecordedResponse _response; +// private string _errorType; +// private Exception _exception; + +// private int _hasEnded = 0; +// private readonly OpenTelemetryScopeType _scopeType; +// private static void ReinitializeConfiguration() +// { +// s_traceContent = AppContextSwitchHelper.GetConfigValue( +// TraceContentsSwitch, +// TraceContentsEnvironmentVariable); + +// s_enableTelemetry = AppContextSwitchHelper.GetConfigValue( +// EnableOpenTelemetrySwitch, +// EnableOpenTelemetryEnvironmentVariable); +// } + +// /// +// /// Sets telemetry tags and events for agent definition, handling both PromptAgentDefinition and other types. +// /// +// /// The OpenTelemetryScope instance to set tags on. +// /// The agent definition to process. +// /// The name of the agent. +// private static void SetAgentDefinitionTelemetryTags(OpenTelemetryScope scope, AgentDefinition agentDefinition, string agentName) +// { +// if (agentDefinition is PromptAgentDefinition promptAgentDefinition) +// { +// scope.SetTagMaybe(GenAiRequestModelKey, promptAgentDefinition.Model); +// scope.SetTagMaybe(GenAiAgentNameKey, agentName); +// scope.SetTagMaybe(GenAiRequestTemperatureKey, promptAgentDefinition.Temperature); +// scope.SetTagMaybe(GenAiRequestTopPKey, promptAgentDefinition.TopP); + +// var reasoningOptions = promptAgentDefinition.ReasoningOptions; +// if (reasoningOptions != null) +// { +// scope.SetTagMaybe(GenAiRequestReasoningEffort, reasoningOptions.ReasoningEffortLevel); +// scope.SetTagMaybe(GenAiRequestReasoningSummary, reasoningOptions.ReasoningSummaryVerbosity); +// } + +// // TODO: check if structured outputs should be events and follow content recording flag +// //var structuredInputs = promptAgentDefinition.StructuredInputs; + +// string traceEvent = s_traceContent ? JsonSerializer.Serialize( +// new EventContent (promptAgentDefinition.Instructions), +// EventsContext.Default.EventContent +// ) : JsonSerializer.Serialize("", EventsContext.Default.String); + +// ActivityTagsCollection messageTags = new() { +// { GenAiSystemKey, GenAiSystemValue}, +// { GenAiEventContent, traceEvent } +// }; + +// scope._activity?.AddEvent( +// new ActivityEvent(EventNameSystemMessage, tags: messageTags) +// ); +// } +// else +// { +// // Handle other agent definition types or set default values +// scope.SetTagMaybe(GenAiRequestModelKey, "unknown"); +// scope.SetTagMaybe(GenAiAgentNameKey, agentName); +// scope.SetTagMaybe(GenAiRequestTemperatureKey, null); +// scope.SetTagMaybe(GenAiRequestTopPKey, null); +// } +// } + +// private OpenTelemetryScope(string activityName, Uri endpoint, string operationName=null) +// { +// _scopeType = activityName switch +// { +// var n when n == OperationNameValueCreateAgent => OpenTelemetryScopeType.CreateAgent, +// var n when n == OperationNameValueCreateThread => OpenTelemetryScopeType.CreateThread, +// var n when n == OperationNameValueCreateMessage => OpenTelemetryScopeType.CreateMessage, +// var n when n == OperationNameValueStartThreadRun => OpenTelemetryScopeType.CreateRun, +// var n when n == OperationNameValueListMessage => OpenTelemetryScopeType.ListMessages, +// var n when n == OperationNameValueSubmitToolOutputs => OpenTelemetryScopeType.SubmitToolOutputs, +// var n when n == OperationNameValueListRunSteps => OpenTelemetryScopeType.ListRunSteps, +// _ => OpenTelemetryScopeType.Unknown +// }; + +// if (operationName == null) +// { +// operationName = activityName; +// } + +// _activity = s_agentSource.StartActivity(activityName, ActivityKind.Client); + +// // suppress nested client activities from generated code. +// _activity?.SetCustomProperty("az.sdk.scope", bool.TrueString); + +// // Record the request to telemetry. +// _commonTags = new TagList() +// { +// { GenAiSystemKey, GenAiSystemValue}, +// { GenAiOperationNameKey, operationName}, +// { ServerAddressKey, endpoint.Host } +// }; +// // Only record port if it is different from 443. +// if (endpoint.Port != 443) +// { +// _commonTags.Add(ServerPortKey, endpoint.Port); +// } + +// // Set tags for reporting them to console. +// foreach (KeyValuePair kv in _commonTags) +// { +// _activity?.SetTag(kv.Key, kv.Value); +// } +// _activity?.SetTag(AzNamespaceKey, AzureRpNamespaceValue); +// _duration = Stopwatch.StartNew(); +// } + +// /// +// /// Log the error. +// /// +// /// Exception thrown by completion call. +// public void RecordError(Exception e) +// { +// if (s_enableTelemetry) +// { +// if (e is RequestFailedException requestFailed && requestFailed.Status != 0) +// { +// _errorType = requestFailed.Status.ToString(); +// } +// else +// { +// _errorType = e?.GetType()?.FullName ?? "error"; +// } +// _exception = e; +// } +// } + +// /// +// /// Record the task cancellation event. +// /// +// public void RecordCancellation() +// { +// if (s_enableTelemetry) +// { +// _errorType = typeof(TaskCanceledException).FullName; +// _exception = null; +// } +// } + +// /// +// /// Record the events and metrics associated with the response. +// /// +// private void End() +// { +// //TagList finalTags = _commonTags; + +// //if (_errorType == null && !IsResponseValid(_response)) +// //{ +// // // If there is no response and no error, it is an unexpected error. +// // _errorType = "error"; +// //} + +// //if (_errorType != null) +// //{ +// // finalTags.Add(ErrorTypeKey, _errorType); +// // _activity?.SetTag(ErrorTypeKey, _errorType); +// // _activity?.SetStatus(ActivityStatusCode.Error, _exception?.Message); +// //} + +// //if (_response == null) +// //{ +// // s_duration.Record(_duration.Elapsed.TotalSeconds, finalTags); +// // return; +// //} + +// //if (!string.IsNullOrEmpty(_response.Model)) +// //{ +// // finalTags.Add(GenAiResponseModelKey, _response.Model); +// // _activity?.SetTag(GenAiResponseModelKey, _response.Model); +// //} + +// //if (!string.IsNullOrEmpty(_response.Version)) +// //{ +// // finalTags.Add(GenAiAgentVersion, _response.Version); +// // _activity?.SetTag(GenAiAgentVersion, _response.Version); +// //} + +// //if (_response.PromptTokens.HasValue) +// //{ +// // finalTags.Add(GenAiUsageInputTokensKey, _response.PromptTokens); +// // _activity?.SetTag(GenAiUsageInputTokensKey, _response.PromptTokens); +// //} + +// //if (_response.CompletionTokens.HasValue) +// //{ +// // finalTags.Add(GenAiUsageOutputTokensKey, _response.CompletionTokens); +// // _activity?.SetTag(GenAiUsageOutputTokensKey, _response.CompletionTokens); +// //} + +// //SetTagMaybe(GenAiAgentIdKey, _response.AgentId); +// //SetTagMaybe(GenAiThreadIdKey, _response.ThreadId); +// //SetTagMaybe(GenAiMessageIdKey, _response.MessageId); +// //SetTagMaybe(GenAiRunIdKey, _response.RunId); +// //SetTagMaybe(GenAiRunStatusKey, _response.RunStatus); + +// //// Record input tokens +// //if (_response.PromptTokens.HasValue) +// //{ +// // TagList input_tags = finalTags; +// // input_tags.Add(GenAiUsageInputTokensKey, "input"); +// // s_tokens.Record(_response.PromptTokens.Value, input_tags); +// //} +// //// Record output tokens +// //if (_response.CompletionTokens.HasValue) +// //{ +// // TagList output_tags = finalTags; +// // output_tags.Add(GenAiUsageOutputTokensKey, "output"); +// // s_tokens.Record(_response.CompletionTokens.Value, output_tags); +// //} +// } + +// public void Dispose() +// { +// // check if the scope has already ended +// if (s_enableTelemetry && Interlocked.Exchange(ref _hasEnded, 1) == 0) +// { +// //_response ??= _buffer?.ToResponse(); +// End(); +// _activity?.Dispose(); +// } +// } + +// private static bool IsResponseValid(RecordedResponse response) +// { +// return response != null;// && response.Id != null && response.FinishReasons != null; +// } + +// /// +// /// Set the tag on the activity, if the tag is present. +// /// +// /// +// /// The name of tag to set. +// /// Nullable value to be set. +// private void SetTagMaybe(string name, T? value) where T : struct +// { +// if (value.HasValue) +// { +// _activity?.SetTag(name, value.Value); +// } +// } + +// private void SetTagMaybe(string name, string value) +// { +// if (!string.IsNullOrEmpty(value)) +// { +// _activity?.SetTag(name, value); +// } +// } + +// internal static void ResetEnvironmentForTests() +// { +// s_traceContent = AppContextSwitchHelper.GetConfigValue(TraceContentsSwitch, TraceContentsEnvironmentVariable); +// s_enableTelemetry = AppContextSwitchHelper.GetConfigValue(EnableOpenTelemetrySwitch, EnableOpenTelemetryEnvironmentVariable); +// } +//} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/src/Telemetry/RecordedResponse.cs b/sdk/ai/Azure.AI.Projects.OpenAI/src/Telemetry/RecordedResponse.cs new file mode 100644 index 000000000000..c22dba7855d6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/src/Telemetry/RecordedResponse.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +//using System.Collections.Generic; + +//namespace Azure.AI.Projects.OpenAI.Telemetry; + +#nullable enable +//internal class RecordedResponse +//{ +// public string? AgentId { get; set; } +// public string? ThreadId { get; set; } +// public string? MessageId { get; set; } +// public string? RunId { get; set; } + +// public bool Stream { get; set; } +// public string? Model { get; set; } +// public string? RunStatus { get; set; } +// public string? Id { get; set; } +// public string? Version { get; set; } +// public string?[]? FinishReasons { get; set; } +// public long? CompletionTokens { get; set; } +// public long? PromptTokens { get; set; } +// public object[]? Choices { get; set; } +// //public List? Messages { get; set; } +// //public List? RunSteps { get; set; } + +// //public ThreadRun? LastRun { get; set; } +// //public PersistentThreadMessage? LastMessage { get; set; } + +// //public List? StreamingMessages { get; set; } = null; + +// private bool _recordContent = false; + +// public RecordedResponse(bool recordContent) +// { +// _recordContent = recordContent; +// Stream = false; +// } + +// //internal void AddStreamingMessage(StreamingMessage message) +// //{ +// // if (StreamingMessages == null) +// // { +// // StreamingMessages = new List(); +// // } +// // if (message != null) +// // { +// // StreamingMessages.Add(message); +// // // Optionally: emit/log/trace here +// // } +// //} +//} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/Azure.AI.Projects.OpenAI.Tests.csproj b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Azure.AI.Projects.OpenAI.Tests.csproj new file mode 100644 index 000000000000..5636f2efe1a6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Azure.AI.Projects.OpenAI.Tests.csproj @@ -0,0 +1,34 @@ + + + $(RequiredTargetFrameworks) + + $(NoWarn);CS1591 + + $(NoWarn);OPENAI001;SCME0001; + + + + + preview + true + + + + + + + + + + + + + + + + + <_Parameter1>SourcePath + <_Parameter2>$(MSBuildProjectDirectory) + + + \ No newline at end of file diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/ConversationsTests.cs b/sdk/ai/Azure.AI.Projects.OpenAI/tests/ConversationsTests.cs new file mode 100644 index 000000000000..6e08407e748b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/ConversationsTests.cs @@ -0,0 +1,188 @@ +// 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.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Azure.AI.Projects.OpenAI; +using Microsoft.ClientModel.TestFramework; +using NUnit.Framework; +using OpenAI; +using OpenAI.Files; +using OpenAI.Responses; +using OpenAI.VectorStores; + +namespace Azure.AI.Projects.OpenAI.Tests; + +/// +/// Many of these tests are adapted from https://github.com/openai/openai-dotnet/tree/main/tests/Responses. +/// +public class ConversationsTests : ProjectsOpenAITestBase +{ + public ConversationsTests(bool isAsync) : base(isAsync) + { + } + + [RecordedTest] + public async Task ConversationOperationsWork() + { + ProjectOpenAIClient client = GetTestProjectOpenAIClient(); + ProjectConversation conversation = await client.Conversations.CreateProjectConversationAsync( + new ProjectConversationCreationOptions() + { + Items = + { + ResponseItem.CreateUserMessageItem("hello, world"), + ResponseItem.CreateAssistantMessageItem("hi there, user"), + ResponseItem.CreateFunctionCallItem("call_abcd1234", "some_function", BinaryData.FromString("{}")), + ResponseItem.CreateFunctionCallOutputItem("call_abcd1234", "some_function_output") + }, + }); + + ProjectConversation retrievedConversation = await client.Conversations.GetProjectConversationAsync(conversation.Id); + Assert.That(retrievedConversation.Id, Is.EqualTo(conversation.Id)); + + retrievedConversation = null; + await foreach (ProjectConversation listedConversation in client.Conversations.GetProjectConversationsAsync(limit: 10)) + { + if (listedConversation.Id == conversation.Id) + { + retrievedConversation = listedConversation; + break; + } + } + Assert.That(retrievedConversation, Is.Not.Null); + + List items = []; + await foreach (AgentResponseItem item in client.Conversations.GetProjectConversationItemsAsync(conversation.Id)) + { + items.Add(item); + } + + Assert.That(items, Has.Count.EqualTo(4)); + Assert.That(items.First().AsOpenAIResponseItem(), Is.InstanceOf()); + Assert.That(items.Last().AsOpenAIResponseItem(), Is.InstanceOf()); + + items.Clear(); + await foreach (AgentResponseItem item in client.Conversations.GetProjectConversationItemsAsync(conversation.Id, order: "asc")) + { + items.Add(item); + } + + Assert.That(items, Has.Count.EqualTo(4)); + Assert.That(items.First().AsOpenAIResponseItem(), Is.InstanceOf()); + Assert.That(items.Last().AsOpenAIResponseItem(), Is.InstanceOf()); + + items.Clear(); + await foreach (AgentResponseItem item in client.Conversations.GetProjectConversationItemsAsync(conversation.Id, itemKind: AgentResponseItemKind.Message)) + { + items.Add(item); + } + + Assert.That(items, Has.Count.EqualTo(2)); + Assert.That(items.All(item => item.AsOpenAIResponseItem() as MessageResponseItem is not null), Is.True); + + AgentResponseItem retrievedItem = await client.Conversations.GetProjectConversationItemAsync(conversation.Id, items.Last().Id); + Assert.That(retrievedItem.Id, Is.EqualTo(items.Last().Id)); + + await client.Conversations.DeleteConversationAsync(conversation.Id); + Assert.ThrowsAsync(async () => await client.Conversations.GetProjectConversationAsync(conversation.Id)); + + int conversationsChecked = 0; + + await foreach (ProjectConversation listedConversation in client.Conversations.GetProjectConversationsAsync(limit: 10)) + { + if (listedConversation.Id == conversation.Id) + { + Assert.Fail($"Found listed conversation that should be deleted: {listedConversation.Id}"); + } + if (conversationsChecked++ >= 20) + { + // Good enough + break; + } + } + } + + [RecordedTest] + public async Task ConversationItemPaginationWorks() + { + ProjectOpenAIClient client = GetTestProjectOpenAIClient(); + + // Create a conversation + ProjectConversation conversation = await client.Conversations.CreateProjectConversationAsync(); + Assert.That(conversation?.Id, Does.StartWith("conv_")); + + // Create 40 messages for the conversation + List messagesToAdd = new(); + for (int i = 1; i <= 40; i++) + { + messagesToAdd.Add(ResponseItem.CreateUserMessageItem($"Message {i}")); + } + + // Trying to add all 40 at once should fail + ClientResultException exceptionFromOperation = Assert.ThrowsAsync(async () => _ = await client.Conversations.CreateProjectConversationItemsAsync(conversation.Id, messagesToAdd)); + Assert.That(exceptionFromOperation.GetRawResponse().Content.ToString(), Does.Contain("20 items")); + + List firstHalfMessages = []; + for (int i = 0; i < 20; i++) + { + firstHalfMessages.Add(messagesToAdd[i]); + } + List secondHalfMessages = []; + for (int i = 20; i < messagesToAdd.Count; i++) + { + secondHalfMessages.Add(messagesToAdd[i]); + } + + ReadOnlyCollection createdItems = await client.Conversations.CreateProjectConversationItemsAsync( + conversation.Id, + firstHalfMessages); + Assert.That(createdItems, Has.Count.EqualTo(20)); + createdItems = await client.Conversations.CreateProjectConversationItemsAsync(conversation.Id, secondHalfMessages); + Assert.That(createdItems, Has.Count.EqualTo(20)); + + // Test ascending order traversal + List ascendingItems = []; + await foreach (AgentResponseItem item in client.Conversations.GetProjectConversationItemsAsync( + conversation.Id, + limit: 5, + order: "asc")) + { + ascendingItems.Add(item); + } + Assert.That(ascendingItems, Has.Count.EqualTo(40)); + + // Test descending order traversal + List descendingItems = []; + await foreach (AgentResponseItem item in client.Conversations.GetProjectConversationItemsAsync( + conversation.Id, + limit: 5, + order: "desc")) + { + descendingItems.Add(item); + } + Assert.That(descendingItems, Has.Count.EqualTo(40)); + + // Verify that ascending and descending lists contain the same items but in reverse order + descendingItems.Reverse(); + Assert.That(ascendingItems.Count, Is.EqualTo(descendingItems.Count)); + for (int i = 0; i < ascendingItems.Count; i++) + { + Assert.That(ascendingItems[i].Id, Is.EqualTo(descendingItems[i].Id), + $"Item at position {i} should be the same in both orderings"); + } + + // Verify that we can collect all items consistently + List allItems = []; + await foreach (AgentResponseItem item in client.Conversations.GetProjectConversationItemsAsync(conversation.Id)) + { + allItems.Add(item); + } + Assert.That(allItems, Has.Count.EqualTo(40)); + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/OtherOpenAIParityTests.cs b/sdk/ai/Azure.AI.Projects.OpenAI/tests/OtherOpenAIParityTests.cs new file mode 100644 index 000000000000..120761e1a461 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/OtherOpenAIParityTests.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +using System; +using System.ClientModel; +using System.Threading.Tasks; +using Microsoft.ClientModel.TestFramework; +using NUnit.Framework; +using OpenAI; +using OpenAI.Files; + +namespace Azure.AI.Projects.OpenAI.Tests; + +public class OtherOpenAIParityTests : ProjectsOpenAITestBase +{ + public OtherOpenAIParityTests(bool isAsync) : base(isAsync) + { + } + + [RecordedTest] + [TestCase(OpenAIClientMode.UseExternalOpenAI, "assistants")] + [TestCase(OpenAIClientMode.UseExternalOpenAI, "fine-tune")] + [TestCase(OpenAIClientMode.UseFDPOpenAI, "assistants")] + [TestCase(OpenAIClientMode.UseFDPOpenAI, "fine-tune")] + public async Task FileUploadWorks(OpenAIClientMode clientMode, string rawPurpose) + { + OpenAIClient openAIClient = GetTestOpenAIClient(clientMode); + OpenAIFileClient fileClient = openAIClient.GetOpenAIFileClient(); + + (string filename, string rawFileData) = rawPurpose switch + { + "assistants" => ("test_data_delete_me.txt", "hello, world"), + "fine-tune" => ("test_data_delete_me.jsonl", @"{""messages"": [{""role"": ""system"", ""content"": """"}]}"), + _ => throw new NotImplementedException() + }; + + OpenAIFile newFile = await fileClient.UploadFileAsync(BinaryData.FromString(rawFileData), filename, rawPurpose); + Assert.That(newFile.SizeInBytesLong, Is.GreaterThan(0)); +#pragma warning disable CS0618 // Status is obsolete + Assert.That(newFile.Status, Is.EqualTo(FileStatus.Processed)); +#pragma warning restore + if (rawPurpose == "fine-tune" && clientMode == OpenAIClientMode.UseFDPOpenAI) + { + Assert.That(newFile.GetAzureFileStatus(), Is.EqualTo("pending")); + } + + OpenAIFile retrievedFile = await fileClient.GetFileAsync(newFile.Id); +#pragma warning disable CS0618 // Status is obsolete + Assert.That(retrievedFile.Status, Is.EqualTo(newFile.Status).Or.EqualTo(FileStatus.Uploaded)); +#pragma warning restore + + if (rawPurpose == "fine-tune" && clientMode == OpenAIClientMode.UseFDPOpenAI) + { + Assert.That(retrievedFile.GetAzureFileStatus(), Is.EqualTo(newFile.GetAzureFileStatus()).Or.EqualTo("processed")); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/ProjectsOpenAITestBase.cs b/sdk/ai/Azure.AI.Projects.OpenAI/tests/ProjectsOpenAITestBase.cs new file mode 100644 index 000000000000..bcf1d6535ef3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/ProjectsOpenAITestBase.cs @@ -0,0 +1,266 @@ +// 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.IO; +using System.Linq; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +using Azure.AI.Projects; +using Azure.AI.Projects.OpenAI; +using Azure.Identity; +using Microsoft.ClientModel.TestFramework; +using NUnit.Framework; +using OpenAI; +using OpenAI.Responses; + +namespace Azure.AI.Projects.OpenAI.Tests; + +[LiveParallelizable(ParallelScope.All)] +public class ProjectsOpenAITestBase : RecordedTestBase +{ + public enum OpenAIClientMode + { + UseExternalOpenAI, + UseFDPOpenAI + } + + private static RecordedTestMode? GetRecordedTestMode() => Environment.GetEnvironmentVariable("AZURE_TEST_MODE") switch + { + "Playback" => RecordedTestMode.Playback, + "Live" => RecordedTestMode.Live, + "Record" => RecordedTestMode.Record, + _ => null + }; + + public ProjectsOpenAITestBase(bool isAsync) : this(isAsync, testMode: GetRecordedTestMode()) { } + + public ProjectsOpenAITestBase(bool isAsync, RecordedTestMode? testMode = null) : base(isAsync, testMode) + { + } + + protected AIProjectClientOptions CreateTestProjectClientOptions(bool instrument = true) + => GetConfiguredOptions(new AIProjectClientOptions(), instrument); + + protected T CreateTestOpenAIClientOptions(Uri endpoint = null, bool instrument = true) + where T : OpenAIClientOptions + { + T options = typeof(T).Name switch + { + nameof(OpenAIClientOptions) => (T)new OpenAIClientOptions(), + nameof(ProjectOpenAIClientOptions) => (T)(object)new ProjectOpenAIClientOptions(), + nameof(ProjectResponsesClientOptions) => (T)(object)new ProjectResponsesClientOptions(), + _ => throw new NotImplementedException() + }; + options.Endpoint = endpoint; + return GetConfiguredOptions(options, instrument); + } + + private T GetConfiguredOptions(T options, bool instrument) + where T : ClientPipelineOptions + { + options.AddPolicy(GetDumpPolicy(), PipelinePosition.BeforeTransport); + options.AddPolicy( + new TestPipelinePolicy(message => + { + if (Mode == RecordedTestMode.Playback) + { + // TODO: ...why!? + message.Request.Headers.Set("Authorization", "Sanitized"); + } + }), + PipelinePosition.PerCall); + + return instrument ? InstrumentClientOptions(options) : options; + } + + protected AIProjectClient GetTestProjectClient() + { + AIProjectClientOptions options = CreateTestProjectClientOptions(); + AIProjectClient baseClient = new(new Uri(TestEnvironment.PROJECT_ENDPOINT), GetTestAuthenticationProvider(), options); + return CreateProxyFromClient(baseClient); + } + + protected ProjectOpenAIClient GetTestProjectOpenAIClient(bool endpointInConstructor = true, bool endpointInOptions = false) + { + ProjectOpenAIClientOptions clientOptions = CreateTestOpenAIClientOptions( + endpoint: endpointInOptions ? new Uri($"{TestEnvironment.PROJECT_ENDPOINT}/openai") : null); + + return CreateProxyFromClient(endpointInConstructor + ? new ProjectOpenAIClient(new Uri(TestEnvironment.PROJECT_ENDPOINT), GetTestAuthenticationProvider(), clientOptions) + : new ProjectOpenAIClient(GetTestAuthenticationPolicy(), clientOptions)); + } + + protected ProjectResponsesClient GetTestProjectResponsesClient(bool endpointInConstructor = true, bool endpointInOptions = false, string defaultAgentName = null, string defaultModelName = null, string defaultConversationId = null) + { + ProjectResponsesClientOptions clientOptions = CreateTestOpenAIClientOptions( + endpoint: endpointInOptions ? new Uri($"{TestEnvironment.PROJECT_ENDPOINT}/openai") : null); + + AgentReference defaultAgent = null; + if (defaultAgentName is not null) + { + defaultAgent = new(defaultAgentName); + } + else if (defaultModelName is not null) + { + defaultAgent = new($"model:{defaultModelName}"); + } + + return CreateProxyFromClient(endpointInConstructor + ? new ProjectResponsesClient(new Uri(TestEnvironment.PROJECT_ENDPOINT), GetTestAuthenticationProvider(), defaultAgent, defaultConversationId, clientOptions) + : new ProjectResponsesClient(GetTestAuthenticationProvider(), clientOptions)); + } + + protected OpenAIClient GetTestBaseOpenAIClient(Uri overrideEndpoint = null) + { + OpenAIClientOptions options = CreateTestOpenAIClientOptions(overrideEndpoint); + + return CreateProxyFromClient( + new OpenAIClient( + new ApiKeyCredential(TestEnvironment.PARITY_OPENAI_API_KEY), + options)); + } + + protected OpenAIResponseClient GetTestBaseResponsesClient(Uri overrideEndpoint = null, string overrideModel = null) + { + OpenAIClientOptions options = CreateTestOpenAIClientOptions(overrideEndpoint); + + return CreateProxyFromClient( + new OpenAIResponseClient( + overrideModel ?? TestEnvironment.MODELDEPLOYMENTNAME, + new ApiKeyCredential(TestEnvironment.PARITY_OPENAI_API_KEY), + options)); + } + + protected OpenAIClient GetTestOpenAIClient(OpenAIClientMode clientMode) + { + return clientMode switch + { + OpenAIClientMode.UseFDPOpenAI => GetTestProjectOpenAIClient(), + OpenAIClientMode.UseExternalOpenAI => GetTestBaseOpenAIClient(), + _ => throw new NotImplementedException() + }; + } + + protected OpenAIResponseClient GetTestResponsesClient(OpenAIClientMode clientMode, string overrideModel = null) + { + return clientMode switch + { + OpenAIClientMode.UseFDPOpenAI => GetTestProjectResponsesClient(defaultModelName: overrideModel), + OpenAIClientMode.UseExternalOpenAI => GetTestBaseResponsesClient(overrideModel: overrideModel), + _ => throw new NotImplementedException(), + }; + } + + private AuthenticationTokenProvider GetTestAuthenticationProvider() + { + // For local testing if you are using non default account + // add USE_CLI_CREDENTIAL into the .runsettings and set it to true, + // also provide the PATH variable. + // This path should allow launching az command. + if (Mode != RecordedTestMode.Playback && bool.TryParse(Environment.GetEnvironmentVariable("USE_CLI_CREDENTIAL"), out bool cliValue) && cliValue) + { + return new AzureCliCredential(); + } + return TestEnvironment.Credential; + } + + private AuthenticationPolicy GetTestAuthenticationPolicy() => new BearerTokenPolicy(GetTestAuthenticationProvider(), "https://ai.azure.com/.default"); + + protected async Task WaitForRun(OpenAIResponseClient responses, OpenAIResponse response, int waitTime=500) + { + while (response.Status != ResponseStatus.Incomplete && response.Status != ResponseStatus.Failed && response.Status != ResponseStatus.Completed) + { + if (Mode != RecordedTestMode.Playback) + await Task.Delay(TimeSpan.FromMilliseconds(waitTime)); + response = await responses.GetResponseAsync(responseId: response.Id); + } + return response; + } + + protected void IgnoreSampleMayBe() + { + if (Mode != RecordedTestMode.Live) + { + Assert.Ignore("Samples represented as tests only for validation of compilation."); + } + } + + #region ToolHelper + + protected static string GetCityNicknameForTest(string location) => location switch + { + "Seattle, WA" => "The Emerald City", + _ => throw new NotImplementedException(), + }; + + #endregion + #region Cleanup + + [TearDown] + public virtual void Cleanup() + { + } + #endregion + + #region Debug Method + internal static PipelinePolicy GetDumpPolicy() + { + return new TestPipelinePolicy((message) => + { + if (message.Request is not null && message.Response is null) + { + Console.WriteLine($"--- New request ---"); + IEnumerable headerPairs = message?.Request?.Headers?.Select(header => $"{header.Key}={(header.Key.ToLower().Contains("auth") ? "***" : header.Value)}"); + string headers = string.Join(",", headerPairs); + Console.WriteLine($"Headers: {headers}"); + Console.WriteLine($"{message?.Request?.Method} URI: {message?.Request?.Uri}"); + if (message.Request?.Content != null) + { + string contentType = "Unknown Content Type"; + if (message.Request.Headers?.TryGetValue("Content-Type", out contentType) == true + && contentType == "application/json") + { + using MemoryStream stream = new(); + message.Request.Content.WriteTo(stream, default); + stream.Position = 0; + using StreamReader reader = new(stream); + string requestDump = reader.ReadToEnd(); + stream.Position = 0; + requestDump = Regex.Replace(requestDump, @"""data"":[\\w\\r\\n]*""[^""]*""", @"""data"":""..."""); + Console.WriteLine(requestDump); + } + else + { + string length = message.Request.Content.TryComputeLength(out long numberLength) + ? $"{numberLength} bytes" + : "unknown length"; + Console.WriteLine($"<< Non-JSON content: {contentType} >> {length}"); + } + } + } + if (message.Response != null) + { + IEnumerable headerPairs = message?.Response?.Headers?.Select(header => $"{header.Key}={(header.Key.ToLower().Contains("auth") ? "***" : header.Value)}"); + string headers = string.Join(",", headerPairs); + Console.WriteLine($"Response headers: {headers}"); + if (message.BufferResponse) + { + message.Response.BufferContent(); + Console.WriteLine("--- Begin response content ---"); + Console.WriteLine(message.Response.Content?.ToString()); + Console.WriteLine("--- End of response content ---"); + } + else + { + Console.WriteLine("--- Response (unbuffered, content not rendered) ---"); + } + } + }); + } + #endregion +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/ProjectsOpenAITestEnvironment.cs b/sdk/ai/Azure.AI.Projects.OpenAI/tests/ProjectsOpenAITestEnvironment.cs new file mode 100644 index 000000000000..569338d6ce3d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/ProjectsOpenAITestEnvironment.cs @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.ClientModel; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure.Identity; +using Microsoft.ClientModel.TestFramework; + +namespace Azure.AI.Projects.OpenAI.Tests +{ + public class ProjectsOpenAITestEnvironment : TestEnvironment + { + public string PROJECT_ENDPOINT => WrappedGetRecordedVariable("PROJECT_ENDPOINT", isSecret: false); + public string AGENT_NAME => WrappedGetRecordedVariable("AZURE_AI_FOUNDRY_AGENT_NAME", isSecret: false); + public string MODELDEPLOYMENTNAME => WrappedGetRecordedVariable("MODEL_DEPLOYMENT_NAME", isSecret: false); + public string EMBEDDINGMODELDEPLOYMENTNAME => WrappedGetRecordedVariable("EMBEDDING_MODEL_DEPLOYMENT_NAME", isSecret: false); + public string INGRESS_SUBDOMAIN_SUFFIX => WrappedGetRecordedVariable("INGRESS_SUBDOMAIN_SUFFIX", isSecret: false); + public string OPENAI_FILE_ID => WrappedGetRecordedVariable("OPENAI_FILE_ID", isSecret: false ); + public string COMPUTER_SCREENSHOTS => WrappedGetRecordedVariable("COMPUTER_SCREENSHOTS", isSecret: false); + public string IMAGE_GENERATION_DEPLOYMENT_NAME => WrappedGetRecordedVariable("IMAGE_GENERATION_DEPLOYMENT_NAME", isSecret: false); + public string COMPUTER_USE_DEPLOYMENT_NAME => WrappedGetRecordedVariable("COMPUTER_USE_DEPLOYMENT_NAME", isSecret: false); + public string CONTAINER_APP_RESOURCE_ID => WrappedGetRecordedVariable("CONTAINER_APP_RESOURCE_ID", isSecret: false); + public string KNOWN_CONVERSATION_ID => WrappedGetRecordedVariable("KNOWN_CONVERSATION_ID", isSecret: false); + public string PARITY_OPENAI_API_KEY => WrappedGetRecordedVariable("OPENAI_API_KEY"); + + public string WrappedGetRecordedVariable(string key, bool isSecret = true) + { + try + { + return GetRecordedVariable( + key, + options => + { + if (isSecret) + { + options.IsSecret(); + } + }); + } + catch (InvalidOperationException invalidOperationException) + { + if (Mode == RecordedTestMode.Playback) + { + throw new TestRecordingMismatchException($"Failed to retrieve recorded variable '{key}' during playback.", invalidOperationException); + } + throw; + } + } + + public override Dictionary ParseEnvironmentFile() + { + return new(); + } + + public override Task WaitForEnvironmentAsync() + { + return Task.CompletedTask; + } + + public override AuthenticationTokenProvider Credential => Mode switch + { + RecordedTestMode.Live or RecordedTestMode.Record => new DefaultAzureCredential(), + _ => base.Credential + }; + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/ResponsesParityTests.cs b/sdk/ai/Azure.AI.Projects.OpenAI/tests/ResponsesParityTests.cs new file mode 100644 index 000000000000..982bbedbda48 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/ResponsesParityTests.cs @@ -0,0 +1,520 @@ +// 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.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.ClientModel.TestFramework; +using NUnit.Framework; +using Azure.AI.Projects.OpenAI; +using OpenAI.Files; +using OpenAI.Responses; +using OpenAI.VectorStores; +using OpenAI.Realtime; + +namespace Azure.AI.Projects.OpenAI.Tests; + +/// +/// Many of these tests are adapted from https://github.com/openai/openai-dotnet/tree/main/tests/Responses. +/// +public class ResponsesParityTests : ProjectsOpenAITestBase +{ + public ResponsesParityTests(bool isAsync) : base(isAsync) + { + } + + [RecordedTest] + public async Task FileSearchToolWorks() + { + ProjectOpenAIClient client = GetTestProjectOpenAIClient(); + + OpenAIFile testFile = await client.Files.UploadFileAsync( + BinaryData.FromString(""" + Travis's favorite food is pizza. + """), + "test_favorite_foods.txt", + FileUploadPurpose.Assistants); + // Bug 4755030 + // FileUploadPurpose.UserData); + + //Validate(testFile); + + VectorStore vectorStore = await client.VectorStores.CreateVectorStoreAsync( + new VectorStoreCreationOptions() + { + FileIds = { testFile.Id }, + }); + //Validate(vectorStore); + + OpenAIResponse response = await client.Responses.CreateResponseAsync( + "Using the file search tool, what's Travis's favorite food?", + new ResponseCreationOptions() + { + Model = TestEnvironment.MODELDEPLOYMENTNAME, + Tools = + { + ResponseTool.CreateFileSearchTool(vectorStoreIds: [vectorStore.Id]), + } + }); + Assert.That(response.OutputItems?.Count, Is.GreaterThanOrEqualTo(2)); + FileSearchCallResponseItem fileSearchCall = response.OutputItems.FirstOrDefault(item => item is FileSearchCallResponseItem) as FileSearchCallResponseItem; + Assert.That(fileSearchCall, Is.Not.Null); + Assert.That(fileSearchCall?.Status, Is.EqualTo(FileSearchCallStatus.Completed)); + Assert.That(fileSearchCall?.Queries, Has.Count.GreaterThan(0)); + MessageResponseItem message = response.OutputItems.FirstOrDefault(item => item is MessageResponseItem) as MessageResponseItem; + Assert.That(message, Is.Not.Null); + ResponseContentPart messageContentPart = message.Content?.FirstOrDefault(); + Assert.That(messageContentPart, Is.Not.Null); + Assert.That(messageContentPart.Text, Does.Contain("pizza")); + Assert.That(messageContentPart.OutputTextAnnotations, Is.Not.Null.And.Not.Empty); + FileCitationMessageAnnotation annotation = messageContentPart.OutputTextAnnotations[0] as FileCitationMessageAnnotation; + Assert.That(annotation.FileId, Is.EqualTo(testFile.Id)); + Assert.That(annotation.Index, Is.GreaterThan(0)); + + await foreach (ResponseItem inputItem in client.Responses.GetResponseInputItemsAsync(response.Id)) + { + Console.WriteLine(ModelReaderWriter.Write(inputItem).ToString()); + } + } + + public enum ResponsesClientCreationMethod + { + UseFactory, + UseConstructor + } + + public enum ResponsesClientDefault + { + DefaultAgent, + DefaultModel, + DefaultConversation + } + + [RecordedTest] + [TestCase(ResponsesClientCreationMethod.UseFactory, ResponsesClientDefault.DefaultAgent)] + [TestCase(ResponsesClientCreationMethod.UseFactory, ResponsesClientDefault.DefaultAgent, ResponsesClientDefault.DefaultConversation)] + [TestCase(ResponsesClientCreationMethod.UseFactory, ResponsesClientDefault.DefaultModel)] + [TestCase(ResponsesClientCreationMethod.UseFactory, ResponsesClientDefault.DefaultModel, ResponsesClientDefault.DefaultConversation)] + [TestCase(ResponsesClientCreationMethod.UseConstructor, ResponsesClientDefault.DefaultAgent)] + [TestCase(ResponsesClientCreationMethod.UseConstructor, ResponsesClientDefault.DefaultAgent, ResponsesClientDefault.DefaultConversation)] + [TestCase(ResponsesClientCreationMethod.UseConstructor, ResponsesClientDefault.DefaultModel)] + [TestCase(ResponsesClientCreationMethod.UseConstructor, ResponsesClientDefault.DefaultModel, ResponsesClientDefault.DefaultConversation)] + public async Task ClientDefaultsWork(ResponsesClientCreationMethod creationMethod, params ResponsesClientDefault[] defaults) + { + bool isDefaultAgent = defaults?.Any(defaultItem => defaultItem == ResponsesClientDefault.DefaultAgent) == true; + bool isDefaultModel = defaults?.Any(defaultItem => defaultItem == ResponsesClientDefault.DefaultModel) == true; + bool isDefaultConversation = defaults?.Any(defaultItem => defaultItem == ResponsesClientDefault.DefaultConversation) == true; + + ProjectResponsesClient responsesClient = null; + if (creationMethod == ResponsesClientCreationMethod.UseFactory) + { + ProjectOpenAIClient openAIClient = GetTestProjectOpenAIClient(); + if (isDefaultModel && !isDefaultAgent) + { + responsesClient = openAIClient.GetProjectResponsesClientForModel( + TestEnvironment.MODELDEPLOYMENTNAME, + isDefaultConversation ? TestEnvironment.KNOWN_CONVERSATION_ID : null); + } + else if (isDefaultAgent && !isDefaultModel) + { + responsesClient = openAIClient.GetProjectResponsesClientForAgent( + TestEnvironment.AGENT_NAME, + isDefaultConversation ? TestEnvironment.KNOWN_CONVERSATION_ID : null); + } + else if (!isDefaultAgent && !isDefaultModel) + { + responsesClient = openAIClient.GetProjectResponsesClient(); + } + else if (isDefaultAgent && isDefaultModel) + { + throw new InvalidOperationException(); + } + responsesClient = CreateProxyFromClient(responsesClient); + } + else + { + responsesClient = GetTestProjectResponsesClient( + defaultAgentName: isDefaultAgent ? TestEnvironment.AGENT_NAME : null, + defaultModelName: isDefaultModel ? TestEnvironment.MODELDEPLOYMENTNAME : null, + defaultConversationId: isDefaultConversation ? TestEnvironment.KNOWN_CONVERSATION_ID : null); + } + + OpenAIResponse response = await responsesClient.CreateResponseAsync("Hello, agent or model!"); + + Assert.That( + response?.Agent?.Name, + isDefaultAgent ? Is.EqualTo(TestEnvironment.AGENT_NAME) : Is.Null); + Assert.That( + response?.AgentConversationId, + isDefaultConversation ? Is.EqualTo(TestEnvironment.KNOWN_CONVERSATION_ID) : Is.Null); + if (isDefaultModel) + { + Assert.That(response?.Model, Does.StartWith(TestEnvironment.MODELDEPLOYMENTNAME)); + } + } + + [RecordedTest] + public async Task CodeInterpreterToolWorks() + { + ProjectOpenAIClient client = GetTestProjectOpenAIClient(); + + ResponseTool codeInterpreterTool + = ResponseTool.CreateCodeInterpreterTool( + new CodeInterpreterToolContainer( + CodeInterpreterToolContainerConfiguration.CreateAutomaticContainerConfiguration([]))); + ResponseCreationOptions responseOptions = new() + { + Model = TestEnvironment.MODELDEPLOYMENTNAME, + Tools = { codeInterpreterTool }, + }; + + OpenAIResponse response = await client.Responses.CreateResponseAsync( + "Calculate the factorial of 5 using Python code.", + responseOptions); + + Assert.That(response, Is.Not.Null); + Assert.That(response.OutputItems, Has.Count.GreaterThanOrEqualTo(2)); + Assert.That(response.OutputItems[response.OutputItems.Count - 2], Is.InstanceOf()); + Assert.That(response.OutputItems[response.OutputItems.Count - 1], Is.InstanceOf()); + + MessageResponseItem message = (MessageResponseItem)response.OutputItems[response.OutputItems.Count - 1]; + Assert.That(message.Content, Has.Count.GreaterThan(0)); + Assert.That(message.Content[0].Kind, Is.EqualTo(ResponseContentPartKind.OutputText)); + Assert.That(message.Content[0].Text, Is.Not.Null.And.Not.Empty); + + // Basic validation that the response was created successfully + Assert.That(response.Id, Is.Not.Null.And.Not.Empty); + + Assert.That(response.Tools.FirstOrDefault(), Is.TypeOf()); + } + + [RecordedTest] + public async Task FunctionToolWorks() + { + ProjectOpenAIClient client = GetTestProjectOpenAIClient(); + + FunctionTool functionTool = ResponseTool.CreateFunctionTool( + "get_user_favorite_food", + BinaryData.FromString("{}"), + strictModeEnabled: false, + functionDescription: "Gets the favorite food of the user"); + + ResponseCreationOptions responseCreationOptions = new() + { + Model = TestEnvironment.MODELDEPLOYMENTNAME, + Tools = { functionTool }, + }; + + OpenAIResponse response = await client.Responses.CreateResponseAsync( + [ResponseItem.CreateUserMessageItem("What's my favorite food?")], + responseCreationOptions); + Assert.That(response.Id, Does.StartWith("resp_")); + Assert.That(response.OutputItems.Count, Is.GreaterThanOrEqualTo(1)); + + FunctionCallResponseItem functionCallResponseItem = response.OutputItems.Last() as FunctionCallResponseItem; + Assert.That(functionCallResponseItem?.FunctionName, Is.EqualTo("get_user_favorite_food")); + Assert.That(functionCallResponseItem?.CallId, Is.Not.Null.And.Not.Empty); + Assert.That(functionCallResponseItem?.Id, Is.Not.Null.And.Not.Empty); + + // previous_response_id not yet supported + //responseCreationOptions.PreviousResponseId = response.Id; + //response = await client.Responses.CreateResponseAsync( + // [ResponseItem.CreateFunctionCallOutputItem(functionCallResponseItem.CallId, "pizza")], + // responseCreationOptions); + + //Assert.That(response.OutputItems.Count, Is.GreaterThanOrEqualTo(1)); + //MessageResponseItem messageResponseItem = response.OutputItems.Last() as MessageResponseItem; + //Assert.That(response.GetOutputText().ToLower(), Does.Contain("pizza")); + } + + [RecordedTest] + public async Task StreamingResponsesWork() + { + ProjectOpenAIClient client = GetTestProjectOpenAIClient(); + ProjectResponsesClient responseClient = client.GetProjectResponsesClientForModel(TestEnvironment.MODELDEPLOYMENTNAME); + + List streamedUpdates = []; + await foreach (StreamingResponseUpdate streamedUpdate in responseClient.CreateResponseStreamingAsync("Hello, model!")) + { + Assert.That(streamedUpdate.SequenceNumber, Is.EqualTo(streamedUpdates.Count)); + streamedUpdates.Add(streamedUpdate); + } + + Assert.That(streamedUpdates.Count, Is.GreaterThan(2)); + StreamingResponseCreatedUpdate createdUpdate = streamedUpdates.First() as StreamingResponseCreatedUpdate; + Assert.That(createdUpdate?.Response?.Id, Is.Not.Null); + + StreamingResponseCompletedUpdate completedUpdate = streamedUpdates.Last() as StreamingResponseCompletedUpdate; + Assert.That(completedUpdate?.Response?.Id, Is.EqualTo(createdUpdate.Response.Id)); + + MessageResponseItem messageItem = completedUpdate.Response.OutputItems?.LastOrDefault() as MessageResponseItem; + Assert.That(messageItem?.Role, Is.EqualTo(MessageRole.Assistant)); + + StringBuilder deltaBuilder = new(); + foreach (StreamingResponseUpdate streamedUpdate in streamedUpdates) + { + if (streamedUpdate is StreamingResponseOutputTextDeltaUpdate textDeltaUpdate) + { + deltaBuilder.Append(textDeltaUpdate.Delta); + } + } + Assert.That(deltaBuilder.ToString(), Is.EqualTo(completedUpdate.Response.GetOutputText())); + } + + [RecordedTest] + public async Task GetResponseWorks() + { + ProjectOpenAIClient client = GetTestProjectOpenAIClient(); + OpenAIResponseClient responseClient = client.GetProjectResponsesClientForModel(TestEnvironment.MODELDEPLOYMENTNAME); + + OpenAIResponse response = await responseClient.CreateResponseAsync([ResponseItem.CreateUserMessageItem("Hello, model!")]); + Assert.That(response?.Id, Is.Not.Null.And.Not.Empty); + + OpenAIResponse retrievedResponse = await client.Responses.GetResponseAsync(response.Id); + Assert.That(retrievedResponse.Status, Is.EqualTo(ResponseStatus.Completed)); + Assert.That(retrievedResponse.Id, Is.EqualTo(response.Id)); + } + + [RecordedTest] + public async Task ResponseBackgroundModeWorks() + { + ProjectOpenAIClient client = GetTestProjectOpenAIClient(); + + OpenAIResponse response = await client.Responses.CreateResponseAsync( + [ResponseItem.CreateUserMessageItem("Hello again, model")], + new ResponseCreationOptions() + { + Model = TestEnvironment.MODELDEPLOYMENTNAME, + BackgroundModeEnabled = true, + }); + Assert.That(response?.Id, Does.StartWith("resp_")); + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Queued).Or.EqualTo(ResponseStatus.InProgress)); + + TimeSpan pollingDelay = Mode == RecordedTestMode.Playback ? TimeSpan.FromMilliseconds(5) : TimeSpan.FromMilliseconds(500); + + for (int i = 0; (response.Status == ResponseStatus.Queued || response.Status == ResponseStatus.InProgress) && i < 20; i++) + { + await Task.Delay(pollingDelay); + response = await client.Responses.GetResponseAsync(response.Id); + } + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + } + + [RecordedTest] + [TestCase(OpenAIClientMode.UseFDPOpenAI, Ignore = "Issue 4823408")] + [TestCase(OpenAIClientMode.UseExternalOpenAI)] + public async Task GetResponseStreamingWorks(OpenAIClientMode clientMode) + { + OpenAIResponseClient client = GetTestResponsesClient(clientMode); + + OpenAIResponse startedResponse = null; + await foreach (StreamingResponseUpdate update + in client.CreateResponseStreamingAsync( + "Hello, model!", + new ResponseCreationOptions() + { + Model = TestEnvironment.MODELDEPLOYMENTNAME, + BackgroundModeEnabled = true, + })) + { + if (update is StreamingResponseCreatedUpdate createdUpdate) + { + startedResponse = createdUpdate.Response; + break; + } + } + + Assert.That(startedResponse?.Id, Is.Not.Null.And.Not.Empty); + Assert.That(startedResponse.Status, Is.EqualTo(ResponseStatus.Queued).Or.EqualTo(ResponseStatus.InProgress)); + + List streamedUpdates = []; + await foreach (StreamingResponseUpdate responseUpdate in client.GetResponseStreamingAsync(startedResponse.Id)) + { + streamedUpdates.Add(responseUpdate); + } + + Assert.That(streamedUpdates.Count, Is.GreaterThan(2)); + Assert.That(streamedUpdates.First(), Is.InstanceOf()); + Assert.That(streamedUpdates.Last(), Is.InstanceOf()); + } + + [RecordedTest] + public async Task ListingResponsesWorks() + { + ProjectOpenAIClient client = GetTestProjectOpenAIClient(); + + Dictionary firstResponsesById = []; + + await foreach (OpenAIResponse response in client.Responses.GetProjectResponsesAsync()) + { + Assert.That(response.Id, Is.Not.Null.And.Not.Empty); + Assert.That(firstResponsesById.ContainsKey(response.Id), Is.False); + firstResponsesById[response.Id] = response; + + if (firstResponsesById.Count >= 20) + { + break; + } + } + + ProjectConversation newConversation = await client.Conversations.CreateProjectConversationAsync(); + ProjectResponsesClient responsesForNewConversation = client.GetProjectResponsesClientForModel(TestEnvironment.MODELDEPLOYMENTNAME, newConversation.Id); + OpenAIResponse newResponse = await responsesForNewConversation.CreateResponseAsync("Hello, new conversation!"); + + List matchingResponses = []; + + await foreach (OpenAIResponse response in client.Responses.GetProjectResponsesAsync(conversationId: newConversation.Id)) + { + matchingResponses.Add(response); + } + + Assert.That(matchingResponses, Has.Count.EqualTo(1)); + Assert.That(matchingResponses[0].Id, Is.EqualTo(newResponse.Id)); + + // TODO: add validation for agent reference + + Assert.That(firstResponsesById, Is.Not.Empty); + } + + [RecordedTest] + public async Task ResponseDeletionWorks() + { + ProjectOpenAIClient client = GetTestProjectOpenAIClient(); + + OpenAIResponse response = await client.Responses.CreateResponseAsync( + "Hello, model!", + new ResponseCreationOptions() + { + Model = TestEnvironment.MODELDEPLOYMENTNAME + }); + Assert.That(response?.Id, Does.StartWith("resp_")); + + Assert.DoesNotThrowAsync(async () => await client.Responses.GetResponseAsync(response.Id)); + + ResponseDeletionResult deletionResult = await client.Responses.DeleteResponseAsync(response.Id); + Assert.That(deletionResult.Deleted, Is.True); + + Assert.ThrowsAsync(async () => await client.Responses.GetResponseAsync(response.Id)); + } + + [RecordedTest] + public async Task FunctionToolWorksWithConversation() + { + ProjectOpenAIClient client = GetTestProjectOpenAIClient(); + + ProjectConversation conversation = await client.Conversations.CreateProjectConversationAsync(); + Assert.That(conversation.Id, Does.StartWith("conv_")); + + FunctionTool functionTool = ResponseTool.CreateFunctionTool( + "get_user_favorite_food", + BinaryData.FromString("{}"), + strictModeEnabled: false, + functionDescription: "Gets the favorite food of the user"); + + ResponseCreationOptions responseCreationOptions = new() + { + Model = TestEnvironment.MODELDEPLOYMENTNAME, + AgentConversationId = conversation, + Tools = { functionTool }, + }; + + OpenAIResponse response = await client.Responses.CreateResponseAsync( + [ResponseItem.CreateUserMessageItem("What's my favorite food?")], + responseCreationOptions); + Assert.That(response.Id, Does.StartWith("resp_")); + Assert.That(response.OutputItems.Count, Is.GreaterThanOrEqualTo(1)); + + FunctionCallResponseItem functionCallResponseItem = response.OutputItems.Last() as FunctionCallResponseItem; + Assert.That(functionCallResponseItem?.FunctionName, Is.EqualTo("get_user_favorite_food")); + Assert.That(functionCallResponseItem?.CallId, Is.Not.Null.And.Not.Empty); + Assert.That(functionCallResponseItem?.Id, Is.Not.Null.And.Not.Empty); + + response = await client.Responses.CreateResponseAsync( + [ResponseItem.CreateFunctionCallOutputItem(functionCallResponseItem.CallId, "pizza")], + responseCreationOptions); + + Assert.That(response.OutputItems.Count, Is.GreaterThanOrEqualTo(1)); + MessageResponseItem messageResponseItem = response.OutputItems.Last() as MessageResponseItem; + Assert.That(response.GetOutputText().ToLower(), Does.Contain("pizza")); + } + + public enum TestResponseClientInitializationType + { + FromProjectsClient, + FromProjectsOpenAIClientWithConstructorEndpoint, + FromProjectsOpenAIClientWithOptionsEndpoint, + DirectWithProjectEndpoint, + DirectWithOptions, + } + + [RecordedTest] + [TestCase(TestResponseClientInitializationType.FromProjectsClient)] + [TestCase(TestResponseClientInitializationType.FromProjectsOpenAIClientWithConstructorEndpoint)] + [TestCase(TestResponseClientInitializationType.FromProjectsOpenAIClientWithOptionsEndpoint)] + [TestCase(TestResponseClientInitializationType.DirectWithProjectEndpoint)] + [TestCase(TestResponseClientInitializationType.DirectWithOptions)] + public async Task DirectlyInitializedResponsesClientsWork( + TestResponseClientInitializationType clientInitializationType) + { + ProjectResponsesClient responseClient = null; + if (clientInitializationType == TestResponseClientInitializationType.FromProjectsClient) + { + AIProjectClient projectClient = GetTestProjectClient(); + responseClient = projectClient.OpenAI.Responses; + } + else if (clientInitializationType == TestResponseClientInitializationType.FromProjectsOpenAIClientWithConstructorEndpoint) + { + ProjectOpenAIClient openAIClient = GetTestProjectOpenAIClient(endpointInConstructor: true, endpointInOptions: false); + responseClient = openAIClient.Responses; + } + else if (clientInitializationType == TestResponseClientInitializationType.FromProjectsOpenAIClientWithOptionsEndpoint) + { + ProjectOpenAIClient openAIClient = GetTestProjectOpenAIClient(endpointInConstructor: false, endpointInOptions: true); + responseClient = openAIClient.Responses; + } + else if (clientInitializationType == TestResponseClientInitializationType.DirectWithProjectEndpoint) + { + responseClient = GetTestProjectResponsesClient(); + } + else if (clientInitializationType == TestResponseClientInitializationType.DirectWithOptions) + { + responseClient = GetTestProjectResponsesClient(endpointInConstructor: false, endpointInOptions: true); + } + else + { + Assert.Fail($"Unexpected initialization type for test: {clientInitializationType}"); + } + + OpenAIResponse response = await responseClient.CreateResponseAsync( + "Hello, model!", + new ResponseCreationOptions() + { + Model = TestEnvironment.MODELDEPLOYMENTNAME, + }); + Assert.That(response?.Id, Is.Not.Null.And.Not.Empty); + Assert.That(response?.OutputItems, Has.Count.GreaterThan(0)); + } + + [RecordedTest] + [TestCase(OpenAIClientMode.UseExternalOpenAI)] + [TestCase(OpenAIClientMode.UseFDPOpenAI, Ignore = "'none' not yet supported on FDP")] + public async Task ExtensibleReasoningEffortWorks(OpenAIClientMode clientMode) + { + OpenAIResponseClient responseClient = GetTestResponsesClient(clientMode, "gpt-5.1"); + + OpenAIResponse response = await responseClient.CreateResponseAsync( + "Hello, gpt-5.1!", + new ResponseCreationOptions() + { + ReasoningOptions = new() + { + ReasoningEffortLevel = "none", + }, + }); + + Assert.That(response.ReasoningOptions?.ReasoningEffortLevel?.ToString(), Is.EqualTo("none")); + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/ResponsesSmokeTests.cs b/sdk/ai/Azure.AI.Projects.OpenAI/tests/ResponsesSmokeTests.cs new file mode 100644 index 000000000000..3546d73dd265 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/ResponsesSmokeTests.cs @@ -0,0 +1,209 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Linq; +using Microsoft.ClientModel.TestFramework; +using NUnit.Framework; +using OpenAI.Responses; + +namespace Azure.AI.Projects.OpenAI.Tests; + +[Category("Smoke")] +[Parallelizable(ParallelScope.All)] +[SyncOnly] +public class ResponsesSmokeTests : ProjectsOpenAITestBase +{ + public ResponsesSmokeTests(bool isAsync) : base(isAsync) + { + } + + [Test] + public void TestResponseItemExtension() + { + string rawStructuredInputsItem = """ + { + "type": "structured_inputs", + "inputs": { + "hello": "world" + } + } + """; + + ResponseItem item = ModelReaderWriter.Read(BinaryData.FromString(rawStructuredInputsItem)); + Assert.That(item, Is.Not.Null); + + AgentResponseItem agentResponseItem = item.AsAgentResponseItem(); + Assert.That(agentResponseItem, Is.Not.Null); + + ResponseItem revertedResponseItem = agentResponseItem; + Assert.That(revertedResponseItem, Is.Not.Null); + } + + [Test] + public void TestAgentToolSerialization() + { + AgentTool localShellTool = new LocalShellAgentTool(); + BinaryData serializedLocalShellTool = ModelReaderWriter.Write(localShellTool); + Assert.That(serializedLocalShellTool.ToString(), Does.Contain(@"""type"":""local_shell""")); + Assert.That((ResponseTool)localShellTool, Is.InstanceOf()); + ResponseTool deserializedLocalShellTool = ModelReaderWriter.Read(serializedLocalShellTool); + Assert.That(deserializedLocalShellTool, Is.InstanceOf()); + Assert.That(deserializedLocalShellTool.AsAgentTool(), Is.InstanceOf()); + } + + [Test] + public void TestResponseCreationOptionsExtensions() + { + ResponseCreationOptions options = new(); + Assert.That(options.Agent, Is.Null); + Assert.That(options.AgentConversationId, Is.Null); + + options.Agent = new AgentReference("my-agent"); + Assert.That(options.Agent?.Name, Is.EqualTo("my-agent")); + Assert.That(options.Agent?.Version, Is.Null); + + options.Agent = "my-other-agent"; + Assert.That(options.Agent?.Name, Is.EqualTo("my-other-agent")); + Assert.That(options.Agent?.Version, Is.Null); + + options.Agent = new AgentReference("one-more-agent", "42"); + Assert.That(options.Agent?.Name, Is.EqualTo("one-more-agent")); + Assert.That(options.Agent?.Version, Is.EqualTo("42")); + + options.Agent = null; + Assert.That(options.Agent, Is.Null); + + options.AgentConversationId = "conv_abcd1234"; + Assert.That(options.AgentConversationId, Is.EqualTo("conv_abcd1234")); + options.AgentConversationId = null; + Assert.That(options.AgentConversationId, Is.Null); + + Assert.That(options.StructuredInputs, Is.Not.Null); + Assert.That(options.StructuredInputs.Keys, Is.Empty); + Assert.That(options.StructuredInputs?.Keys, Is.Empty); + Assert.That(options.StructuredInputs?.Values, Is.Empty); + Assert.That(ModelReaderWriter.Write(options).ToString(), Does.Not.Contain("structured_inputs")); + + options.StructuredInputs["foo"] = BinaryData.FromString(@"""bar"""); + Assert.That(ModelReaderWriter.Write(options).ToString(), Does.Contain("structured_inputs")); + Assert.That(options.StructuredInputs.ContainsKey("foo"), Is.True); + Assert.That(options.StructuredInputs.ContainsKey("bar"), Is.False); + Assert.That(options.StructuredInputs.Keys, Has.Count.EqualTo(1)); + Assert.That(options.StructuredInputs.Values, Has.Count.EqualTo(1)); + Assert.That(options.StructuredInputs.Keys.First(), Is.EqualTo("foo")); + Assert.That(options.StructuredInputs.Values.First().ToString(), Is.EqualTo(@"""bar""")); + Assert.That(options.StructuredInputs.TryGetValue("foo", out BinaryData fooBytes), Is.True); + Assert.That(fooBytes?.ToString(), Is.EqualTo(@"""bar""")); + Assert.That(options.StructuredInputs.TryGetValue("bar", out BinaryData _), Is.False); + + options.StructuredInputs.Clear(); + Assert.That(options.StructuredInputs, Is.Not.Null); + Assert.That(options.StructuredInputs.Keys, Is.Empty); + Assert.That(options.StructuredInputs?.Keys, Is.Empty); + Assert.That(options.StructuredInputs?.Values, Is.Empty); + + options.StructuredInputs["foo"u8] = BinaryData.FromString(@"""bar"""); + Assert.That(ModelReaderWriter.Write(options).ToString(), Does.Contain("structured_inputs")); + Assert.That(options.StructuredInputs.TryGetValue("foo", out fooBytes), Is.True); + Assert.That(options.StructuredInputs.TryGetValue("bar", out BinaryData _), Is.False); + + options = new() + { + StructuredInputs = + { + ["foo"] = BinaryData.FromString(@"""bar"""), + ["baz.key"] = BinaryData.FromString(@"""quz"""), + } + }; + Assert.That(ModelReaderWriter.Write(options).ToString(), Does.Contain("structured_inputs")); + Assert.That(options.StructuredInputs.ContainsKey("foo"), Is.True); + Assert.That(options.StructuredInputs.ContainsKey("bar"), Is.False); + Assert.That(options.StructuredInputs.ContainsKey("baz.key"), Is.True); + Assert.That(options.StructuredInputs.ContainsKey("quz"), Is.False); + Assert.That(options.StructuredInputs.Keys, Has.Count.EqualTo(2)); + Assert.That(options.StructuredInputs.Values, Has.Count.EqualTo(2)); + Assert.That(options.StructuredInputs.Keys.First(), Is.EqualTo("foo")); + Assert.That(options.StructuredInputs.Keys.Last(), Is.EqualTo("baz.key")); + Assert.That(options.StructuredInputs.Values.First().ToString(), Is.EqualTo(@"""bar""")); + Assert.That(options.StructuredInputs.Values.Last().ToString(), Is.EqualTo(@"""quz""")); + Assert.That(options.StructuredInputs.TryGetValue("foo", out fooBytes), Is.True); + Assert.That(fooBytes?.ToString(), Is.EqualTo(@"""bar""")); + Assert.That(options.StructuredInputs.TryGetValue("bar", out BinaryData _), Is.False); + Assert.That(options.StructuredInputs.TryGetValue("baz.key", out BinaryData bazBytes), Is.True); + Assert.That(bazBytes?.ToString(), Is.EqualTo(@"""quz""")); + + options.StructuredInputs.Remove("foo"); + Assert.That(options.StructuredInputs.ContainsKey("foo"), Is.False); + Assert.That(options.StructuredInputs.ContainsKey("bar"), Is.False); + Assert.That(options.StructuredInputs.ContainsKey("baz.key"), Is.True); + Assert.That(options.StructuredInputs.ContainsKey("quz"), Is.False); + Assert.That(options.StructuredInputs.Keys, Has.Count.EqualTo(1)); + Assert.That(options.StructuredInputs.Values, Has.Count.EqualTo(1)); + Assert.That(options.StructuredInputs.Keys.First(), Is.EqualTo("baz.key")); + Assert.That(options.StructuredInputs.Values.First().ToString(), Is.EqualTo(@"""quz""")); + Assert.That(options.StructuredInputs.TryGetValue("foo", out BinaryData _), Is.False); + Assert.That(options.StructuredInputs.TryGetValue("bar", out BinaryData _), Is.False); + Assert.That(options.StructuredInputs.TryGetValue("baz.key", out bazBytes), Is.True); + Assert.That(bazBytes?.ToString(), Is.EqualTo(@"""quz""")); + + options.StructuredInputs.Add("stringValueKey", "stringValueValue"); + Assert.That(options.StructuredInputs["stringValueKey"].ToString(), Is.EqualTo(@"""stringValueValue""")); + options.StructuredInputs.Add("intValueKey", 42); + Assert.That(int.TryParse(options.StructuredInputs["intValueKey"].ToString(), out int retrievedIntValue), Is.True); + Assert.That(retrievedIntValue, Is.EqualTo(42)); + options.StructuredInputs.Add("boolValueKey", true); + Assert.That(bool.TryParse(options.StructuredInputs["boolValueKey"].ToString(), out bool retrievedBoolValue), Is.True); + Assert.That(retrievedBoolValue, Is.True); + + options.StructuredInputs.SetData(BinaryData.FromString(""" + { + "direct_value_1": "foo", + "direct_value_2": 42 + } + """)); + Assert.That(options.StructuredInputs.Keys, Has.Count.EqualTo(2)); + Assert.That(options.StructuredInputs["direct_value_2"].ToString(), Is.EqualTo("42")); + } + + [Test] + public void ResponsesEndpointsSetCorrectly() + { + Uri mockProjectEndpoint = new("https://microsoft.com/mock/endpoint"); + Uri mockOpenAIEndpoint = new($"{mockProjectEndpoint.AbsoluteUri}/openai"); + AuthenticationTokenProvider mockCredential = new MockCredential(); + AuthenticationPolicy mockAuthPolicy = new BearerTokenPolicy(mockCredential, "https://ai.azure.com/.default"); + + ProjectOpenAIClientOptions GetOptions(Uri endpoint = null) => new() { Endpoint = endpoint }; + + // Not specifying options should use the constructed /openai endpoint from the project Uri + ProjectOpenAIClient client = new(mockProjectEndpoint, new MockCredential()); + Assert.That(client.Endpoint?.AbsoluteUri, Is.EqualTo(mockOpenAIEndpoint)); + client = new(new Uri(mockProjectEndpoint.AbsoluteUri + "/"), mockCredential); + Assert.That(client.Endpoint?.AbsoluteUri, Is.EqualTo(mockOpenAIEndpoint)); + + // Providing no endpoint anywhere should throw + Assert.Throws(() => client = new(mockAuthPolicy, GetOptions())); + + // Supplying in options should use the literal value with no construction + client = new(mockAuthPolicy, GetOptions(mockProjectEndpoint)); + Assert.That(client.Endpoint?.AbsoluteUri, Is.EqualTo(mockProjectEndpoint.AbsoluteUri)); + + // Supplying in both should be OK if they match correctly + client = new(mockProjectEndpoint, mockCredential, GetOptions(mockOpenAIEndpoint)); + Assert.That(client.Endpoint?.AbsoluteUri, Is.EqualTo(mockOpenAIEndpoint)); + + // Supplying in both should throw if they don't match + Assert.Throws(() => client = new(mockProjectEndpoint, mockCredential, GetOptions(mockProjectEndpoint))); + + // Clients retrieved from ProjectOpenAIClient should handle construction + ProjectOpenAIClient openAIClient = new(mockProjectEndpoint, mockCredential); + Assert.That(openAIClient.Responses.Endpoint, Is.EqualTo(mockOpenAIEndpoint)); + Assert.That(openAIClient.GetOpenAIResponseClient("model").Endpoint, Is.EqualTo(mockOpenAIEndpoint)); + Assert.That(openAIClient.GetProjectResponsesClient().Endpoint, Is.EqualTo(mockOpenAIEndpoint)); + Assert.That(openAIClient.GetProjectResponsesClientForModel("model").Endpoint, Is.EqualTo(mockOpenAIEndpoint)); + Assert.That(openAIClient.GetProjectResponsesClientForAgent(new AgentReference("agent")).Endpoint, Is.EqualTo(mockOpenAIEndpoint)); + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Assets/cua_browser_search.png b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Assets/cua_browser_search.png new file mode 100644 index 000000000000..31325a9c3df6 Binary files /dev/null and b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Assets/cua_browser_search.png differ diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Assets/cua_search_results.png b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Assets/cua_search_results.png new file mode 100644 index 000000000000..ed3ab3d8d492 Binary files /dev/null and b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Assets/cua_search_results.png differ diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Assets/cua_search_typed.png b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Assets/cua_search_typed.png new file mode 100644 index 000000000000..9f2c56c20445 Binary files /dev/null and b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Assets/cua_search_typed.png differ diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/ClientCreationAndAuthenticationSamples.cs b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/ClientCreationAndAuthenticationSamples.cs new file mode 100644 index 000000000000..340e6af16ba0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/ClientCreationAndAuthenticationSamples.cs @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.ClientModel.TestFramework; +using Azure.Identity; +using NUnit.Framework; +using OpenAI.Files; +using OpenAI.VectorStores; + +namespace Azure.AI.Projects.OpenAI.Tests.Samples; + +[Ignore("Samples represented as tests only for validation of compilation.")] +public class ClientCreationAndAuthenticationSamples : ProjectsOpenAITestBase +{ + [RecordedTest] + public void CreateAgentClientDirectlyFromProjectEndpoint() + { + #region Snippet:CreateAgentClientDirectlyFromProjectEndpoint + AIProjectClient projectClient = new( + endpoint: new Uri("https://.services.ai.azure.com/api/projects/"), + tokenProvider: new AzureCliCredential()); + AIProjectAgentsOperations agentClient = projectClient.Agents; + #endregion + } + + [Test] + public void CreateAgentClientFromProjectsClient() + { + #region Snippet:CreateAgentClientFromProjectsClient + AIProjectClient projectClient = new( + endpoint: new Uri("https://.services.ai.azure.com/api/projects/"), + tokenProvider: new AzureCliCredential()); + ProjectOpenAIClient agentClient = projectClient.OpenAI; + #endregion + } + + [Test] + public void GetOpenAIClientsFromAgents() + { + AIProjectClient projectClient = new( + endpoint: new Uri("https://.services.ai.azure.com/api/projects/"), + tokenProvider: new AzureCliCredential()); + + #region Snippet:GetOpenAIClientsFromProjects + ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent("AGENT_NAME"); + OpenAIFileClient fileClient = projectClient.OpenAI.GetOpenAIFileClient(); + VectorStoreClient vectorStoreClient = projectClient.OpenAI.GetVectorStoreClient(); + #endregion + } + + [Test] + public void SelectClientVersion() + { + #region Snippet:SelectAPIVersion + ProjectOpenAIClientOptions option = new() + { + ApiVersion = "2025-11-15-preview" + }; + ProjectOpenAIClient projectClient = new( + projectEndpoint: new Uri("https://.services.ai.azure.com/api/projects/"), + tokenProvider: new AzureCliCredential()); + #endregion + } + + public ClientCreationAndAuthenticationSamples(bool isAsync) : base(isAsync) { } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/PromptAgentSamples.cs b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/PromptAgentSamples.cs new file mode 100644 index 000000000000..bf13da712d61 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/PromptAgentSamples.cs @@ -0,0 +1,266 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.ClientModel.TestFramework; +using Azure.Identity; +using NUnit.Framework; +using OpenAI.Responses; +using System.ClientModel; + +namespace Azure.AI.Projects.OpenAI.Tests.Samples; + +public class PromptAgentSamples : ProjectsOpenAITestBase +{ + [Test] + public async Task CreateAPromptAgent() + { + IgnoreSampleMayBe(); + #region Snippet:CreateAPromptAgent +#if SNIPPET + string RAW_PROJECT_ENDPOINT = Environment.GetEnvironmentVariable("AZURE_AI_FOUNDRY_PROJECT_ENDPOINT") + ?? throw new InvalidOperationException("Missing environment variable 'AZURE_AI_FOUNDRY_PROJECT_ENDPOINT'"); + string MODEL_DEPLOYMENT = Environment.GetEnvironmentVariable("AZURE_AI_FOUNDRY_MODEL_DEPLOYMENT") + ?? throw new InvalidOperationException("Missing environment variable 'AZURE_AI_FOUNDRY_MODEL_DEPLOYMENT'"); + string AGENT_NAME = Environment.GetEnvironmentVariable("AZURE_AI_FOUNDRY_AGENT_NAME") + ?? throw new InvalidOperationException("Missing environment variable 'AZURE_AI_FOUNDRY_AGENT_NAME'"); +#else + string RAW_PROJECT_ENDPOINT = TestEnvironment.PROJECT_ENDPOINT; + string MODEL_DEPLOYMENT = TestEnvironment.MODELDEPLOYMENTNAME; + string AGENT_NAME = TestEnvironment.AGENT_NAME; +#endif + + AIProjectClient projectClient = new(new Uri(RAW_PROJECT_ENDPOINT), new AzureCliCredential()); + + AgentDefinition agentDefinition = new PromptAgentDefinition(MODEL_DEPLOYMENT) + { + Instructions = "You are a foo bar agent. In EVERY response you give, ALWAYS include both `foo` and `bar` strings somewhere in the response.", + }; + + AgentVersion newAgentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: AGENT_NAME, + options: new(agentDefinition)); + Console.WriteLine($"Created new agent version: {newAgentVersion.Name}"); + #endregion + } + + [Test] + [AsyncOnly] + public async Task RunAPromptAgentNoConversationAsync() + { + IgnoreSampleMayBe(); +#if SNIPPET + string RAW_PROJECT_ENDPOINT = Environment.GetEnvironmentVariable("AZURE_AI_FOUNDRY_PROJECT_ENDPOINT") + ?? throw new InvalidOperationException("Missing environment variable 'AZURE_AI_FOUNDRY_PROJECT_ENDPOINT'"); + string MODEL_DEPLOYMENT = Environment.GetEnvironmentVariable("AZURE_AI_FOUNDRY_MODEL_DEPLOYMENT") + ?? throw new InvalidOperationException("Missing environment variable 'AZURE_AI_FOUNDRY_MODEL_DEPLOYMENT'"); +#else + string RAW_PROJECT_ENDPOINT = TestEnvironment.PROJECT_ENDPOINT; + string MODEL_DEPLOYMENT = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + AIProjectClient projectClient = new(new Uri(RAW_PROJECT_ENDPOINT), new AzureCliCredential()); + ProjectOpenAIClient openaiClient = projectClient.GetProjectOpenAIClient(); + #region Snippet:CreateAgent_Basic_Async + PromptAgentDefinition agentDefinition = new(model: MODEL_DEPLOYMENT) + { + Instructions = "You are a physics teacher with a sense of humor.", + }; + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent", + options: new(agentDefinition) + ); + #endregion + #region Snippet:CreateResponseBasic_Async + var agentReference = new AgentReference(name: agentVersion.Name); + ProjectResponsesClient responseClient = openaiClient.GetProjectResponsesClientForAgent(agentReference); + ResponseCreationOptions responseCreationOptions = new(); + OpenAIResponse response = await responseClient.CreateResponseAsync( + [ResponseItem.CreateUserMessageItem("Write Maxwell's equation in LaTeX format.")], + responseCreationOptions); + Console.WriteLine(response.GetOutputText()); + #endregion + #region Snippet:FollowUp_Basic_Async + responseCreationOptions.PreviousResponseId = response.Id; + response = await responseClient.CreateResponseAsync( + [ResponseItem.CreateUserMessageItem("What was the previous question?")], + responseCreationOptions); + Console.WriteLine(response.GetOutputText()); + #endregion + #region Snippet:CleanUp_Basic_Async + await projectClient.Agents.DeleteAgentAsync(agentName: "myAgent"); + #endregion + } + + [Test] + [SyncOnly] + public void RunAPromptAgentNoConversationSync() + { + IgnoreSampleMayBe(); +#if SNIPPET + string RAW_PROJECT_ENDPOINT = Environment.GetEnvironmentVariable("AZURE_AI_FOUNDRY_PROJECT_ENDPOINT") + ?? throw new InvalidOperationException("Missing environment variable 'AZURE_AI_FOUNDRY_PROJECT_ENDPOINT'"); + string MODEL_DEPLOYMENT = Environment.GetEnvironmentVariable("AZURE_AI_FOUNDRY_MODEL_DEPLOYMENT") + ?? throw new InvalidOperationException("Missing environment variable 'AZURE_AI_FOUNDRY_MODEL_DEPLOYMENT'"); +#else + string RAW_PROJECT_ENDPOINT = TestEnvironment.PROJECT_ENDPOINT; + string MODEL_DEPLOYMENT = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + AIProjectClient projectClient = new(new Uri(RAW_PROJECT_ENDPOINT), new AzureCliCredential()); + ProjectOpenAIClient openAIClient = projectClient.GetProjectOpenAIClient(); + PromptAgentDefinition agentDefinition = new(model: MODEL_DEPLOYMENT) + { + Instructions = "You are a physics teacher with a sense of humor.", + }; + AgentVersion agentVersion = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent", + options: new(agentDefinition) + ); + var agentReference = new AgentReference(name: agentVersion.Name); + ResponseCreationOptions responseCreationOptions = new(); + ProjectResponsesClient responseClient = openAIClient.GetProjectResponsesClientForAgent(agentReference); + OpenAIResponse response = responseClient.CreateResponse( + [ResponseItem.CreateUserMessageItem("Write Maxwell's equation in LaTeX format.")], + responseCreationOptions); + Console.WriteLine(response.GetOutputText()); + responseCreationOptions.PreviousResponseId = response.Id; + response = responseClient.CreateResponse( + [ResponseItem.CreateUserMessageItem("What was the previous question?")], + responseCreationOptions); + Console.WriteLine(response.GetOutputText()); + projectClient.Agents.DeleteAgent(agentName: "myAgent"); + } + + [Test] + public async Task RunAPromptAgent() + { + IgnoreSampleMayBe(); +#if SNIPPET + string RAW_PROJECT_ENDPOINT = Environment.GetEnvironmentVariable("AZURE_AI_FOUNDRY_PROJECT_ENDPOINT") + ?? throw new InvalidOperationException("Missing environment variable 'AZURE_AI_FOUNDRY_PROJECT_ENDPOINT'"); + string MODEL_DEPLOYMENT = Environment.GetEnvironmentVariable("AZURE_AI_FOUNDRY_MODEL_DEPLOYMENT") + ?? throw new InvalidOperationException("Missing environment variable 'AZURE_AI_FOUNDRY_MODEL_DEPLOYMENT'"); + string AGENT_NAME = Environment.GetEnvironmentVariable("AZURE_AI_FOUNDRY_AGENT_NAME") + ?? throw new InvalidOperationException("Missing environment variable 'AZURE_AI_FOUNDRY_AGENT_NAME'"); +#else + string RAW_PROJECT_ENDPOINT = TestEnvironment.PROJECT_ENDPOINT; + string MODEL_DEPLOYMENT = TestEnvironment.MODELDEPLOYMENTNAME; + string AGENT_NAME = TestEnvironment.AGENT_NAME; +#endif + AIProjectClient projectClient = new(new Uri(RAW_PROJECT_ENDPOINT), new AzureCliCredential()); + ProjectOpenAIClient openAIClient = projectClient.GetProjectOpenAIClient(); + #region Snippet:ConversationClient + ResponseCreationOptions responseCreationOptions = new(); + // Optionally, use a conversation to automatically maintain state between calls. + ProjectConversation conversation = await projectClient.OpenAI.Conversations.CreateProjectConversationAsync(); + ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(AGENT_NAME, conversation); + #endregion + List items = [ResponseItem.CreateUserMessageItem("Tell me a one-line story.")]; + OpenAIResponse response = await responseClient.CreateResponseAsync("Tell me a one-line story."); + + Console.WriteLine(response.GetOutputText()); + #region Snippet:DeleteConversationClient + await openAIClient.GetConversationClient().DeleteConversationAsync(conversation.Id); + #endregion + } + + [Test] + public async Task FullPromptAgentEndToEnd() + { + IgnoreSampleMayBe(); +#if SNIPPET + string RAW_PROJECT_ENDPOINT = Environment.GetEnvironmentVariable("AZURE_AI_FOUNDRY_PROJECT_ENDPOINT") + ?? throw new InvalidOperationException("Missing environment variable 'AZURE_AI_FOUNDRY_PROJECT_ENDPOINT'"); + string MODEL_DEPLOYMENT = Environment.GetEnvironmentVariable("AZURE_AI_FOUNDRY_MODEL_DEPLOYMENT") + ?? throw new InvalidOperationException("Missing environment variable 'AZURE_AI_FOUNDRY_MODEL_DEPLOYMENT'"); + string AGENT_NAME = Environment.GetEnvironmentVariable("AZURE_AI_FOUNDRY_AGENT_NAME") + ?? throw new InvalidOperationException("Missing environment variable 'AZURE_AI_FOUNDRY_AGENT_NAME'"); +#else + string RAW_PROJECT_ENDPOINT = TestEnvironment.PROJECT_ENDPOINT; + string MODEL_DEPLOYMENT = TestEnvironment.MODELDEPLOYMENTNAME; + string AGENT_NAME = TestEnvironment.AGENT_NAME; +#endif + AIProjectClient projectClient = new(new Uri(RAW_PROJECT_ENDPOINT), new AzureCliCredential()); + ProjectOpenAIClient openAIClient = projectClient.GetProjectOpenAIClient(); + + // + // Create an agent version for a new prompt agent + // + + AgentDefinition agentDefinition = new PromptAgentDefinition(MODEL_DEPLOYMENT) + { + Instructions = "You are a foo bar agent. In EVERY response you give, ALWAYS include both `foo` and `bar` strings somewhere in the response.", + }; + AgentVersion newAgentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: AGENT_NAME, + options: new(agentDefinition)); + + // + // Create a conversation to maintain state between calls + // + #region Snippet:ExistingConversations + ProjectConversationCreationOptions conversationOptions = new() + { + Items = { ResponseItem.CreateSystemMessageItem("Your preferred genre of story today is: horror.") }, + Metadata = { ["foo"] = "bar" }, + }; + ProjectConversation conversation = await projectClient.OpenAI.Conversations.CreateProjectConversationAsync(conversationOptions); + + // + // Add items to an existing conversation to supplement the interaction state + // + string EXISTING_CONVERSATION_ID = conversation.Id; + + _ = await projectClient.OpenAI.Conversations.CreateProjectConversationItemsAsync( + EXISTING_CONVERSATION_ID, + [ResponseItem.CreateSystemMessageItem(inputTextContent: "Story theme to use: department of licensing.")]); + // + // Use the agent and conversation in a response + // + ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(AGENT_NAME); + ResponseCreationOptions responseCreationOptions = new() + { + AgentConversationId = EXISTING_CONVERSATION_ID, + }; + + List items = [ResponseItem.CreateUserMessageItem("Tell me a one-line story.")]; + OpenAIResponse response = await responseClient.CreateResponseAsync(items, responseCreationOptions); + #endregion + Console.WriteLine(response.GetOutputText()); + await openAIClient.GetConversationClient().DeleteConversationAsync(conversation.Id); + } + + [Test] + public async Task AgentError() + { + IgnoreSampleMayBe(); +#if SNIPPET + string RAW_PROJECT_ENDPOINT = Environment.GetEnvironmentVariable("AZURE_AI_FOUNDRY_PROJECT_ENDPOINT") + ?? throw new InvalidOperationException("Missing environment variable 'AZURE_AI_FOUNDRY_PROJECT_ENDPOINT'"); + string MODEL_DEPLOYMENT = Environment.GetEnvironmentVariable("AZURE_AI_FOUNDRY_MODEL_DEPLOYMENT") + ?? throw new InvalidOperationException("Missing environment variable 'AZURE_AI_FOUNDRY_MODEL_DEPLOYMENT'"); + string AGENT_NAME = Environment.GetEnvironmentVariable("AZURE_AI_FOUNDRY_AGENT_NAME") + ?? throw new InvalidOperationException("Missing environment variable 'AZURE_AI_FOUNDRY_AGENT_NAME'"); +#else + string RAW_PROJECT_ENDPOINT = TestEnvironment.PROJECT_ENDPOINT; + string MODEL_DEPLOYMENT = TestEnvironment.MODELDEPLOYMENTNAME; + string AGENT_NAME = TestEnvironment.AGENT_NAME; +#endif + AIProjectClient projectClient = new(new Uri(RAW_PROJECT_ENDPOINT), new AzureCliCredential()); + #region Snippet:ErrorHandling + try + { + AgentVersion agent = await projectClient.Agents.GetAgentVersionAsync( + agentName: "agent_which_dies_not_exist", agentVersion: "1"); + } + catch (ClientResultException e) when (e.Status == 404) + { + Console.WriteLine($"Exception status code: {e.Status}"); + Console.WriteLine($"Exception message: {e.Message}"); + } + #endregion + } + public PromptAgentSamples(bool isAsync) : base(isAsync) + { } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_Agents_Telemetry.cs b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_Agents_Telemetry.cs new file mode 100644 index 000000000000..67615120703f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_Agents_Telemetry.cs @@ -0,0 +1,172 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using System.Threading.Tasks; +using Microsoft.ClientModel.TestFramework; +using NUnit.Framework; +using OpenTelemetry.Resources; +using OpenTelemetry.Trace; +using OpenTelemetry; +using Azure.Identity; +using Azure.Monitor.OpenTelemetry.Exporter; +using Azure.AI.Projects.OpenAI; +using Azure.AI.Projects.OpenAI.Tests; + +namespace Azure.AI.Projects.OpenAI.Tests.Samples; + +public partial class Sample_Agents_Telemetry : ProjectsOpenAITestBase +{ + [Test] + [AsyncOnly] + public async Task TracingToConsoleExample() + { + IgnoreSampleMayBe(); +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + var tracerProvider = Sdk.CreateTracerProviderBuilder() + .AddSource("Azure.AI.Projects.Persistent.*") // Add the required sources name + .SetResourceBuilder(OpenTelemetry.Resources.ResourceBuilder.CreateDefault().AddService("AgentTracingSample")) + .AddConsoleExporter() // Export traces to the console + .Build(); + + using (tracerProvider) + { + AIProjectClient projectClient = new(new Uri(projectEndpoint), new DefaultAzureCredential()); + + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a prompt agent." + }; + AgentVersion agentVersion1 = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent1", + options: new(agentDefinition)); + + await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion1.Name, agentVersion: agentVersion1.Version); + Console.WriteLine($"Agent deleted (name: {agentVersion1.Name}, version: {agentVersion1.Version})"); + } + } + + [Test] + [SyncOnly] + public void TracingToConsoleExampleSync() + { + IgnoreSampleMayBe(); +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + #region Snippet:EnableActivitySourceToGetAgentTraces + AppContext.SetSwitch("Azure.Experimental.EnableActivitySource", true); + #endregion + #region Snippet:DisableContentRecordingForAgentTraces + AppContext.SetSwitch("Azure.Experimental.TraceGenAIMessageContent", false); + #endregion + #region Snippet:AgentTelemetrySetupTracingToConsole + var tracerProvider = Sdk.CreateTracerProviderBuilder() + .AddSource("Azure.AI.Projects.Persistent.*") // Add the required sources name + .SetResourceBuilder(OpenTelemetry.Resources.ResourceBuilder.CreateDefault().AddService("AgentTracingSample")) + .AddConsoleExporter() // Export traces to the console + .Build(); + #endregion + + using (tracerProvider) + { + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a prompt agent." + }; + AgentVersion agentVersion1 = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent1", + options: new(agentDefinition)); + + projectClient.Agents.DeleteAgentVersion(agentName: agentVersion1.Name, agentVersion: agentVersion1.Version); + Console.WriteLine($"Agent deleted (name: {agentVersion1.Name} , version: {agentVersion1.Version})"); + } + } + + [Test] + [AsyncOnly] + public async Task TracingToAzureMonitorExample() + { + IgnoreSampleMayBe(); +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + var tracerProvider = Sdk.CreateTracerProviderBuilder() + .AddSource("Azure.AI.Projects.Persistent.*") + .SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("AgentTracingSample")) + .AddAzureMonitorTraceExporter().Build(); + + using (tracerProvider) + { + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a prompt agent." + }; + AgentVersion agentVersion1 = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent1", + options: new(agentDefinition)); + + await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion1.Name, agentVersion: agentVersion1.Version); + Console.WriteLine($"Agent deleted (name: {agentVersion1.Name} , version: {agentVersion1.Version})"); + } + } + + [Test] + [SyncOnly] + public void TracingToAzureMonitorExampleSync() + { + IgnoreSampleMayBe(); +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + #region Snippet:AgentTelemetrySetupTracingToAzureMonitor + var tracerProvider = Sdk.CreateTracerProviderBuilder() + .AddSource("Azure.AI.Projects.Persistent.*") + .SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("AgentTracingSample")) + .AddAzureMonitorTraceExporter().Build(); + #endregion + + using (tracerProvider) + { + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a prompt agent." + }; + AgentVersion agentVersion1 = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent1", + options: new(agentDefinition)); + + projectClient.Agents.DeleteAgentVersion(agentName: agentVersion1.Name, agentVersion: agentVersion1.Version); + Console.WriteLine($"Agent deleted (name: {agentVersion1.Name} , version: {agentVersion1.Version})"); + } + } + + public Sample_Agents_Telemetry(bool isAsync) : base(isAsync) + { } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_CodeInterpreter.cs b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_CodeInterpreter.cs new file mode 100644 index 000000000000..d45678a4d732 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_CodeInterpreter.cs @@ -0,0 +1,118 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Azure.Identity; +using Microsoft.ClientModel.TestFramework; +using NUnit.Framework; +using Azure.AI.Projects.OpenAI; +using OpenAI; +using OpenAI.Responses; + +namespace Azure.AI.Projects.OpenAI.Tests.Samples; + +public class Sample_CodeInterpreter : ProjectsOpenAITestBase +{ + [Test] + [AsyncOnly] + public async Task CodeInterpreterAsync() + { + IgnoreSampleMayBe(); + #region Snippet:Sample_CreateAgentClient_CodeInterpreter +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + #endregion + #region Snippet:Sample_CreateAgent_CodeInterpreter_Async + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a personal math tutor. When asked a math question, write and run code using the python tool to answer the question.", + Tools = { + ResponseTool.CreateCodeInterpreterTool( + new CodeInterpreterToolContainer( + CodeInterpreterToolContainerConfiguration.CreateAutomaticContainerConfiguration([]) + ) + ), + } + }; + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent", + options: new(agentDefinition)); + #endregion + #region Snippet:Sample_CreateResponse_CodeInterpreter_Async + AgentReference agentReference = new(name: agentVersion.Name, version: agentVersion.Version); + ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentReference); + + OpenAIResponse response = await responseClient.CreateResponseAsync("I need to solve the equation sin(x) + x^2 = 42"); + #endregion + + #region Snippet:Sample_WaitForResponse_CodeInterpreter_Async + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + Console.WriteLine(response.GetOutputText()); + #endregion + + #region Snippet:Sample_Cleanup_CodeInterpreter_Async + await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion.Name, agentVersion: agentVersion.Version); + #endregion + } + + [Test] + [SyncOnly] + public void CodeInterpreterSync() + { + IgnoreSampleMayBe(); +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + + #region Snippet:Sample_CreateAgent_CodeInterpreter_Sync + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a helpful agent that can help fetch data from files you know about.", + Tools = { + ResponseTool.CreateCodeInterpreterTool( + new CodeInterpreterToolContainer( + CodeInterpreterToolContainerConfiguration.CreateAutomaticContainerConfiguration( + fileIds: [] + ) + ) + ), + } + }; + AgentVersion agentVersion = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent", + options: new(agentDefinition)); + #endregion + #region Snippet:Sample_CreateResponse_CodeInterpreter_Sync + AgentReference agentReference = new(name: agentVersion.Name, version: agentVersion.Version); + ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentReference); + + OpenAIResponse response = responseClient.CreateResponse("I need to solve the equation sin(x) + x^2 = 42"); + #endregion + + #region Snippet:Sample_WaitForResponse_CodeInterpreter_Sync + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + Console.WriteLine(response.GetOutputText()); + #endregion + + #region Snippet:Sample_Cleanup_CodeInterpreter_Sync + projectClient.Agents.DeleteAgentVersion(agentName: agentVersion.Name, agentVersion: agentVersion.Version); + #endregion + } + + public Sample_CodeInterpreter(bool isAsync) : base(isAsync) + { } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_ComputerUse.cs b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_ComputerUse.cs new file mode 100644 index 000000000000..9fd1476822fc --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_ComputerUse.cs @@ -0,0 +1,280 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading; +using System.Threading.Tasks; +using Azure.AI.Projects.OpenAI; +using Azure.Identity; +using Microsoft.ClientModel.TestFramework; +using NUnit.Framework; +using OpenAI.Responses; + +namespace Azure.AI.Projects.OpenAI.Tests.Samples; + +#pragma warning disable OPENAICUA001 +public class Sample_ComputerUse : ProjectsOpenAITestBase +{ + #region Snippet:Sample_ReadImageFile_ComputerUse + private static BinaryData ReadImageFile(string name, [CallerFilePath] string pth = "") + { + var dirName = Path.GetDirectoryName(pth) ?? ""; + return new BinaryData(File.ReadAllBytes(Path.Combine(dirName, name))); + } + #endregion + + #region Snippet:Sample_ProcessComputerUseCall_ComputerUse + private static string ProcessComputerUseCall(ComputerCallResponseItem item, string oldScreenshot) + { + string currentScreenshot = "browser_search"; + switch (item.Action.Kind) + { + case ComputerCallActionKind.Type: + Console.WriteLine($" Typing text \"{item.Action.TypeText}\" - Simulating keyboard input"); + currentScreenshot = "search_typed"; + break; + case ComputerCallActionKind.KeyPress: + HashSet codes = [.. item.Action.KeyPressKeyCodes]; + if (codes.Contains("Return") || codes.Contains("ENTER")) + { + // If we have typed the value to the search field, go to search results. + if (string.Equals(oldScreenshot, "search_typed")) + { + Console.WriteLine(" -> Detected ENTER key press, when search field was populated, displaying results."); + currentScreenshot = "search_results"; + } + else + { + Console.WriteLine(" -> Detected ENTER key press, on results or unpopulated search, do nothing."); + currentScreenshot = oldScreenshot; + } + } + else + { + Console.WriteLine($" Key press: {item.Action.KeyPressKeyCodes.Aggregate("", (agg, next) => agg + "+" + next)} - Simulating key combination"); + } + break; + case ComputerCallActionKind.Click: + Console.WriteLine($" Click at ({item.Action.ClickCoordinates.Value.X}, {item.Action.ClickCoordinates.Value.Y}) - Simulating click on UI element"); + if (string.Equals(oldScreenshot, "search_typed")) + { + Console.WriteLine(" -> Assuming click on Search button when search field was populated, displaying results."); + currentScreenshot = "search_results"; + } + else + { + Console.WriteLine(" -> Assuming click on Search on results or when search was not populated, do nothing."); + currentScreenshot = oldScreenshot; + } + break; + case ComputerCallActionKind.Drag: + string pathStr = item.Action.DragPath.ToArray().Select(p => $"{p.X}, {p.Y}").Aggregate("", (agg, next) => $"{agg} -> {next}"); + Console.WriteLine($" Drag path: {pathStr} - Simulating drag operation"); + break; + case ComputerCallActionKind.Scroll: + Console.WriteLine($" Scroll at ({item.Action.ScrollCoordinates.Value.X}, {item.Action.ScrollCoordinates.Value.Y}) - Simulating scroll action"); + break; + case ComputerCallActionKind.Screenshot: + Console.WriteLine(" Taking screenshot - Capturing current screen state"); + break; + default: + break; + } + Console.WriteLine($" -> Action processed: {item.Action.Kind}"); + + return currentScreenshot; + } + #endregion + + [Test] + [AsyncOnly] + public async Task ComputerUseAsync() + { + IgnoreSampleMayBe(); + #region Snippet:Sample_CreateAgentClient_ComputerUse +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("COMPUTER_USE_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.COMPUTER_USE_DEPLOYMENT_NAME; +#endif + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + #endregion + #region Snippet:Sample_ReadImageFilesToDictionaries_ComputerUse + Dictionary screenshots = new() { + { "browser_search", ReadImageFile("Assets/cua_browser_search.png")}, + { "search_typed", ReadImageFile("Assets/cua_search_typed.png")}, + { "search_results", ReadImageFile("Assets/cua_search_results.png")}, + }; + #endregion + #region Snippet:Sample_CreateAgent_ComputerUse_Async + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a computer automation assistant.\n\n" + + "Be direct and efficient. When you reach the search results page, read and describe the actual search result titles and descriptions you can see.", + Tools = { + ResponseTool.CreateComputerTool( + environment: new ComputerToolEnvironment("windows"), + displayWidth: 1026, + displayHeight: 769 + ), + } + }; + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent", + options: new(agentDefinition) + ); + #endregion + #region Snippet:Sample_CreateResponse_ComputerUse_Async + ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name); + ResponseCreationOptions responseOptions = new(); + responseOptions.TruncationMode = ResponseTruncationMode.Auto; + ResponseItem request = ResponseItem.CreateUserMessageItem( + [ + ResponseContentPart.CreateInputTextPart("I need you to help me search for 'OpenAI news'. Please type 'OpenAI news' and submit the search. Once you see search results, the task is complete."), + ResponseContentPart.CreateInputImagePart(imageBytes: screenshots["browser_search"], imageBytesMediaType: "image/png", imageDetailLevel: ResponseImageDetailLevel.High) + ] + ); + List inputItems = [request]; + bool computerUseCalled = false; + string currentScreenshot = "browser_search"; + int limitIteration = 10; + OpenAIResponse response; + do + { + response = await CreateResponseAsync( + responseClient, + inputItems, + responseOptions + ); + computerUseCalled = false; + responseOptions.PreviousResponseId = response.Id; + inputItems.Clear(); + foreach (ResponseItem responseItem in response.OutputItems) + { + inputItems.Add(responseItem); + if (responseItem is ComputerCallResponseItem computerCall) + { + currentScreenshot = ProcessComputerUseCall(computerCall, currentScreenshot); + inputItems.Add(ResponseItem.CreateComputerCallOutputItem(callId: computerCall.CallId, output: ComputerCallOutput.CreateScreenshotOutput(screenshotImageBytes: screenshots[currentScreenshot], screenshotImageBytesMediaType: "image/png"))); + computerUseCalled = true; + } + } + limitIteration--; + } while (computerUseCalled && limitIteration > 0); + Console.WriteLine(response.GetOutputText()); + #endregion + #region Snippet:Sample_Cleanup_ComputerUse_Async + await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion.Name, agentVersion: agentVersion.Version); + #endregion + } + + #region Snippet:Sample_CreateNextResponse_ComputerUse_Async + public static async Task CreateResponseAsync(OpenAIResponseClient responseClient, IEnumerable items, ResponseCreationOptions options) + { + OpenAIResponse response = await responseClient.CreateResponseAsync( + inputItems: items, + options: options); + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + return response; + } + #endregion + + #region Snippet:Sample_CreateNextResponse_ComputerUse_Sync + public static OpenAIResponse CreateResponse(OpenAIResponseClient responseClient, IEnumerable items, ResponseCreationOptions options) + { + OpenAIResponse response = responseClient.CreateResponse( + inputItems: items, + options: options); + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + return response; + } + #endregion + + [Test] + [SyncOnly] + public void ComputerUseSync() + { + IgnoreSampleMayBe(); +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("COMPUTER_USE_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.COMPUTER_USE_DEPLOYMENT_NAME; +#endif + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + Dictionary screenshots = new() { + {"browser_search", ReadImageFile("Assets/cua_browser_search.png")}, + {"search_typed", ReadImageFile("Assets/cua_search_typed.png")}, + {"search_results", ReadImageFile("Assets/cua_search_results.png")}, + }; + #region Snippet:Sample_CreateAgent_ComputerUse_Sync + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a computer automation assistant.\n\n" + + "Be direct and efficient. When you reach the search results page, read and describe the actual search result titles and descriptions you can see.", + Tools = { + ResponseTool.CreateComputerTool( + environment: new ComputerToolEnvironment("windows"), + displayWidth: 1026, + displayHeight: 769 + ), + } + }; + AgentVersion agentVersion = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent", + options: new(agentDefinition) + ); + #endregion + #region Snippet:Sample_CreateResponse_ComputerUse_Sync + ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name); + ResponseCreationOptions responseOptions = new(); + responseOptions.TruncationMode = ResponseTruncationMode.Auto; + string currentScreenshot = "browser_search"; + ResponseItem request = ResponseItem.CreateUserMessageItem( + [ + ResponseContentPart.CreateInputTextPart("I need you to help me search for 'OpenAI news'. Please type 'OpenAI news' and submit the search. Once you see search results, the task is complete."), + ResponseContentPart.CreateInputImagePart(imageBytes: screenshots["browser_search"], imageBytesMediaType: "image/png", imageDetailLevel: ResponseImageDetailLevel.High) + ] + ); + List inputItems = [request]; + bool computerUseCalled = false; + int limitIteration = 10; + OpenAIResponse response; + do + { + response = CreateResponse( + responseClient, + inputItems, + responseOptions); + computerUseCalled = false; + inputItems.Clear(); + responseOptions.PreviousResponseId = response.Id; + foreach (ResponseItem responseItem in response.OutputItems) + { + inputItems.Add(responseItem); + if (responseItem is ComputerCallResponseItem computerCall) + { + currentScreenshot = ProcessComputerUseCall(computerCall, currentScreenshot); + inputItems.Add(ResponseItem.CreateComputerCallOutputItem(callId: computerCall.CallId, output: ComputerCallOutput.CreateScreenshotOutput(screenshotImageBytes: screenshots[currentScreenshot], screenshotImageBytesMediaType: "image/png"))); + computerUseCalled = true; + } + } + limitIteration--; + } while (computerUseCalled && limitIteration > 0); + Console.WriteLine(response.GetOutputText()); + #endregion + #region Snippet:Sample_Cleanup_ComputerUse_Sync + projectClient.Agents.DeleteAgentVersion(agentName: agentVersion.Name, agentVersion: agentVersion.Version); + #endregion + } + + public Sample_ComputerUse(bool isAsync) : base(isAsync) + { } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_Container_App.cs b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_Container_App.cs new file mode 100644 index 000000000000..6fb0a0f02973 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_Container_App.cs @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure.Identity; +using Microsoft.ClientModel.TestFramework; +using NUnit.Framework; +using OpenAI.Responses; + +namespace Azure.AI.Projects.OpenAI.Tests.Samples; + +public class Sample_Container_App : ProjectsOpenAITestBase +{ + [Test] + [AsyncOnly] + public async Task SampleContainerAppAsync() + { + IgnoreSampleMayBe(); + #region Snippet:Sample_Create_client_ContainerApp +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var containerAppResourceId = System.Environment.GetEnvironmentVariable("CONTAINER_APP_RESOURCE_ID"); + var ingressSubdomainSuffix = System.Environment.GetEnvironmentVariable("INGRESS_SUBDOMAIN_SUFFIX"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var containerAppResourceId = TestEnvironment.CONTAINER_APP_RESOURCE_ID; + var ingressSubdomainSuffix = TestEnvironment.INGRESS_SUBDOMAIN_SUFFIX; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + #endregion + #region Snippet:Sample_CreateContainerApp_ContainerApp_Async + AgentVersion containerAgentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "containerAgent", + options: new(new ContainerApplicationAgentDefinition( + containerProtocolVersions: [new ProtocolVersionRecord(protocol: AgentCommunicationMethod.Responses, version: "1")], + containerAppResourceId: containerAppResourceId, + ingressSubdomainSuffix: ingressSubdomainSuffix))); + #endregion + #region Snippet:Sample_CreateConversation_ContainerApp_Async + ProjectConversationCreationOptions conversationOptions = new(); + conversationOptions.Items.Add( + ResponseItem.CreateUserMessageItem("What is the size of France in square miles?") + ); + ProjectConversation conversation = await projectClient.OpenAI.Conversations.CreateProjectConversationAsync(conversationOptions); + #endregion + #region Snippet:Sample_CommunicateWithTheAgent_ContainerApp_Async + ResponseCreationOptions responseOptions = new() + { + Agent = containerAgentVersion, + AgentConversationId = conversation.Id, + }; + OpenAIResponse response = await projectClient.OpenAI.Responses.CreateResponseAsync([], responseOptions); + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + Console.WriteLine(response.GetOutputText()); + + await projectClient.OpenAI.Conversations.CreateProjectConversationItemsAsync( + conversationId: conversation.Id, + items: [ResponseItem.CreateUserMessageItem("And what is the capital city?")]); + response = await projectClient.OpenAI.Responses.CreateResponseAsync([], responseOptions); + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + Console.WriteLine(response.GetOutputText()); + #endregion + #region Snippet:Sample_Cleanup_ContainerApp_Async + await projectClient.OpenAI.Conversations.DeleteConversationAsync(conversationId:conversation.Id); + await projectClient.Agents.DeleteAgentVersionAsync(agentName: containerAgentVersion.Name, agentVersion: containerAgentVersion.Version); + #endregion + } + + [Test] + [SyncOnly] + public void SampleContainerAppSync() + { + IgnoreSampleMayBe(); +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var containerAppResourceId = System.Environment.GetEnvironmentVariable("CONTAINER_APP_RESOURCE_ID"); + var ingressSubdomainSuffix = System.Environment.GetEnvironmentVariable("INGRESS_SUBDOMAIN_SUFFIX"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var containerAppResourceId = TestEnvironment.CONTAINER_APP_RESOURCE_ID; + var ingressSubdomainSuffix = TestEnvironment.INGRESS_SUBDOMAIN_SUFFIX; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + #region Snippet:Sample_CreateContainerApp_ContainerApp_Sync + AgentVersion containerAgentVersion = projectClient.Agents.CreateAgentVersion( + agentName: "containerAgent", + options: new(new ContainerApplicationAgentDefinition( + containerProtocolVersions: [new ProtocolVersionRecord(protocol: AgentCommunicationMethod.Responses, version: "1")], + containerAppResourceId: containerAppResourceId, + ingressSubdomainSuffix: ingressSubdomainSuffix))); + #endregion + #region Snippet:Sample_CreateConversation_ContainerApp_Sync + ProjectConversationCreationOptions conversationOptions = new(); + conversationOptions.Items.Add( + ResponseItem.CreateUserMessageItem("What is the size of France in square miles?") + ); + ProjectConversation conversation = projectClient.OpenAI.Conversations.CreateProjectConversation(options: conversationOptions); + #endregion + #region Snippet:Sample_CommunicateWithTheAgent_ContainerApp_Sync + ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(containerAgentVersion, conversation); + OpenAIResponse response = responseClient.CreateResponse([]); + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + Console.WriteLine(response.GetOutputText()); + + projectClient.OpenAI.Conversations.CreateProjectConversationItems( + conversationId: conversation.Id, + items: [ResponseItem.CreateUserMessageItem("And what is the capital city?")]); + response = projectClient.OpenAI.Responses.CreateResponse([]); + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + Console.WriteLine(response.GetOutputText()); + #endregion + #region Snippet:Sample_Cleanup_ContainerApp_Sync + projectClient.OpenAI.Conversations.DeleteConversation(conversationId: conversation.Id); + projectClient.Agents.DeleteAgentVersion(agentName: containerAgentVersion.Name, agentVersion: containerAgentVersion.Version); + #endregion + } + + public Sample_Container_App(bool isAsync) : base(isAsync) + { } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_Conversation_CRUD.cs b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_Conversation_CRUD.cs new file mode 100644 index 000000000000..64fe87f4edad --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_Conversation_CRUD.cs @@ -0,0 +1,118 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Threading.Tasks; +using Azure.AI.Projects.OpenAI; +using Azure.Identity; +using Microsoft.ClientModel.TestFramework; +using NUnit.Framework; + +namespace Azure.AI.Projects.OpenAI.Tests.Samples; + +public class Sample_conversation_CRUD : ProjectsOpenAITestBase +{ + [Test] + [AsyncOnly] + public async Task ConversationCRUDAsync() + { + IgnoreSampleMayBe(); + #region Snippet:Sample_CreateAgentClient_ConversationCRUD +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; +#endif + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + #endregion + + #region Snippet:Sample_CreateConversations_ConversationCRUD_Async + ProjectConversation conversation1 = await projectClient.OpenAI.Conversations.CreateProjectConversationAsync(); + Console.WriteLine($"Created conversation (id: {conversation1.Id})"); + + ProjectConversation conversation2 = await projectClient.OpenAI.Conversations.CreateProjectConversationAsync(); + Console.WriteLine($"Created conversation (id: {conversation2.Id})"); + #endregion + + #region Snippet:Sample_GetConversation_ConversationCRUD_Async + ProjectConversation conversation = await projectClient.OpenAI.Conversations.GetProjectConversationAsync(conversationId: conversation1.Id); + Console.WriteLine($"Got conversation (id: {conversation.Id}, metadata: {conversation.Metadata})"); + #endregion + + #region Snippet:Sample_ListConversations_ConversationCRUD_Async + await foreach (ProjectConversation res in projectClient.OpenAI.Conversations.GetProjectConversationsAsync()){ + Console.WriteLine($"Listed conversation (id: {res.Id})"); + } + #endregion + + #region Snippet:Sample_UpdateConversations_ConversationCRUD_Async + ProjectConversationUpdateOptions updateOptions = new() + { + Metadata = { ["key"] = "value" }, + }; + await projectClient.OpenAI.Conversations.UpdateProjectConversationAsync(conversation.Id, updateOptions); + + // Get the updated conversation. + conversation = await projectClient.OpenAI.Conversations.GetProjectConversationAsync(conversation1.Id); + Console.WriteLine($"Got conversation (id: {conversation.Id}, metadata: {conversation.Metadata})"); + #endregion + + #region Snippet:Sample_DeleteConversations_ConversationCRUD_Async + await projectClient.OpenAI.Conversations.DeleteConversationAsync(conversationId: conversation1.Id); + await projectClient.OpenAI.Conversations.DeleteConversationAsync(conversationId: conversation2.Id); + #endregion + } + + [Test] + [SyncOnly] + public void ConversationCRUDSync() + { + IgnoreSampleMayBe(); +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; +#endif + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + + #region Snippet:Sample_CreateConversations_ConversationCRUD_Sync + ProjectConversation conversation1 = projectClient.OpenAI.Conversations.CreateProjectConversation(); + Console.WriteLine($"Created conversation (id: {conversation1.Id})"); + + ProjectConversation conversation2 = projectClient.OpenAI.Conversations.CreateProjectConversation(); + Console.WriteLine($"Created conversation (id: {conversation2.Id})"); + #endregion + + #region Snippet:Sample_GetConversation_ConversationCRUD_Sync + ProjectConversation conversation = projectClient.OpenAI.Conversations.GetProjectConversation(conversationId: conversation1.Id); + Console.WriteLine($"Got conversation (id: {conversation.Id}, metadata: {conversation.Metadata})"); + #endregion + + #region Snippet:Sample_ListConversations_ConversationCRUD_Sync + foreach (ProjectConversation res in projectClient.OpenAI.Conversations.GetProjectConversations()) + { + Console.WriteLine($"Listed conversation (id: {res.Id})"); + } + #endregion + + #region Snippet:Sample_UpdateConversations_ConversationCRUD_Sync + ProjectConversationUpdateOptions updateOptions = new() + { + Metadata = { ["key"] = "value" }, + }; + projectClient.OpenAI.Conversations.UpdateProjectConversation(conversation1.Id, updateOptions); + + // Get the updated conversation. + conversation = projectClient.OpenAI.Conversations.GetProjectConversation(conversationId: conversation1.Id); + Console.WriteLine($"Got conversation (id: {conversation.Id}, metadata: {conversation.Metadata})"); + #endregion + + #region Snippet:Sample_DeleteConversations_ConversationCRUD_Sync + projectClient.OpenAI.Conversations.DeleteConversation(conversationId: conversation1.Id); + projectClient.OpenAI.Conversations.DeleteConversation(conversationId: conversation2.Id); + #endregion + } + + public Sample_conversation_CRUD(bool isAsync) : base(isAsync) + { } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_CreateAgentVersion.cs b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_CreateAgentVersion.cs new file mode 100644 index 000000000000..2af77839324d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_CreateAgentVersion.cs @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Azure.Identity; +using Microsoft.ClientModel.TestFramework; +using NUnit.Framework; +using Azure.AI.Projects.OpenAI; +using OpenAI.Responses; + +namespace Azure.AI.Projects.OpenAI.Tests.Samples; + +public class Sample_CreateAgentVersion : ProjectsOpenAITestBase +{ + [Test] + [AsyncOnly] + public async Task CreateAgentVersionAsync() + { + IgnoreSampleMayBe(); + #region Snippet:Sample_CreateAgentClient +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + #endregion + + #region Snippet:Sample_CreateAgentVersion_Async + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a prompt agent." + }; + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent", + options: new(agentDefinition)); + #endregion + #region Snippet:Sample_ListAgentVersions_Async + var agentVersions = projectClient.Agents.GetAgentVersionsAsync(agentName: "myAgent"); + await foreach (AgentVersion oneAgentVersion in agentVersions) + { + Console.WriteLine($"Agent: {oneAgentVersion.Id}, Name: {oneAgentVersion.Name}, Version: {oneAgentVersion.Version}"); + } + #endregion + + #region Snippet:Sample_CreateConversation_Async + ProjectConversation conversation + = await projectClient.OpenAI.Conversations.CreateProjectConversationAsync(); + #endregion + + #region Snippet:Sample_CreateSimpleResponse_Async + + OpenAIResponseClient responseClient + = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion, conversation.Id); + + OpenAIResponse response = await responseClient.CreateResponseAsync("Hello, tell me a joke."); + + #endregion + #region Snippet:Sample_WriteOutput_Async + Console.WriteLine(response.GetOutputText()); + #endregion + #region Snippet:Sample_Cleanup_Async + await projectClient.OpenAI.Conversations.DeleteConversationAsync(conversationId: conversation.Id); + await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion.Name, agentVersion: agentVersion.Version); + #endregion + } + + [Test] + [SyncOnly] + public void CreateAgentVersion() + { + IgnoreSampleMayBe(); +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + + #region Snippet:Sample_CreateAgentVersion_Sync + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a prompt agent." + }; + AgentVersion agentVersion = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent", + options: new(agentDefinition)); + #endregion + #region Snippet:Sample_ListAgentVersions_Sync + var agentVersions = projectClient.Agents.GetAgentVersions(agentName: "myAgent"); + foreach (AgentVersion oneAgentVersion in agentVersions) + { + Console.WriteLine($"Agent: {oneAgentVersion.Id}, Name: {oneAgentVersion.Name}, Version: {oneAgentVersion.Version}"); + } + #endregion + + #region Snippet:Sample_CreateConversation_Sync + ProjectConversation conversation + = projectClient.OpenAI.Conversations.CreateProjectConversation(); + #endregion + + #region Snippet:Sample_CreateSimpleResponse_Sync + + OpenAIResponseClient responseClient + = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion, conversation.Id); + + OpenAIResponse response = responseClient.CreateResponse("Hello, tell me a joke."); + + #endregion + #region Snippet:Sample_WriteOutput_Sync + Console.WriteLine(response.GetOutputText()); + #endregion + #region Snippet:Sample_Cleanup_Sync + projectClient.OpenAI.Conversations.DeleteConversation(conversationId: conversation.Id); + projectClient.Agents.DeleteAgentVersion(agentName: agentVersion.Name, agentVersion: agentVersion.Version); + #endregion + } + + public Sample_CreateAgentVersion(bool isAsync) : base(isAsync) + { } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_FileSearch.cs b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_FileSearch.cs new file mode 100644 index 000000000000..ae330f8a468e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_FileSearch.cs @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using Azure.Identity; +using Microsoft.ClientModel.TestFramework; +using NUnit.Framework; +using OpenAI.Files; +using OpenAI.Responses; +using OpenAI.VectorStores; + +namespace Azure.AI.Projects.OpenAI.Tests.Samples; + +public class Sample_FileSearch : ProjectsOpenAITestBase +{ + [Test] + [AsyncOnly] + public async Task FileSearchAsync() + { + IgnoreSampleMayBe(); + #region Snippet:Sample_CreateAgentClient_FileSearch +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + + #endregion + #region Snippet:Sample_UploadFile_FileSearch_Async + string filePath = "sample_file_for_upload.txt"; + File.WriteAllText( + path: filePath, + contents: "The word 'apple' uses the code 442345, while the word 'banana' uses the code 673457."); + OpenAIFileClient fileClient = projectClient.OpenAI.GetOpenAIFileClient(); + OpenAIFile uploadedFile = await fileClient.UploadFileAsync(filePath: filePath, purpose: FileUploadPurpose.Assistants); + File.Delete(filePath); + #endregion + #region Snippet:Sample_CreateVectorStore_FileSearch_Async + VectorStoreClient vctStoreClient = projectClient.OpenAI.GetVectorStoreClient(); + VectorStoreCreationOptions options = new() + { + Name = "MySampleStore", + FileIds = { uploadedFile.Id } + }; + VectorStore vectorStore = await vctStoreClient.CreateVectorStoreAsync(options); + #endregion + #region Snippet:Sample_CreateAgent_FileSearch_Async + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a helpful agent that can help fetch data from files you know about.", + Tools = { ResponseTool.CreateFileSearchTool(vectorStoreIds: [vectorStore.Id]), } + }; + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent", + options: new(agentDefinition)); + #endregion + #region Snippet:Sample_CreateResponse_FileSearch_Async + ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name); + + OpenAIResponse response = await responseClient.CreateResponseAsync("Can you give me the documented codes for 'banana' and 'orange'?"); + #endregion + + #region Snippet:Sample_WaitForResponse_FileSearch_Async + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + Console.WriteLine(response.GetOutputText()); + #endregion + + #region Snippet:Sample_Cleanup_FileSearch_Async + await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion.Name, agentVersion: agentVersion.Version); + await vctStoreClient.DeleteVectorStoreAsync(vectorStoreId: vectorStore.Id); + await fileClient.DeleteFileAsync(uploadedFile.Id); + #endregion + } + + [Test] + [SyncOnly] + public void FileSearchSync() + { + IgnoreSampleMayBe(); +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + + #region Snippet:Sample_UploadFile_FileSearch_Sync + string filePath = "sample_file_for_upload.txt"; + File.WriteAllText( + path: filePath, + contents: "The word 'apple' uses the code 442345, while the word 'banana' uses the code 673457."); + OpenAIFileClient fileClient = projectClient.OpenAI.GetOpenAIFileClient(); + OpenAIFile uploadedFile = fileClient.UploadFile(filePath: filePath, purpose: FileUploadPurpose.Assistants); + File.Delete(filePath); + #endregion + #region Snippet:Sample_CreateVectorStore_FileSearch_Sync + VectorStoreClient vctStoreClient = projectClient.OpenAI.GetVectorStoreClient(); + VectorStoreCreationOptions options = new() + { + Name = "MySampleStore", + FileIds = { uploadedFile.Id } + }; + VectorStore vectorStore = vctStoreClient.CreateVectorStore(options: options); + #endregion + #region Snippet:Sample_CreateAgent_FileSearch_Sync + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a helpful agent that can help fetch data from files you know about.", + Tools = { ResponseTool.CreateFileSearchTool(vectorStoreIds: [vectorStore.Id]), } + }; + AgentVersion agentVersion = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent", + options: new(agentDefinition)); + #endregion + #region Snippet:Sample_CreateResponse_FileSearch_Sync + ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name); + + OpenAIResponse response = responseClient.CreateResponse("Can you give me the documented codes for 'banana' and 'orange'?"); + #endregion + + #region Snippet:Sample_WaitForResponse_FileSearch_Sync + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + Console.WriteLine(response.GetOutputText()); + #endregion + + #region Snippet:Sample_Cleanup_FileSearch_Sync + projectClient.Agents.DeleteAgentVersion(agentName: agentVersion.Name, agentVersion: agentVersion.Version); + vctStoreClient.DeleteVectorStore(vectorStoreId: vectorStore.Id); + fileClient.DeleteFile(uploadedFile.Id); + #endregion + } + + public Sample_FileSearch(bool isAsync) : base(isAsync) + { } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_FileSearch_Streaming.cs b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_FileSearch_Streaming.cs new file mode 100644 index 000000000000..25ce613cb311 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_FileSearch_Streaming.cs @@ -0,0 +1,204 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.IO; +using System.Threading.Tasks; +using Azure.AI.Projects.OpenAI; +using Azure.Identity; +using Microsoft.ClientModel.TestFramework; +using NUnit.Framework; +using OpenAI; +using OpenAI.Files; +using OpenAI.Responses; +using OpenAI.VectorStores; + +namespace Azure.AI.Projects.OpenAI.Tests.Samples; + +public class Sample_FileSearch_Streaming : ProjectsOpenAITestBase +{ + #region Snippet:Sample_ParseResponse_FileSearch_Streaming + private static void ParseResponse(StreamingResponseUpdate streamResponse) + { + if (streamResponse is StreamingResponseCreatedUpdate createUpdate) + { + Console.WriteLine($"Stream response created with ID: {createUpdate.Response.Id}"); + } + else if (streamResponse is StreamingResponseOutputTextDeltaUpdate textDelta) + { + Console.WriteLine($"Delta: {textDelta.Delta}"); + } + else if (streamResponse is StreamingResponseOutputTextDoneUpdate textDoneUpdate) + { + Console.WriteLine($"Response done with full message: {textDoneUpdate.Text}"); + } + else if (streamResponse is StreamingResponseOutputItemDoneUpdate itemDoneUpdate) + { + if (itemDoneUpdate.Item is MessageResponseItem messageItem) + { + foreach (ResponseContentPart part in messageItem.Content) + { + foreach (ResponseMessageAnnotation annotation in part.OutputTextAnnotations) + { + if (annotation is FileCitationMessageAnnotation fileAnnotation) + { + // Note fileAnnotation.Filename will be available in OpenAI package versions + // greater then 2.6.0. + Console.WriteLine($"File Citation - File ID: {fileAnnotation.FileId}"); + } + } + } + } + } + else if (streamResponse is StreamingResponseErrorUpdate errorUpdate) + { + throw new InvalidOperationException($"The stream has failed with the error: {errorUpdate.Message}"); + } + } + #endregion + + [Test] + [AsyncOnly] + public async Task FileSearch_StreamingAsync() + { + IgnoreSampleMayBe(); + #region Snippet:Sample_CreateAgentClient_FileSearch_Streaming +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + #endregion + #region Snippet:Sample_UploadFile_FileSearch_Streaming_Async + string filePath = "sample_file_for_upload.txt"; + File.WriteAllText( + path: filePath, + contents: "The word 'apple' uses the code 442345, while the word 'banana' uses the code 673457."); + OpenAIFile uploadedFile = await projectClient.OpenAI.Files.UploadFileAsync(filePath: filePath, purpose: FileUploadPurpose.Assistants); + File.Delete(filePath); + #endregion + #region Snippet:Sample_CreateVectorStore_FileSearch_Streaming_Async + VectorStoreCreationOptions options = new() + { + Name = "MySampleStore", + FileIds = { uploadedFile.Id } + }; + VectorStore vectorStore = await projectClient.OpenAI.VectorStores.CreateVectorStoreAsync(options); + #endregion + #region Snippet:Sample_CreateAgent_FileSearch_Streaming_Async + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a helpful agent that can help fetch data from files you know about.", + Tools = { ResponseTool.CreateFileSearchTool(vectorStoreIds: [vectorStore.Id]), } + }; + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent", + options: new(agentDefinition) + ); + #endregion + #region Snippet:Sample_CreateResponse_FileSearch_Streaming_Async + ProjectConversation conversation = await projectClient.OpenAI.Conversations.CreateProjectConversationAsync(); + ResponseCreationOptions responseOptions = new() + { + Agent = agentVersion, + AgentConversationId = conversation.Id, + }; + #endregion + + #region Snippet:Sample_StreamingResponse_FileSearch_Streaming_Async + await foreach (StreamingResponseUpdate streamResponse in projectClient.OpenAI.Responses.CreateResponseStreamingAsync("Can you give me the documented codes for 'banana' and 'orange'?", responseOptions)) + { + ParseResponse(streamResponse); + } + #endregion + #region Snippet:Sample_FollowUp_FileSearch_Streaming_Async + Console.WriteLine("Demonstrating follow-up query with streaming..."); + await foreach (StreamingResponseUpdate streamResponse in projectClient.OpenAI.Responses.CreateResponseStreamingAsync("What was my previous question about?", responseOptions)) + { + ParseResponse(streamResponse); + } + #endregion + + #region Snippet:Sample_Cleanup_FileSearch_Streaming_Async + await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion.Name, agentVersion: agentVersion.Version); + await projectClient.OpenAI.VectorStores.DeleteVectorStoreAsync(vectorStoreId: vectorStore.Id); + await projectClient.OpenAI.Files.DeleteFileAsync(uploadedFile.Id); + #endregion + } + + [Test] + [SyncOnly] + public void FileSearch_StreamingSync() + { + IgnoreSampleMayBe(); +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + #region Snippet:Sample_UploadFile_FileSearch_Streaming_Sync + string filePath = "sample_file_for_upload.txt"; + File.WriteAllText( + path: filePath, + contents: "The word 'apple' uses the code 442345, while the word 'banana' uses the code 673457."); + OpenAIFile uploadedFile = projectClient.OpenAI.Files.UploadFile(filePath: filePath, purpose: FileUploadPurpose.Assistants); + File.Delete(filePath); + #endregion + #region Snippet:Sample_CreateVectorStore_FileSearch_Streaming_Sync + VectorStoreCreationOptions options = new() + { + Name = "MySampleStore", + FileIds = { uploadedFile.Id } + }; + VectorStore vectorStore = projectClient.OpenAI.VectorStores.CreateVectorStore(options); + #endregion + #region Snippet:Sample_CreateAgent_FileSearch_Streaming_Sync + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a helpful agent that can help fetch data from files you know about.", + Tools = { ResponseTool.CreateFileSearchTool(vectorStoreIds: [vectorStore.Id]), } + }; + AgentVersion agentVersion = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent", + options: new(agentDefinition) + ); + #endregion + #region Snippet:Sample_CreateResponse_FileSearch_Streaming_Sync + ProjectConversation conversation = projectClient.OpenAI.Conversations.CreateProjectConversation(); + ResponseCreationOptions responseOptions = new() + { + Agent = agentVersion, + AgentConversationId = conversation.Id, + }; + #endregion + + #region Snippet:Sample_StreamingResponse_FileSearch_Streaming_Sync + foreach (StreamingResponseUpdate streamResponse in projectClient.OpenAI.Responses.CreateResponseStreaming("Can you give me the documented codes for 'banana' and 'orange'?", responseOptions)) + { + ParseResponse(streamResponse); + } + #endregion + #region Snippet:Sample_FollowUp_FileSearch_Streaming_Sync + Console.WriteLine("Demonstrating follow-up query with streaming..."); + foreach (StreamingResponseUpdate streamResponse in projectClient.OpenAI.Responses.CreateResponseStreaming("What was my previous question about?", responseOptions)) + { + ParseResponse(streamResponse); + } + #endregion + + #region Snippet:Sample_Cleanup_FileSearch_Streaming_Sync + projectClient.Agents.DeleteAgentVersion(agentName: agentVersion.Name, agentVersion: agentVersion.Version); + projectClient.OpenAI.VectorStores.DeleteVectorStore(vectorStoreId: vectorStore.Id); + projectClient.OpenAI.Files.DeleteFile(uploadedFile.Id); + #endregion + } + + public Sample_FileSearch_Streaming(bool isAsync) : base(isAsync) + { } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_Function.cs b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_Function.cs new file mode 100644 index 000000000000..b9216f394478 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_Function.cs @@ -0,0 +1,274 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.AI.Projects.OpenAI; +using Azure.Identity; +using Microsoft.ClientModel.TestFramework; +using NUnit.Framework; +using OpenAI; +using OpenAI.Responses; + +namespace Azure.AI.Projects.OpenAI.Tests.Samples; + +public class Sample_Function : ProjectsOpenAITestBase +{ + #region Snippet:Sample_Functions_Function + /// Example of a function that defines no parameters + /// returns user favorite city. + private static string GetUserFavoriteCity() => "Seattle, WA"; + + /// + /// Example of a function with a single required parameter + /// + /// The location to get nickname for. + /// The city nickname. + /// + private static string GetCityNickname(string location) => location switch + { + "Seattle, WA" => "The Emerald City", + _ => throw new NotImplementedException(), + }; + + /// + /// Example of a function with one required and one optional, enum parameter + /// + /// Get weather for location. + /// "c" or "f" + /// The weather in selected location. + /// + public static string GetWeatherAtLocation(string location, string temperatureUnit = "f") => location switch + { + "Seattle, WA" => temperatureUnit == "f" ? "70f" : "21c", + _ => throw new NotImplementedException() + }; + #endregion + #region Snippet:Sample_FunctionTools_Function + public static readonly FunctionTool getUserFavoriteCityTool = ResponseTool.CreateFunctionTool( + functionName: "getUserFavoriteCity", + functionDescription: "Gets the user's favorite city.", + functionParameters: BinaryData.FromString("{}"), + strictModeEnabled: false + ); + + public static readonly FunctionTool getCityNicknameTool = ResponseTool.CreateFunctionTool( + functionName: "getCityNickname", + functionDescription: "Gets the nickname of a city, e.g. 'LA' for 'Los Angeles, CA'.", + functionParameters: BinaryData.FromObjectAsJson( + new + { + Type = "object", + Properties = new + { + Location = new + { + Type = "string", + Description = "The city and state, e.g. San Francisco, CA", + }, + }, + Required = new[] { "location" }, + }, + new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase } + ), + strictModeEnabled: false + ); + + private static readonly FunctionTool getCurrentWeatherAtLocationTool = ResponseTool.CreateFunctionTool( + functionName: "getCurrentWeatherAtLocation", + functionDescription: "Gets the current weather at a provided location.", + functionParameters: BinaryData.FromObjectAsJson( + new + { + Type = "object", + Properties = new + { + Location = new + { + Type = "string", + Description = "The city and state, e.g. San Francisco, CA", + }, + Unit = new + { + Type = "string", + Enum = new[] { "c", "f" }, + }, + }, + Required = new[] { "location" }, + }, + new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase } + ), + strictModeEnabled: false + ); + #endregion + + # region Snippet:Sample_Resolver_Function + private static FunctionCallOutputResponseItem GetResolvedToolOutput(FunctionCallResponseItem item) + { + if (item.FunctionName == getUserFavoriteCityTool.FunctionName) + { + return ResponseItem.CreateFunctionCallOutputItem(item.CallId, GetUserFavoriteCity()); + } + using JsonDocument argumentsJson = JsonDocument.Parse(item.FunctionArguments); + if (item.FunctionName == getCityNicknameTool.FunctionName) + { + string locationArgument = argumentsJson.RootElement.GetProperty("location").GetString(); + return ResponseItem.CreateFunctionCallOutputItem(item.CallId, GetCityNickname(locationArgument)); + } + if (item.FunctionName == getCurrentWeatherAtLocationTool.FunctionName) + { + string locationArgument = argumentsJson.RootElement.GetProperty("location").GetString(); + if (argumentsJson.RootElement.TryGetProperty("unit", out JsonElement unitElement)) + { + string unitArgument = unitElement.GetString(); + return ResponseItem.CreateFunctionCallOutputItem(item.CallId, GetWeatherAtLocation(locationArgument, unitArgument)); + } + return ResponseItem.CreateFunctionCallOutputItem(item.CallId, GetWeatherAtLocation(locationArgument)); + } + return null; + } + #endregion + [Test] + [AsyncOnly] + public async Task FunctionAsync() + { + IgnoreSampleMayBe(); + #region Snippet:Sample_CreateAgentClient_Function +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + + #endregion + #region Snippet:Sample_CreateAgent_Function_Async + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a weather bot. Use the provided functions to help answer questions. " + + "Customize your responses to the user's preferences as much as possible and use friendly " + + "nicknames for cities whenever possible.", + Tools = { getUserFavoriteCityTool, getCityNicknameTool, getCurrentWeatherAtLocationTool } + }; + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent", + options: new(agentDefinition)); + #endregion + #region Snippet:Sample_CreateResponse_Function_Async + ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name); + + ResponseItem request = ResponseItem.CreateUserMessageItem("What's the weather like in my favorite city?"); + List inputItems = [request]; + bool funcionCalled = false; + OpenAIResponse response; + do + { + response = await CreateAndCheckResponseAsync( + responseClient, + inputItems); + funcionCalled = false; + foreach (ResponseItem responseItem in response.OutputItems) + { + inputItems.Add(responseItem); + if (responseItem is FunctionCallResponseItem functionToolCall) + { + Console.WriteLine($"Calling {functionToolCall.FunctionName}..."); + inputItems.Add(GetResolvedToolOutput(functionToolCall)); + funcionCalled = true; + } + } + } while (funcionCalled); + Console.WriteLine(response.GetOutputText()); + #endregion + + #region Snippet:Sample_Cleanup_Function_Async + await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion.Name, agentVersion: agentVersion.Version); + #endregion + } + + #region Snippet:Sample_CheckResponse_Function_Async + public static async Task CreateAndCheckResponseAsync(OpenAIResponseClient responseClient, IEnumerable items) + { + OpenAIResponse response = await responseClient.CreateResponseAsync( + inputItems: items); + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + return response; + } + #endregion + + #region Snippet:Sample_CheckResponse_Function_Sync + public static OpenAIResponse CreateAndCheckResponse(OpenAIResponseClient responseClient, IEnumerable items) + { + OpenAIResponse response = responseClient.CreateResponse( + inputItems: items); + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + return response; + } + #endregion + + [Test] + [SyncOnly] + public void FunctionSync() + { + IgnoreSampleMayBe(); +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + + #region Snippet:Sample_CreateAgent_Function_Sync + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a weather bot. Use the provided functions to help answer questions. " + + "Customize your responses to the user's preferences as much as possible and use friendly " + + "nicknames for cities whenever possible.", + Tools = { getUserFavoriteCityTool, getCityNicknameTool, getCurrentWeatherAtLocationTool } + }; + AgentVersion agentVersion = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent", + options: new(agentDefinition)); + #endregion + #region Snippet:Sample_CreateResponse_Function_Sync + OpenAIResponseClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name); + + ResponseItem request = ResponseItem.CreateUserMessageItem("What's the weather like in my favorite city?"); + List inputItems = [request]; + bool funcionCalled = false; + OpenAIResponse response; + do + { + response = CreateAndCheckResponse( + responseClient, + inputItems); + funcionCalled = false; + foreach (ResponseItem responseItem in response.OutputItems) + { + inputItems.Add(responseItem); + if (responseItem is FunctionCallResponseItem functionToolCall) + { + Console.WriteLine($"Calling {functionToolCall.FunctionName}..."); + inputItems.Add(GetResolvedToolOutput(functionToolCall)); + funcionCalled = true; + } + } + } while (funcionCalled); + Console.WriteLine(response.GetOutputText()); + #endregion + + #region Snippet:Sample_Cleanup_Function_Sync + projectClient.Agents.DeleteAgentVersion(agentName: agentVersion.Name, agentVersion: agentVersion.Version); + #endregion + } + + public Sample_Function(bool isAsync) : base(isAsync) + { } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_ImageGeneration.cs b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_ImageGeneration.cs new file mode 100644 index 000000000000..813d0aa7e71e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_ImageGeneration.cs @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using System.IO; +using Azure.Identity; +using Microsoft.ClientModel.TestFramework; +using NUnit.Framework; +using OpenAI; +using OpenAI.Responses; + +namespace Azure.AI.Projects.OpenAI.Tests.Samples; + +# region Snippet:Sample_CustomHeader_ImageGeneration +internal class HeaderPolicy(string image_deployment) : PipelinePolicy +{ + private const string image_deployment_header = "x-ms-oai-image-generation-deployment"; + + public override void Process(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) + { + message.Request.Headers.Add(image_deployment_header, image_deployment); + ProcessNext(message, pipeline, currentIndex); + } + + public override async ValueTask ProcessAsync(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) + { + // Add your desired header name and value + message.Request.Headers.Add(image_deployment_header, image_deployment); + await ProcessNextAsync(message, pipeline, currentIndex); + } +} +# endregion + +public class Sample_ImageGeneration : ProjectsOpenAITestBase +{ + [Test] + [AsyncOnly] + public async Task ImageGenerationAsync() + { + IgnoreSampleMayBe(); + #region Snippet:Sample_CreateClient_ImageGeneration +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); + var imageGenerationModelName = System.Environment.GetEnvironmentVariable("IMAGE_GENERATION_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; + var imageGenerationModelName = TestEnvironment.IMAGE_GENERATION_DEPLOYMENT_NAME; +#endif + AIProjectClientOptions projectOptions = new(); + projectOptions.AddPolicy(new HeaderPolicy(imageGenerationModelName), PipelinePosition.PerCall); + AIProjectClient projectClient = new( + endpoint: new Uri(projectEndpoint), + tokenProvider: new DefaultAzureCredential(), + options: projectOptions + ); + #endregion + + #region Snippet:Sample_CreateAgent_ImageGeneration_Async + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "Generate images based on user prompts.", + Tools = { + ResponseTool.CreateImageGenerationTool( + model: imageGenerationModelName, + quality: ImageGenerationToolQuality.Low, + size:ImageGenerationToolSize.W1024xH1024 + ) + } + }; + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent", + options: new(agentDefinition)); + #endregion + + #region Snippet:Sample_GetResponse_ImageGeneration_Async + ProjectOpenAIClientOptions options = new(); + ProjectOpenAIClient openAIClient = projectClient.GetProjectOpenAIClient(options: options); + ProjectResponsesClient responseClient = openAIClient.GetProjectResponsesClientForAgent(new AgentReference(name: agentVersion.Name)); + + OpenAIResponse response = await responseClient.CreateResponseAsync("Generate parody of Newton with apple."); + #endregion + #region Snippet:Sample_SaveImage_ImageGeneration + foreach (ResponseItem item in response.OutputItems) + { + if (item is ImageGenerationCallResponseItem imageItem) + { + File.WriteAllBytes("newton.png", imageItem.ImageResultBytes.ToArray()); + Console.WriteLine($"Image downloaded and saved to: {Path.GetFullPath("newton.png")}"); + } + } + #endregion + #region Snippet:Sample_Cleanup_ImageGeneration_Async + await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion.Name, agentVersion: agentVersion.Version); + #endregion + } + + [Test] + [SyncOnly] + public void ImageGeneration() + { + IgnoreSampleMayBe(); +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); + var imageGenerationModelName = System.Environment.GetEnvironmentVariable("IMAGE_GENERATION_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; + var imageGenerationModelName = TestEnvironment.IMAGE_GENERATION_DEPLOYMENT_NAME; +#endif + AIProjectClientOptions projectOptions = new(); + projectOptions.AddPolicy(new HeaderPolicy(imageGenerationModelName), PipelinePosition.PerCall); + AIProjectClient projectClient = new( + endpoint: new Uri(projectEndpoint), + tokenProvider: new DefaultAzureCredential(), + options: projectOptions + ); + + #region Snippet:Sample_CreateAgent_ImageGeneration_Sync + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "Generate images based on user prompts.", + Tools = { + ResponseTool.CreateImageGenerationTool( + model: imageGenerationModelName, + quality: ImageGenerationToolQuality.Low, + size:ImageGenerationToolSize.W1024xH1024 + ) + } + }; + AgentVersion agentVersion = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent", + options: new(agentDefinition)); + #endregion + + #region Snippet:Sample_GetResponse_ImageGeneration_Sync + ProjectOpenAIClientOptions options = new(); + ProjectOpenAIClient openAIClient = projectClient.GetProjectOpenAIClient(); + ProjectResponsesClient responseClient = openAIClient.GetProjectResponsesClientForAgent(new AgentReference(name: agentVersion.Name)); + + OpenAIResponse response = responseClient.CreateResponse("Generate parody of Newton with apple."); + #endregion + foreach (ResponseItem item in response.OutputItems) + { + if (item is ImageGenerationCallResponseItem imageItem) + { + File.WriteAllBytes("newton.png", imageItem.ImageResultBytes.ToArray()); + Console.WriteLine($"Image downloaded and saved to: {Path.GetFullPath("newton.png")}"); + } + } + #region Snippet:Sample_Cleanup_ImageGeneration_Sync + projectClient.Agents.DeleteAgentVersion(agentName: agentVersion.Name, agentVersion: agentVersion.Version); + #endregion + } + + public Sample_ImageGeneration(bool isAsync) : base(isAsync) + { } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_MemorySearchTool.cs b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_MemorySearchTool.cs new file mode 100644 index 000000000000..16ddb691e4c1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_MemorySearchTool.cs @@ -0,0 +1,233 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Azure.AI.Projects.OpenAI; +using Azure.Identity; +using Microsoft.ClientModel.TestFramework; +using NUnit.Framework; +using OpenAI; +using OpenAI.Responses; + +namespace Azure.AI.Projects.OpenAI.Tests.Samples; + +public class Sample_MemorySearchTool : ProjectsOpenAITestBase +{ + [Test] + [AsyncOnly] + public async Task MemorySearchToolAsync() + { + IgnoreSampleMayBe(); + #region Snippet:Sample_MemoryTool +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); + var embeddingDeploymentName = System.Environment.GetEnvironmentVariable("EMBEDDING_MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; + var embeddingDeploymentName = TestEnvironment.EMBEDDINGMODELDEPLOYMENTNAME; +#endif + AIProjectClient projectClient = new(new Uri(projectEndpoint), new DefaultAzureCredential()); + #endregion + + #region Snippet:Sample_CreateAgent_MemoryTool_Async + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a prompt agent." + }; + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent", + options: new(agentDefinition)); + #endregion + #region Snippet:Sample_CreateConversation_MemoryTool_Async + ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name); + + ResponseItem request = ResponseItem.CreateUserMessageItem("Hello, tell me a joke."); + OpenAIResponse response = await responseClient.CreateResponseAsync([request]); + #endregion + + #region Snippet:Sample_WriteOutput_MemoryTool_Async + string scope = "Joke from conversation"; + MemoryUpdateOptions memoryOptions = new(scope); + memoryOptions.Items.Add(request); + while (response.Status != ResponseStatus.Incomplete && response.Status != ResponseStatus.Failed && response.Status != ResponseStatus.Completed){ + await Task.Delay(TimeSpan.FromMilliseconds(500)); + response = await responseClient.GetResponseAsync(responseId: response.Id); + } + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + + foreach (ResponseItem item in response.OutputItems) + { + memoryOptions.Items.Add(item); + } + Console.WriteLine(response.GetOutputText()); + #endregion + #region Snippet:CreateMemoryStore_MemoryTool_Async + MemoryStoreDefaultDefinition memoryStoreDefinition = new( + chatModel: modelDeploymentName, + embeddingModel: embeddingDeploymentName + ); + MemoryStore memoryStore = await projectClient.MemoryStores.CreateMemoryStoreAsync( + name: "jokeMemory", + definition: memoryStoreDefinition, + description: "Memory store for conversation." + ); + MemoryUpdateResult updateResult = await projectClient.MemoryStores.UpdateMemoriesAsync(memoryStoreName: memoryStore.Name, options: memoryOptions); + while (updateResult.Status != MemoryStoreUpdateStatus.Failed && updateResult.Status != MemoryStoreUpdateStatus.Completed) + { + await Task.Delay(TimeSpan.FromMilliseconds(500)); + updateResult = await projectClient.MemoryStores.GetUpdateResultAsync(memoryStore.Name, updateResult.UpdateId); + } + #endregion + #region Snippet:Sample_CheckMemorySearch_Async + MemorySearchOptions opts = new(scope) + { + Items = { ResponseItem.CreateUserMessageItem("What was the joke?") }, + }; + MemoryStoreSearchResponse resp = await projectClient.MemoryStores.SearchMemoriesAsync( + memoryStoreName: memoryStore.Name, + options: new(scope) + ); + Console.WriteLine("==The output from memory tool.=="); + foreach (Azure.AI.Projects.MemorySearchItem item in resp.Memories) + { + Console.WriteLine(item.MemoryItem.Content); + } + Console.WriteLine("==End of memory tool output.=="); + #endregion + #region Snippet:Sample_CreateAgentWithTool_MemoryTool_Async + agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a prompt agent capable to access memorized conversation.", + }; + agentDefinition.Tools.Add(new MemorySearchTool(memoryStoreName: memoryStore.Name, scope: scope)); + AgentVersion agentVersion2 = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent2", + options: new(agentDefinition)); + #endregion + + #region Snippet:Sample_AnotherConversation_MemoryTool_Async + responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion2.Name); + + response = await responseClient.CreateResponseAsync( + "Please explain me the meaning of the joke from the previous conversation."); + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + Console.WriteLine(response.GetOutputText()); + #endregion + #region Snippet:Sample_Cleanup_MemoryTool_Async + await projectClient.MemoryStores.DeleteMemoryStoreAsync(name: memoryStore.Name); + await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion.Name, agentVersion: agentVersion.Version); + await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion2.Name, agentVersion: agentVersion2.Version); + #endregion + } + + [Test] + [SyncOnly] + public async Task MemorySearchTool() + { + IgnoreSampleMayBe(); +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); + var embeddingDeploymentName = System.Environment.GetEnvironmentVariable("EMBEDDING_MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; + var embeddingDeploymentName = TestEnvironment.EMBEDDINGMODELDEPLOYMENTNAME; +#endif + AIProjectClient projectClient = new(new Uri(projectEndpoint), new DefaultAzureCredential()); + #region Snippet:Sample_CreateAgent_MemoryTool_Sync + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a prompt agent." + }; + AgentVersion agentVersion = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent", + options: new(agentDefinition)); + #endregion + + #region Snippet:Sample_CreateConversation_MemoryTool_Sync + + ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name); + + ResponseItem request = ResponseItem.CreateUserMessageItem("Hello, tell me a joke."); + OpenAIResponse response = responseClient.CreateResponse([request]); + #endregion + + #region Snippet:Sample_WriteOutput_MemoryTool_Sync + string scope = "Joke from conversation"; + MemoryUpdateOptions memoryOptions = new(scope); + memoryOptions.Items.Add(request); + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + foreach (ResponseItem item in response.OutputItems) + { + memoryOptions.Items.Add(item); + } + Console.WriteLine(response.GetOutputText()); + #endregion + #region Snippet:CreateMemoryStore_MemoryTool_Sync + MemoryStoreDefaultDefinition memoryStoreDefinition = new( + chatModel: modelDeploymentName, + embeddingModel: embeddingDeploymentName + ); + MemoryStore memoryStore = projectClient.MemoryStores.CreateMemoryStore( + name: "jokeMemory", + definition: memoryStoreDefinition, + description: "Memory store for conversation." + ); + MemoryUpdateResult updateResult = projectClient.MemoryStores.UpdateMemories(memoryStoreName: memoryStore.Name, options: memoryOptions); + while (updateResult.Status != MemoryStoreUpdateStatus.Failed && updateResult.Status != MemoryStoreUpdateStatus.Completed) + { + Thread.Sleep(TimeSpan.FromMilliseconds(500)); + updateResult = await projectClient.MemoryStores.GetUpdateResultAsync(memoryStore.Name, updateResult.UpdateId); + } + #endregion + #region Snippet:Sample_CheckMemorySearch_Sync + MemorySearchOptions searchOptions = new(scope) + { + Items = { ResponseItem.CreateUserMessageItem("What was the joke?") }, + }; + MemoryStoreSearchResponse resp = projectClient.MemoryStores.SearchMemories( + memoryStoreName: memoryStore.Id, + options: searchOptions + ); + Console.WriteLine("==The output from memory search tool.=="); + foreach (Azure.AI.Projects.MemorySearchItem item in resp.Memories) + { + Console.WriteLine(item.MemoryItem.Content); + } + Console.WriteLine("==End of memory search tool output.=="); + #endregion + #region Snippet:Sample_CreateAgentWithTool_MemoryTool_Sync + agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a prompt agent capable to access memorized conversation.", + }; + agentDefinition.Tools.Add(new MemorySearchTool(memoryStoreName: memoryStore.Name, scope: scope)); + AgentVersion agentVersion2 = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent2", + options: new(agentDefinition)); + #endregion + + #region Snippet:Sample_AnotherConversation_MemoryTool_Sync + responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion2.Name); + + response = responseClient.CreateResponse( + [ResponseItem.CreateUserMessageItem("Please explain me the meaning of the joke from the previous conversation.")]); + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + Console.WriteLine(response.GetOutputText()); + #endregion + #region Snippet:Sample_Cleanup_MemoryTool_Sync + projectClient.MemoryStores.DeleteMemoryStore(name: memoryStore.Name); + projectClient.Agents.DeleteAgentVersion(agentName: agentVersion.Name, agentVersion: agentVersion.Version); + projectClient.Agents.DeleteAgentVersion(agentName: agentVersion2.Name, agentVersion: agentVersion2.Version); + #endregion + } + + public Sample_MemorySearchTool(bool isAsync) : base(isAsync) + { } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_ResponseBasic.cs b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_ResponseBasic.cs new file mode 100644 index 000000000000..4a1aae27e846 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_ResponseBasic.cs @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Azure.Identity; +using Microsoft.ClientModel.TestFramework; +using NUnit.Framework; +using OpenAI.Responses; + +namespace Azure.AI.Projects.OpenAI.Tests.Samples; + +public class Sample_ResponseBasic : ProjectsOpenAITestBase +{ + [Test] + [AsyncOnly] + public async Task AgentResponse() + { + IgnoreSampleMayBe(); + #region Snippet:Sample_CreateAgentClient_ResponseBasic +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + #endregion + #region Snippet:Sample_CreateResponse_Async + ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForModel(modelDeploymentName); + OpenAIResponse response = await responseClient.CreateResponseAsync("What is the size of France in square miles?"); + + #endregion + + #region Snippet:Sample_WriteOutput_ResponseBasic_Async + Console.WriteLine(response.GetOutputText()); + #endregion + } + + [Test] + [SyncOnly] + public void AgentResponseSync() + { + IgnoreSampleMayBe(); +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + #region Snippet:Sample_CreateResponse_Sync + ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForModel(modelDeploymentName); + OpenAIResponse response = responseClient.CreateResponse("What is the size of France in square miles?"); + #endregion + + #region Snippet:Sample_WriteOutput_ResponseBasic_Sync + Console.WriteLine(response.GetOutputText()); + #endregion + } + + [Test] + [AsyncOnly] + public async Task ListResponses() + { + IgnoreSampleMayBe(); +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); + var agentName = System.Environment.GetEnvironmentVariable("AGENT_NAME"); + var conversationId = System.Environment.GetEnvironmentVariable("KNOWN_CONVERSATION_ID"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; + var agentName = TestEnvironment.AGENT_NAME; + string conversationId = TestEnvironment.KNOWN_CONVERSATION_ID; +#endif + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + + #region Snippet:Sample_ListResponses_Async + await foreach (OpenAIResponse response + in projectClient.OpenAI.Responses.GetProjectResponsesAsync(agent: new AgentReference(agentName), conversationId: conversationId)) + { + Console.WriteLine($"Matching response: {response.Id}"); + } + #endregion + } + public Sample_ResponseBasic(bool isAsync) : base(isAsync) + { } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_ResponseStreaming.cs b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_ResponseStreaming.cs new file mode 100644 index 000000000000..7964574a91bc --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_ResponseStreaming.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Threading.Tasks; +using Azure.Identity; +using Microsoft.ClientModel.TestFramework; +using NUnit.Framework; +using OpenAI.Responses; + +namespace Azure.AI.Projects.OpenAI.Tests.Samples; + +public class Sample_ResponseStreaming : ProjectsOpenAITestBase +{ + [Test] + [AsyncOnly] + public async Task AgentResponseSteaming() + { + IgnoreSampleMayBe(); + #region Snippet:Sample_CreateAgentClient_ResponseStreaming +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + #endregion + #region Snippet:Sample_CreateResponseStreaming + ProjectResponsesClient responsesClient = projectClient.OpenAI.GetProjectResponsesClientForModel(modelDeploymentName); + #endregion + + #region Snippet:Sample_WriteOutput_ResponseStreaming_Async + await foreach (StreamingResponseUpdate streamResponse in responsesClient.CreateResponseStreamingAsync("What is the size of France in square miles?")) + { + if (streamResponse is StreamingResponseCreatedUpdate createUpdate) + { + Console.WriteLine($"Stream response created with ID: {createUpdate.Response.Id}"); + } + else if (streamResponse is StreamingResponseOutputTextDeltaUpdate textDelta) + { + Console.WriteLine($"Delta: {textDelta.Delta}"); + } + else if (streamResponse is StreamingResponseOutputTextDoneUpdate textDoneUpdate) + { + Console.WriteLine($"Response done with full message: {textDoneUpdate.Text}"); + } + else if (streamResponse is StreamingResponseErrorUpdate errorUpdate) + { + throw new InvalidOperationException($"The stream has failed with the error: {errorUpdate.Message}"); + } + } + #endregion + } + + [Test] + [SyncOnly] + public void AgentResponseStreamingSync() + { + IgnoreSampleMayBe(); +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + ProjectResponsesClient responsesClient = projectClient.OpenAI.GetProjectResponsesClientForModel(modelDeploymentName); + + #region Snippet:Sample_WriteOutput_ResponseStreaming_Sync + foreach (StreamingResponseUpdate streamResponse in responsesClient.CreateResponseStreaming("What is the size of France in square miles?")) + { + if (streamResponse is StreamingResponseCreatedUpdate createUpdate) + { + Console.WriteLine($"Stream response created with ID: {createUpdate.Response.Id}"); + } + else if (streamResponse is StreamingResponseOutputTextDeltaUpdate textDelta) + { + Console.WriteLine($"Delta: {textDelta.Delta}"); + } + else if (streamResponse is StreamingResponseOutputTextDoneUpdate textDoneUpdate) + { + Console.WriteLine($"Response done with full message: {textDoneUpdate.Text}"); + } + else if (streamResponse is StreamingResponseErrorUpdate errorUpdate) + { + throw new InvalidOperationException($"The stream has failed with the error: {errorUpdate.Message}"); + } + } + #endregion + } + + public Sample_ResponseStreaming(bool isAsync) : base(isAsync) + { } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_WebSearch.cs b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_WebSearch.cs new file mode 100644 index 000000000000..28fcbc3d06c9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Samples/Sample_WebSearch.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Threading.Tasks; +using Azure.Identity; +using Microsoft.ClientModel.TestFramework; +using NUnit.Framework; +using OpenAI.Responses; + +namespace Azure.AI.Projects.OpenAI.Tests.Samples; + +public class Sample_WebSearch : ProjectsOpenAITestBase +{ + [Test] + [AsyncOnly] + public async Task WebSearchAsync() + { + IgnoreSampleMayBe(); + #region Snippet:Sample_CreateAgentClient_WebSearch +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + + #endregion + #region Snippet:Sample_CreateAgent_WebSearch_Async + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a helpful assistant that can search the web", + Tools = { ResponseTool.CreateWebSearchTool(userLocation: WebSearchToolLocation.CreateApproximateLocation(country: "GB", city: "London", region: "London")), } + }; + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent", + options: new(agentDefinition)); + #endregion + #region Snippet:Sample_CreateResponse_WebSearch_Async + ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name); + + OpenAIResponse response = await responseClient.CreateResponseAsync("Show me the latest London Underground service updates"); + #endregion + + #region Snippet:Sample_WaitForResponse_WebSearch + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + Console.WriteLine(response.GetOutputText()); + #endregion + + #region Snippet:Sample_Cleanup_WebSearch_Async + await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion.Name, agentVersion: agentVersion.Version); + #endregion + } + + [Test] + [SyncOnly] + public void WebSearchSync() + { + IgnoreSampleMayBe(); +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECT_ENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + + #region Snippet:Sample_CreateAgent_WebSearch_Sync + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a helpful assistant that can search the web", + Tools = { ResponseTool.CreateWebSearchTool(userLocation: WebSearchToolLocation.CreateApproximateLocation(country: "GB", city: "London", region: "London")), } + }; + AgentVersion agentVersion = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent", + options: new(agentDefinition)); + #endregion + #region Snippet:Sample_CreateResponse_WebSearch_Sync + ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name); + + OpenAIResponse response = responseClient.CreateResponse("Show me the latest London Underground service updates"); + #endregion + + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + Console.WriteLine(response.GetOutputText()); + + #region Snippet:Sample_Cleanup_WebSearch_Sync + projectClient.Agents.DeleteAgentVersion(agentName: agentVersion.Name, agentVersion: agentVersion.Version); + #endregion + } + + public Sample_WebSearch(bool isAsync) : base(isAsync) + { } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/Utilities/GenAITraceVerifier.cs b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Utilities/GenAITraceVerifier.cs new file mode 100644 index 000000000000..5e87295b8f08 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Utilities/GenAITraceVerifier.cs @@ -0,0 +1,218 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text.Json; + +namespace Azure.AI.Projects.OpenAI.Tests.Utilities +{ + public class GenAiTraceVerifier + { + public bool CheckSpanAttributes(Activity span, Dictionary expectedAttributes) + { + var actualAttributes = new Dictionary(); + foreach (var tag in span.EnumerateTagObjects()) + { + actualAttributes[tag.Key] = tag.Value; + } + + foreach (var expected in expectedAttributes) + { + if (!actualAttributes.ContainsKey(expected.Key)) + { + Console.WriteLine($"Attribute '{expected.Key}' not found in span."); + return false; + } + + var actualValue = actualAttributes[expected.Key]; + + if (!CheckAttributeValue(expected.Value, actualValue)) + { + Console.WriteLine($"Attribute '{expected.Key}' value mismatch. Expected: {expected.Value}, Actual: {actualValue}"); + return false; + } + } + return true; + } + + public bool CheckSpanEvents(Activity span, List<(string Name, Dictionary Attributes)> expectedEvents) + { + var spanEvents = span.Events.ToList(); + return CheckSpanEvents(spanEvents, expectedEvents); + } + + public bool CheckSpanEvents(List spanEvents, List<(string Name, Dictionary Attributes)> expectedEvents, bool allowAdditionalEvents=false) + { + foreach (var expectedEvent in expectedEvents) + { + var matchingEvent = spanEvents.FirstOrDefault(e => e.Name == expectedEvent.Name); + if (matchingEvent.Name == null) + { + Console.WriteLine($"Event '{expectedEvent.Name}' not found."); + return false; + } + + var actualEventAttributes = new Dictionary(); + foreach (var tag in matchingEvent.EnumerateTagObjects()) + { + actualEventAttributes[tag.Key] = tag.Value; + } + + if (!CheckEventAttributes(expectedEvent.Attributes, actualEventAttributes)) + { + Console.WriteLine($"Event '{expectedEvent.Name}' attributes mismatch."); + return false; + } + + spanEvents.Remove(matchingEvent); + } + + if (spanEvents.Any() && !allowAdditionalEvents) + { + Console.WriteLine("Unexpected additional events found in span."); + return false; + } + + return true; + } + + public bool CheckEventAttributes(Dictionary expected, Dictionary actual) + { + var expectedKeys = new HashSet(expected.Keys); + var actualKeys = new HashSet(actual.Keys); + + if (!expectedKeys.SetEquals(actualKeys)) + { + Console.WriteLine("Event attribute keys mismatch."); + return false; + } + + foreach (var key in expectedKeys) + { + if (!CheckAttributeValue(expected[key], actual[key])) + { + Console.WriteLine($"Event attribute '{key}' value mismatch. Expected: {expected[key]}, Actual: {actual[key]}"); + return false; + } + } + + return true; + } + + private bool CheckAttributeValue(object expected, object actual) + { + if (expected is string expectedStr) + { + if (expectedStr == "*") + { + return !string.IsNullOrEmpty(actual?.ToString()); + } + if (expectedStr == "+") + { + if (double.TryParse(actual?.ToString(), out double numericValue)) + { + return numericValue >= 0; + } + return false; + } + if (IsValidJson(expectedStr) && IsValidJson(actual?.ToString())) + { + return CheckJsonString(expectedStr, actual.ToString()); + } + return expectedStr == actual?.ToString(); + } + else if (expected is Dictionary expectedDict) + { + if (actual is string actualStr && IsValidJson(actualStr)) + { + var actualDict = JsonSerializer.Deserialize>(actualStr); + return CheckEventAttributes(expectedDict, actualDict); + } + return false; + } + else if (expected is IEnumerable expectedList) + { + if (actual is string actualStr && IsValidJson(actualStr)) + { + var actualList = JsonSerializer.Deserialize>(actualStr); + return expectedList.SequenceEqual(actualList); + } + return false; + } + else + { + return expected.Equals(actual); + } + } + + private bool IsValidJson(string json) + { + if (string.IsNullOrWhiteSpace(json)) + return false; + try + { + JsonDocument.Parse(json); + return true; + } + catch + { + return false; + } + } + + private bool CheckJsonString(string expectedJson, string actualJson) + { + try + { + var expectedDoc = JsonDocument.Parse(expectedJson); + var actualDoc = JsonDocument.Parse(actualJson); + return JsonElementDeepEquals(expectedDoc.RootElement, actualDoc.RootElement); + } + catch + { + return false; + } + } + + private bool JsonElementDeepEquals(JsonElement expected, JsonElement actual) + { + if (expected.ValueKind != actual.ValueKind) + return false; + + switch (expected.ValueKind) + { + case JsonValueKind.Object: + var expectedProps = expected.EnumerateObject().OrderBy(p => p.Name).ToList(); + var actualProps = actual.EnumerateObject().OrderBy(p => p.Name).ToList(); + if (expectedProps.Count != actualProps.Count) + return false; + for (int i = 0; i < expectedProps.Count; i++) + { + if (expectedProps[i].Name != actualProps[i].Name || + !JsonElementDeepEquals(expectedProps[i].Value, actualProps[i].Value)) + return false; + } + return true; + + case JsonValueKind.Array: + var expectedItems = expected.EnumerateArray().ToList(); + var actualItems = actual.EnumerateArray().ToList(); + if (expectedItems.Count != actualItems.Count) + return false; + for (int i = 0; i < expectedItems.Count; i++) + { + if (!JsonElementDeepEquals(expectedItems[i], actualItems[i])) + return false; + } + return true; + case JsonValueKind.Number: + return expected.GetInt64() == actual.GetInt64(); + default: + return CheckAttributeValue(expected.GetString(), actual.GetString()); + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/Utilities/MemoryTraceExporter.cs b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Utilities/MemoryTraceExporter.cs new file mode 100644 index 000000000000..3e9f58d44aee --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Utilities/MemoryTraceExporter.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +using System.Collections.Generic; +using OpenTelemetry; +using System.Diagnostics; + +namespace Azure.AI.Projects.OpenAI.Tests.Utilities +{ + public class MemoryTraceExporter : BaseExporter + { + private readonly List _activities = new(); + + public override ExportResult Export(in Batch batch) + { + foreach (var activity in batch) + { + _activities.Add(activity); + } + return ExportResult.Success; + } + + public IReadOnlyList GetExportedActivities() => _activities; + + public void Clear() => _activities.Clear(); + } +} diff --git a/sdk/ai/Azure.AI.Projects.OpenAI/tests/Utils/TestPipelinePolicy.cs b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Utils/TestPipelinePolicy.cs new file mode 100644 index 000000000000..b79886a20e58 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects.OpenAI/tests/Utils/TestPipelinePolicy.cs @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Azure.AI.Projects.OpenAI.Tests; + +internal partial class TestPipelinePolicy : PipelinePolicy +{ + private Action _processMessageAction; + + public TestPipelinePolicy(Action processMessageAction) + { + _processMessageAction = processMessageAction; + } + + public override void Process(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) + { + _processMessageAction(message); // for request + ProcessNext(message, pipeline, currentIndex); + _processMessageAction(message); // for response + } + + public override async ValueTask ProcessAsync(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) + { + _processMessageAction(message); // for request + await ProcessNextAsync(message, pipeline, currentIndex); + _processMessageAction(message); // for response + } +} diff --git a/sdk/ai/Azure.AI.Projects/Azure.AI.Projects.sln b/sdk/ai/Azure.AI.Projects/Azure.AI.Projects.sln index 81113161b082..4c076370981d 100644 --- a/sdk/ai/Azure.AI.Projects/Azure.AI.Projects.sln +++ b/sdk/ai/Azure.AI.Projects/Azure.AI.Projects.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29709.97 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36623.8 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core.TestFramework", "..\..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj", "{ECC730C1-4AEA-420C-916A-66B19B79E4DC}" EndProject @@ -8,36 +8,20 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AI.Projects", "src\Az EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AI.Projects.Tests", "tests\Azure.AI.Projects.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AI.Projects.Agents.Tests", "tests_agents\Azure.AI.Projects.Agents.Tests.csproj", "{9FA7297A-688F-54A7-CB3B-B218D605BD39}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AI.Projects.OpenAI", "..\Azure.AI.Projects.OpenAI\src\Azure.AI.Projects.OpenAI.csproj", "{455D4CEC-1BB6-92B9-BB23-F52A9E409337}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU - {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.Build.0 = Debug|Any CPU {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.ActiveCfg = Release|Any CPU {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.Build.0 = Release|Any CPU - {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU - {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU - {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -46,6 +30,14 @@ Global {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + {9FA7297A-688F-54A7-CB3B-B218D605BD39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9FA7297A-688F-54A7-CB3B-B218D605BD39}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9FA7297A-688F-54A7-CB3B-B218D605BD39}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9FA7297A-688F-54A7-CB3B-B218D605BD39}.Release|Any CPU.Build.0 = Release|Any CPU + {455D4CEC-1BB6-92B9-BB23-F52A9E409337}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {455D4CEC-1BB6-92B9-BB23-F52A9E409337}.Debug|Any CPU.Build.0 = Debug|Any CPU + {455D4CEC-1BB6-92B9-BB23-F52A9E409337}.Release|Any CPU.ActiveCfg = Release|Any CPU + {455D4CEC-1BB6-92B9-BB23-F52A9E409337}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/sdk/ai/Azure.AI.Projects/CHANGELOG.md b/sdk/ai/Azure.AI.Projects/CHANGELOG.md index b1076d78a9de..74d466702ceb 100644 --- a/sdk/ai/Azure.AI.Projects/CHANGELOG.md +++ b/sdk/ai/Azure.AI.Projects/CHANGELOG.md @@ -1,19 +1,33 @@ # Release History -## 1.2.0-beta.1 (Unreleased) +## 1.2.0-beta.4 (2025-11-17) -### Features Added +### Bugs Fixed -### Breaking Changes +- Fixed an issue preventing telemetry from being logged. + +## 1.2.0-beta.3 (2025-11-15) ### Bugs Fixed -### Other Changes +- Addressed an issue that caused paginated responses like conversation items to never terminate when large numbers of items are fetched -## 1.1.0 (2025-11-03) +## 1.2.0-beta.2 (2025-11-14) + +### Bugs Fixed + +- Addressed an issue with memory store creation failing when not providing `metadata` + +## 1.2.0-beta.1 (2025-11-14) ### Features Added +This major update brings feature support for Microsoft Foundry Agents Service, integration with the new `Azure.AI.Projects.OpenAI` package, expanded evaluations capabilities, insights, red teaming, schedules, and more. + +## 1.1.0 (2025-11-03) + +### Other Changes +* Added `files` samples for operations create, delete, list, retrieve and download. - Remove `clientRequestId` parameter from `AIProjectConnectionsOperations` and `AIProjectDeploymentsOperations` methods as this value is controlled transparently by `System.ClientModel`. - Remove `type` parameter from `AzureAIProjectsModelFactory.BlobReferenceSasCredential` as this is a hardcoded value. - Remove `pendingUploadType` parameter from `AzureAIProjectsModelFactory.PendingUploadRequest` and `AzureAIProjectsModelFactory.PendingUploadConfiguration` as this is a hardcoded value. diff --git a/sdk/ai/Azure.AI.Projects/README.md b/sdk/ai/Azure.AI.Projects/README.md index 3daf8588ace1..c0bbbc70552f 100644 --- a/sdk/ai/Azure.AI.Projects/README.md +++ b/sdk/ai/Azure.AI.Projects/README.md @@ -1,7 +1,8 @@ # Azure AI Projects client library for .NET The AI Projects client library is part of the Azure AI Foundry SDK and provides easy access to resources in your Azure AI Foundry Project. Use it to: -* **Create and run Agents** using the `GetPersistentAgentsClient` method on the client. +* **Create and run Classic Agents** using the `GetPersistentAgentsClient` method on the client. +* **Create Agents** using `Agents` property. * **Enumerate AI Models** deployed to your Foundry Project using the `Deployments` operations. * **Enumerate connected Azure resources** in your Foundry project using the `Connections` operations. * **Upload documents and create Datasets** to reference them using the `Datasets` operations. @@ -23,6 +24,7 @@ The client library uses version `v1` of the AI Foundry [data plane REST APIs](ht - [Key concepts](#key-concepts) - [Create and authenticate the client](#create-and-authenticate-the-client) - [Examples](#examples) + - [Performing Classic Agent operations](#performing-classic-agent-operations) - [Performing Agent operations](#performing-agent-operations) - [Get an authenticated AzureOpenAI client](#get-an-authenticated-azureopenai-client) - [Get an authenticated ChatCompletionsClient](#get-an-authenticated-chatcompletionsclient) @@ -30,6 +32,7 @@ The client library uses version `v1` of the AI Foundry [data plane REST APIs](ht - [Connections operations](#connections-operations) - [Dataset operations](#dataset-operations) - [Indexes operations](#indexes-operations) + - [Files operations](#files-operations) - [Troubleshooting](#troubleshooting) - [Next steps](#next-steps) - [Contributing](#contributing) @@ -73,7 +76,7 @@ Once the `AIProjectClient` is created, you can use properties such as `.Datasets ## Examples -### Performing Agent operations +### Performing Classic Agent operations The `GetPersistentAgentsClient` method on the `AIProjectsClient` gives you access to an authenticated `PersistentAgentsClient` from the `Azure.AI.Agents.Persistent` package. Below we show how to create an Agent and delete it. To see what you can do with the agent you created, see the [many samples](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/ai/Azure.AI.Agents.Persistent/samples) associated with the `Azure.AI.Agents.Persistent` package. @@ -148,6 +151,94 @@ agentsClient.Threads.DeleteThread(threadId: thread.Id); agentsClient.Administration.DeleteAgent(agentId: agent.Id); ``` +### Performing Agent operations + +Azure.AI.Projects can be used to create, update and delete Agents. + +Create Agent + +Synchronous call: +```C# Snippet:Sample_CreateAgentVersionCRUD_Sync +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a prompt agent." +}; +AgentVersion agentVersion1 = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent1", + options: new(agentDefinition)); +Console.WriteLine($"Agent created (id: {agentVersion1.Id}, name: {agentVersion1.Name}, version: {agentVersion1.Version})"); +AgentVersion agentVersion2 = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent2", + options: new(agentDefinition)); +Console.WriteLine($"Agent created (id: {agentVersion2.Id}, name: {agentVersion2.Name}, version: {agentVersion2.Version})"); +``` + +Asynchronous call: +```C# Snippet:Sample_CreateAgentVersionCRUD_Async +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a prompt agent." +}; +AgentVersion agentVersion1 = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent1", + options: new(agentDefinition)); +Console.WriteLine($"Agent created (id: {agentVersion1.Id}, name: {agentVersion1.Name}, version: {agentVersion1.Version})"); +AgentVersion agentVersion2 = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent2", + options: new(agentDefinition)); +Console.WriteLine($"Agent created (id: {agentVersion2.Id}, name: {agentVersion2.Name}, version: {agentVersion2.Version})"); +``` + +Get Agent + +Synchronous call: +```C# Snippet:Sample_GetAgentCRUD_Sync +AgentRecord result = projectClient.Agents.GetAgent(agentVersion1.Name); +Console.WriteLine($"Agent created (id: {result.Id}, name: {result.Name})"); +``` + +Asynchronous call: +```C# Snippet:Sample_GetAgentCRUD_Async +AgentRecord result = await projectClient.Agents.GetAgentAsync(agentVersion1.Name); +Console.WriteLine($"Agent created (id: {result.Id}, name: {result.Name})"); +``` + +List Agents + +Synchronous call: +```C# Snippet:Sample_ListAgentsCRUD_Sync +foreach (AgentRecord agent in projectClient.Agents.GetAgents()) +{ + Console.WriteLine($"Listed Agent: id: {agent.Id}, name: {agent.Name}"); +} +``` + +Asynchronous call: +```C# Snippet:Sample_ListAgentsCRUD_Async +await foreach (AgentRecord agent in projectClient.Agents.GetAgentsAsync()) +{ + Console.WriteLine($"Listed Agent: id: {agent.Id}, name: {agent.Name}"); +} +``` + +Delete Agent + +Synchronous call: +```C# Snippet:Sample_DeleteAgentCRUD_Sync +projectClient.Agents.DeleteAgentVersion(agentName: agentVersion1.Name, agentVersion: agentVersion1.Version); +Console.WriteLine($"Agent deleted (name: {agentVersion1.Name}, version: {agentVersion1.Version})"); +projectClient.Agents.DeleteAgentVersion(agentName: agentVersion2.Name, agentVersion: agentVersion2.Version); +Console.WriteLine($"Agent deleted (name: {agentVersion2.Name}, version: {agentVersion2.Version})"); +``` + +Asynchronous call: +```C# Snippet:Sample_DeleteAgentCRUD_Async +await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion1.Name, agentVersion: agentVersion1.Version); +Console.WriteLine($"Agent deleted (name: {agentVersion1.Name}, version: {agentVersion1.Version})"); +await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion2.Name, agentVersion: agentVersion2.Version); +Console.WriteLine($"Agent deleted (name: {agentVersion2.Name}, version: {agentVersion2.Version})"); +``` + ### Get an authenticated AzureOpenAI client Your Azure AI Foundry project may have one or more OpenAI models deployed that support chat completions. Use the code below to get an authenticated ChatClient from the [Azure.AI.OpenAI](https://learn.microsoft.com/dotnet/api/overview/azure/ai.openai-readme?view=azure-dotnet) package, and execute a chat completions call. @@ -354,6 +445,46 @@ Console.WriteLine("Delete the Index version created above:"); projectClient.Indexes.Delete(name: indexName, version: indexVersion); ``` +### Files operations + +The code below shows some Files operations, which allow you to manage files through the OpenAI Files API. These operations are accessed via the AgentsClient's GetOpenAIClient() method. Full samples can be found under the "Files" folder in the [package samples][samples]. + +**Note:** File upload via OpenAIClient from AgentsClient.GetOpenAIClient() is not currently supported. + +```C# Snippet:AI_Projects_FileOperationsAsync +var endpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); +AIProjectClient projectClient = new(new Uri(endpoint), new DefaultAzureCredential()); +ProjectFilesClient fileClient = projectClient.OpenAI.Files; + +// Upload file +var dataDirectory = GetDataDirectory(); +var testFilePath = Path.Combine(dataDirectory, "training_set.jsonl"); +OpenAIFile uploadedFile = await fileClient.UploadFileAsync( + testFilePath, + FileUploadPurpose.FineTune); + +string fileId = uploadedFile.Id; + +// Retrieve file metadata +OpenAIFile retrievedFile = await fileClient.GetFileAsync(fileId); +Console.WriteLine($"File ID: {retrievedFile.Id}, Filename: {retrievedFile.Filename}"); + +// Download file content +BinaryData fileContent = await fileClient.DownloadFileAsync(fileId); +Console.WriteLine($"Content size: {fileContent.ToMemory().Length} bytes"); + +// List all files +ClientResult filesResult = await fileClient.GetFilesAsync(); +foreach (OpenAIFile file in filesResult.Value) +{ + Console.WriteLine($"File: {file.Filename} (ID: {file.Id})"); +} + +// Delete file +ClientResult deleteResult = await fileClient.DeleteFileAsync(fileId); +Console.WriteLine($"File deleted: {deleteResult.Value.Deleted}"); +``` + ## Troubleshooting Any operation that fails will throw a [RequestFailedException][RequestFailedException]. The exception's `code` will hold the HTTP response status code. The exception's `message` contains a detailed message that may be helpful in diagnosing the issue: diff --git a/sdk/ai/Azure.AI.Projects/_tsp-location.yaml b/sdk/ai/Azure.AI.Projects/_tsp-location.yaml new file mode 100644 index 000000000000..d42c96f1d3d3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/_tsp-location.yaml @@ -0,0 +1,5 @@ +directory: specification/ai/Azure.AI.Projects +commit: 36a958797ca18009a2008990674e71b0faf12def +repo: Azure/azure-rest-api-specs-pr +emitterPackageJsonPath: eng/http-client-csharp-emitter-package.json +entrypointFile: client.csharp.tsp \ No newline at end of file diff --git a/sdk/ai/Azure.AI.Projects/api/Azure.AI.Projects.net8.0.cs b/sdk/ai/Azure.AI.Projects/api/Azure.AI.Projects.net8.0.cs index b6e019b3dd83..b4705864886c 100644 --- a/sdk/ai/Azure.AI.Projects/api/Azure.AI.Projects.net8.0.cs +++ b/sdk/ai/Azure.AI.Projects/api/Azure.AI.Projects.net8.0.cs @@ -1,5 +1,197 @@ namespace Azure.AI.Projects { + public partial class AgentClusterInsightResult : Azure.AI.Projects.InsightResult, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AgentClusterInsightResult() { } + public Azure.AI.Projects.ClusterInsightResult ClusterInsight { get { throw null; } } + protected override Azure.AI.Projects.InsightResult JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.InsightResult PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.AgentClusterInsightResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.AgentClusterInsightResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AgentClusterInsightsRequest : Azure.AI.Projects.InsightRequest, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AgentClusterInsightsRequest(string agentName) { } + public string AgentName { get { throw null; } set { } } + public Azure.AI.Projects.InsightModelConfiguration ModelConfiguration { get { throw null; } set { } } + protected override Azure.AI.Projects.InsightRequest JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.InsightRequest PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.AgentClusterInsightsRequest System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.AgentClusterInsightsRequest System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AgenticIdentityCredentials : Azure.AI.Projects.AIProjectConnectionBaseCredential, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AgenticIdentityCredentials() { } + protected override Azure.AI.Projects.AIProjectConnectionBaseCredential JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.AIProjectConnectionBaseCredential PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.AgenticIdentityCredentials System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.AgenticIdentityCredentials System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct AgentKind : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public AgentKind(string value) { throw null; } + public static Azure.AI.Projects.AgentKind ContainerApp { get { throw null; } } + public static Azure.AI.Projects.AgentKind Hosted { get { throw null; } } + public static Azure.AI.Projects.AgentKind Prompt { get { throw null; } } + public static Azure.AI.Projects.AgentKind Workflow { get { throw null; } } + public bool Equals(Azure.AI.Projects.AgentKind other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.AgentKind left, Azure.AI.Projects.AgentKind right) { throw null; } + public static implicit operator Azure.AI.Projects.AgentKind (string value) { throw null; } + public static implicit operator Azure.AI.Projects.AgentKind? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.AgentKind left, Azure.AI.Projects.AgentKind right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct AgentListOrder : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public AgentListOrder(string value) { throw null; } + public static Azure.AI.Projects.AgentListOrder Ascending { get { throw null; } } + public static Azure.AI.Projects.AgentListOrder Descending { get { throw null; } } + public bool Equals(Azure.AI.Projects.AgentListOrder other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.AgentListOrder left, Azure.AI.Projects.AgentListOrder right) { throw null; } + public static implicit operator Azure.AI.Projects.AgentListOrder (string value) { throw null; } + public static implicit operator Azure.AI.Projects.AgentListOrder? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.AgentListOrder left, Azure.AI.Projects.AgentListOrder right) { throw null; } + public override string ToString() { throw null; } + } + public partial class AgentManifestOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AgentManifestOptions() { } + public string Description { get { throw null; } } + public string ManifestId { get { throw null; } } + public System.Collections.Generic.IDictionary Metadata { get { throw null; } } + public System.Collections.Generic.IDictionary ParameterValues { get { throw null; } } + protected virtual Azure.AI.Projects.AgentManifestOptions JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static implicit operator System.ClientModel.BinaryContent (Azure.AI.Projects.AgentManifestOptions agentManifestOptions) { throw null; } + protected virtual Azure.AI.Projects.AgentManifestOptions PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.AgentManifestOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.AgentManifestOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AgentTaxonomyInput : Azure.AI.Projects.EvaluationTaxonomyInput, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AgentTaxonomyInput(Azure.AI.Projects.AzureAIAgentTarget target, System.Collections.Generic.IEnumerable riskCategories) { } + public System.Collections.Generic.IList RiskCategories { get { throw null; } } + public Azure.AI.Projects.AzureAIAgentTarget Target { get { throw null; } set { } } + protected override Azure.AI.Projects.EvaluationTaxonomyInput JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.EvaluationTaxonomyInput PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.AgentTaxonomyInput System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.AgentTaxonomyInput System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AgentVersionCreationOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AgentVersionCreationOptions(Azure.AI.Projects.OpenAI.AgentDefinition definition) { } + public Azure.AI.Projects.OpenAI.AgentDefinition Definition { get { throw null; } set { } } + public string Description { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Metadata { get { throw null; } } + protected virtual Azure.AI.Projects.AgentVersionCreationOptions JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.AgentVersionCreationOptions PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.AgentVersionCreationOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.AgentVersionCreationOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AIProjectAgentsOperations + { + protected AIProjectAgentsOperations() { } + public System.ClientModel.Primitives.ClientPipeline Pipeline { get { throw null; } } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.ClientModel.ClientResult CreateAgent(System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.Threading.Tasks.Task CreateAgentAsync(System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.ClientModel.ClientResult CreateAgentFromManifest(System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.Threading.Tasks.Task CreateAgentFromManifestAsync(System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult CreateAgentVersion(string agentName, Azure.AI.Projects.AgentVersionCreationOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.ClientModel.ClientResult CreateAgentVersion(string agentName, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> CreateAgentVersionAsync(string agentName, Azure.AI.Projects.AgentVersionCreationOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.Threading.Tasks.Task CreateAgentVersionAsync(string agentName, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.ClientModel.ClientResult CreateAgentVersionFromManifest(string agentName, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult CreateAgentVersionFromManifest(string agentName, string manifestId, Azure.AI.Projects.AgentManifestOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.Threading.Tasks.Task CreateAgentVersionFromManifestAsync(string agentName, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> CreateAgentVersionFromManifestAsync(string agentName, string manifestId, Azure.AI.Projects.AgentManifestOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.ClientModel.ClientResult DeleteAgent(string agentName, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult DeleteAgent(string agentName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.Threading.Tasks.Task DeleteAgentAsync(string agentName, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAgentAsync(string agentName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.ClientModel.ClientResult DeleteAgentVersion(string agentName, string agentVersion, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult DeleteAgentVersion(string agentName, string agentVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.Threading.Tasks.Task DeleteAgentVersionAsync(string agentName, string agentVersion, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAgentVersionAsync(string agentName, string agentVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.ClientModel.ClientResult GetAgent(string agentName, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult GetAgent(string agentName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.Threading.Tasks.Task GetAgentAsync(string agentName, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task> GetAgentAsync(string agentName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.CollectionResult GetAgents(Azure.AI.Projects.AgentKind? kind = default(Azure.AI.Projects.AgentKind?), int? limit = default(int?), Azure.AI.Projects.AgentListOrder? order = default(Azure.AI.Projects.AgentListOrder?), string after = null, string before = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetAgentsAsync(Azure.AI.Projects.AgentKind? kind = default(Azure.AI.Projects.AgentKind?), int? limit = default(int?), Azure.AI.Projects.AgentListOrder? order = default(Azure.AI.Projects.AgentListOrder?), string after = null, string before = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.ClientModel.ClientResult GetAgentVersion(string agentName, string agentVersion, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult GetAgentVersion(string agentName, string agentVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.Threading.Tasks.Task GetAgentVersionAsync(string agentName, string agentVersion, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task> GetAgentVersionAsync(string agentName, string agentVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.CollectionResult GetAgentVersions(string agentName, int? limit = default(int?), Azure.AI.Projects.AgentListOrder? order = default(Azure.AI.Projects.AgentListOrder?), string after = null, string before = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetAgentVersionsAsync(string agentName, int? limit = default(int?), Azure.AI.Projects.AgentListOrder? order = default(Azure.AI.Projects.AgentListOrder?), string after = null, string before = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.ClientModel.ClientResult UpdateAgent(string agentName, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.Threading.Tasks.Task UpdateAgentAsync(string agentName, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.ClientModel.ClientResult UpdateAgentFromManifest(string agentName, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.Threading.Tasks.Task UpdateAgentFromManifestAsync(string agentName, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + } public partial class AIProjectBlobReference : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal AIProjectBlobReference() { } @@ -21,11 +213,20 @@ public partial class AIProjectClient : System.ClientModel.Primitives.ClientConne protected AIProjectClient() : base (default(int)) { } public AIProjectClient(System.Uri endpoint, System.ClientModel.AuthenticationTokenProvider tokenProvider) : base (default(int)) { } public AIProjectClient(System.Uri endpoint, System.ClientModel.AuthenticationTokenProvider tokenProvider, Azure.AI.Projects.AIProjectClientOptions options) : base (default(int)) { } + public virtual Azure.AI.Projects.AIProjectAgentsOperations Agents { get { throw null; } } public virtual Azure.AI.Projects.AIProjectConnectionsOperations Connections { get { throw null; } } public virtual Azure.AI.Projects.AIProjectDatasetsOperations Datasets { get { throw null; } } public virtual Azure.AI.Projects.AIProjectDeploymentsOperations Deployments { get { throw null; } } + public virtual Azure.AI.Projects.EvaluationRules EvaluationRules { get { throw null; } } + public virtual Azure.AI.Projects.EvaluationTaxonomies EvaluationTaxonomies { get { throw null; } } + public virtual Azure.AI.Projects.Evaluators Evaluators { get { throw null; } } public virtual Azure.AI.Projects.AIProjectIndexesOperations Indexes { get { throw null; } } + public virtual Azure.AI.Projects.Insights Insights { get { throw null; } } + public virtual Azure.AI.Projects.AIProjectMemoryStoresOperations MemoryStores { get { throw null; } } + public virtual Azure.AI.Projects.OpenAI.ProjectOpenAIClient OpenAI { get { throw null; } } public System.ClientModel.Primitives.ClientPipeline Pipeline { get { throw null; } } + public virtual Azure.AI.Projects.RedTeams RedTeams { get { throw null; } } + public virtual Azure.AI.Projects.Schedules Schedules { get { throw null; } } public virtual Azure.AI.Projects.AIProjectTelemetry Telemetry { get { throw null; } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override System.Collections.Generic.IEnumerable GetAllConnections() { throw null; } @@ -34,11 +235,14 @@ public AIProjectClient(System.Uri endpoint, System.ClientModel.AuthenticationTok } public partial class AIProjectClientOptions : System.ClientModel.Primitives.ClientPipelineOptions { - public AIProjectClientOptions(Azure.AI.Projects.AIProjectClientOptions.ServiceVersion version = Azure.AI.Projects.AIProjectClientOptions.ServiceVersion.V1) { } + public AIProjectClientOptions(Azure.AI.Projects.AIProjectClientOptions.ServiceVersion version = Azure.AI.Projects.AIProjectClientOptions.ServiceVersion.V2025_11_15_Preview) { } + public string UserAgentApplicationId { get { throw null; } set { } } public enum ServiceVersion { V2025_05_01 = 1, V1 = 2, + V2025_05_15_Preview = 3, + V2025_11_15_Preview = 4, } } public partial class AIProjectConnection : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel @@ -369,12 +573,142 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } + public partial class AIProjectMemoryStoresOperations + { + protected AIProjectMemoryStoresOperations() { } + public System.ClientModel.Primitives.ClientPipeline Pipeline { get { throw null; } } + public virtual System.ClientModel.ClientResult CreateMemoryStore(System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult CreateMemoryStore(string name, Azure.AI.Projects.MemoryStoreDefinition definition, string description = null, System.Collections.Generic.IDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task CreateMemoryStoreAsync(System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> CreateMemoryStoreAsync(string name, Azure.AI.Projects.MemoryStoreDefinition definition, string description = null, System.Collections.Generic.IDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult DeleteMemoryStore(string name, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult DeleteMemoryStore(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteMemoryStoreAsync(string name, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task> DeleteMemoryStoreAsync(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult DeleteScope(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult DeleteScope(string name, string scope, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteScopeAsync(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> DeleteScopeAsync(string name, string scope, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult GetMemoryStore(string name, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult GetMemoryStore(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GetMemoryStoreAsync(string name, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task> GetMemoryStoreAsync(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.CollectionResult GetMemoryStores(int? limit = default(int?), Azure.AI.Projects.AgentListOrder? order = default(Azure.AI.Projects.AgentListOrder?), string after = null, string before = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetMemoryStoresAsync(int? limit = default(int?), Azure.AI.Projects.AgentListOrder? order = default(Azure.AI.Projects.AgentListOrder?), string after = null, string before = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult GetUpdateResult(string name, string updateId, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult GetUpdateResult(string name, string updateId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GetUpdateResultAsync(string name, string updateId, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task> GetUpdateResultAsync(string name, string updateId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult SearchMemories(string memoryStoreName, Azure.AI.Projects.MemorySearchOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult SearchMemories(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> SearchMemoriesAsync(string memoryStoreName, Azure.AI.Projects.MemorySearchOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task SearchMemoriesAsync(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult UpdateMemories(string memoryStoreName, Azure.AI.Projects.MemoryUpdateOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult UpdateMemories(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateMemoriesAsync(string memoryStoreName, Azure.AI.Projects.MemoryUpdateOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task UpdateMemoriesAsync(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult UpdateMemoryStore(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult UpdateMemoryStore(string name, string description = null, System.Collections.Generic.IDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task UpdateMemoryStoreAsync(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateMemoryStoreAsync(string name, string description = null, System.Collections.Generic.IDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } public partial class AIProjectTelemetry { public AIProjectTelemetry(Azure.AI.Projects.AIProjectClient outerInstance) { } public string GetApplicationInsightsConnectionString() { throw null; } public System.Threading.Tasks.Task GetApplicationInsightsConnectionStringAsync() { throw null; } } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct AttackStrategy : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public AttackStrategy(string value) { throw null; } + public static Azure.AI.Projects.AttackStrategy AnsiiAttack { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy AsciiArt { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy AsciiSmuggler { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Atbash { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Base64 { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Baseline { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Binary { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Caesar { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy CharacterSpace { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy CharacterSwap { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Crescendo { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Diacritic { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Difficult { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Easy { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Flip { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy IndirectJailbreak { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Jailbreak { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Leetspeak { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Moderate { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Morse { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy MultiTurn { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy ROT13 { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy StringJoin { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy SuffixAppend { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Tense { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy UnicodeConfusable { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy UnicodeSubstitution { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Url { get { throw null; } } + public bool Equals(Azure.AI.Projects.AttackStrategy other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.AttackStrategy left, Azure.AI.Projects.AttackStrategy right) { throw null; } + public static implicit operator Azure.AI.Projects.AttackStrategy (string value) { throw null; } + public static implicit operator Azure.AI.Projects.AttackStrategy? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.AttackStrategy left, Azure.AI.Projects.AttackStrategy right) { throw null; } + public override string ToString() { throw null; } + } + public partial class AzureAIAgentTarget : Azure.AI.Projects.Target, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AzureAIAgentTarget(string name) { } + public string Name { get { throw null; } set { } } + public System.Collections.Generic.IList ToolDescriptions { get { throw null; } } + public string Version { get { throw null; } set { } } + protected override Azure.AI.Projects.Target JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.Target PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.AzureAIAgentTarget System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.AzureAIAgentTarget System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AzureAIAssistantTarget : Azure.AI.Projects.Target, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AzureAIAssistantTarget() { } + public string Id { get { throw null; } } + public System.Collections.Generic.IList ToolDescriptions { get { throw null; } } + protected override Azure.AI.Projects.Target JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.Target PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.AzureAIAssistantTarget System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.AzureAIAssistantTarget System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AzureAIModelTarget : Azure.AI.Projects.Target, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AzureAIModelTarget() { } + public string Model { get { throw null; } } + public Azure.AI.Projects.ModelSamplingParams SamplingParams { get { throw null; } } + protected override Azure.AI.Projects.Target JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.Target PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.AzureAIModelTarget System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.AzureAIModelTarget System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } public partial class AzureAIProjectsContext : System.ClientModel.Primitives.ModelReaderWriterContext { internal AzureAIProjectsContext() { } @@ -383,6 +717,11 @@ internal AzureAIProjectsContext() { } } public static partial class AzureAIProjectsModelFactory { + public static Azure.AI.Projects.AgentClusterInsightResult AgentClusterInsightResult(Azure.AI.Projects.ClusterInsightResult clusterInsight = null) { throw null; } + public static Azure.AI.Projects.AgentClusterInsightsRequest AgentClusterInsightsRequest(string agentName = null, Azure.AI.Projects.InsightModelConfiguration modelConfiguration = null) { throw null; } + public static Azure.AI.Projects.AgenticIdentityCredentials AgenticIdentityCredentials() { throw null; } + public static Azure.AI.Projects.AgentManifestOptions AgentManifestOptions(System.Collections.Generic.IDictionary metadata = null, string description = null, string manifestId = null, System.Collections.Generic.IDictionary parameterValues = null) { throw null; } + public static Azure.AI.Projects.AgentTaxonomyInput AgentTaxonomyInput(Azure.AI.Projects.AzureAIAgentTarget target = null, System.Collections.Generic.IEnumerable riskCategories = null) { throw null; } public static Azure.AI.Projects.AIProjectBlobReference AIProjectBlobReference(System.Uri blobUri = null, string storageAccountArmId = null, Azure.AI.Projects.BlobReferenceSasCredential credential = null) { throw null; } public static Azure.AI.Projects.AIProjectConnection AIProjectConnection(string name = null, string id = null, Azure.AI.Projects.ConnectionType type = default(Azure.AI.Projects.ConnectionType), string target = null, bool isDefault = false, Azure.AI.Projects.AIProjectConnectionBaseCredential credentials = null, System.Collections.Generic.IReadOnlyDictionary metadata = null) { throw null; } public static Azure.AI.Projects.AIProjectConnectionApiKeyCredential AIProjectConnectionApiKeyCredential(string apiKey = null) { throw null; } @@ -395,24 +734,100 @@ public static partial class AzureAIProjectsModelFactory public static Azure.AI.Projects.AIProjectDeployment AIProjectDeployment(string type = null, string name = null) { throw null; } public static Azure.AI.Projects.AIProjectIndex AIProjectIndex(string type = null, string id = null, string name = null, string version = null, string description = null, System.Collections.Generic.IDictionary tags = null) { throw null; } public static Azure.AI.Projects.AIProjectIndexFieldMapping AIProjectIndexFieldMapping(System.Collections.Generic.IEnumerable contentFields = null, string filepathField = null, string titleField = null, string urlField = null, System.Collections.Generic.IEnumerable vectorFields = null, System.Collections.Generic.IEnumerable metadataFields = null) { throw null; } + public static Azure.AI.Projects.AzureAIAgentTarget AzureAIAgentTarget(string name = null, string version = null, System.Collections.Generic.IEnumerable toolDescriptions = null) { throw null; } + public static Azure.AI.Projects.AzureAIAssistantTarget AzureAIAssistantTarget(string id = null, System.Collections.Generic.IEnumerable toolDescriptions = null) { throw null; } + public static Azure.AI.Projects.AzureAIModelTarget AzureAIModelTarget(string model = null, Azure.AI.Projects.ModelSamplingParams samplingParams = null) { throw null; } public static Azure.AI.Projects.AzureAISearchIndex AzureAISearchIndex(string id = null, string name = null, string version = null, string description = null, System.Collections.Generic.IDictionary tags = null, string connectionName = null, string indexName = null, Azure.AI.Projects.AIProjectIndexFieldMapping fieldMapping = null) { throw null; } + public static Azure.AI.Projects.AzureOpenAIModelConfiguration AzureOpenAIModelConfiguration(string modelDeploymentName = null) { throw null; } public static Azure.AI.Projects.BlobReferenceSasCredential BlobReferenceSasCredential(System.Uri sasUri = null) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.AI.Projects.BlobReferenceSasCredential BlobReferenceSasCredential(System.Uri sasUri, string type) { throw null; } + public static Azure.AI.Projects.ChartCoordinate ChartCoordinate(int x = 0, int y = 0, int size = 0) { throw null; } + public static Azure.AI.Projects.ChatSummaryMemoryItem ChatSummaryMemoryItem(string memoryId = null, System.DateTimeOffset updatedAt = default(System.DateTimeOffset), string scope = null, string content = null) { throw null; } + public static Azure.AI.Projects.ClusterInsightResult ClusterInsightResult(Azure.AI.Projects.InsightSummary summary = null, System.Collections.Generic.IEnumerable clusters = null, System.Collections.Generic.IDictionary coordinates = null) { throw null; } + public static Azure.AI.Projects.ClusterTokenUsage ClusterTokenUsage(int inputTokenUsage = 0, int outputTokenUsage = 0, int totalTokenUsage = 0) { throw null; } + public static Azure.AI.Projects.CodeBasedEvaluatorDefinition CodeBasedEvaluatorDefinition(System.BinaryData initParameters = null, System.BinaryData dataSchema = null, System.Collections.Generic.IDictionary metrics = null, string codeText = null) { throw null; } + public static Azure.AI.Projects.ContinuousEvaluationRuleAction ContinuousEvaluationRuleAction(string evalId = null, int? maxHourlyRuns = default(int?)) { throw null; } + public static Azure.AI.Projects.CreateAgentVersionFromManifestRequest CreateAgentVersionFromManifestRequest(System.Collections.Generic.IDictionary metadata = null, string description = null, string manifestId = null, System.Collections.Generic.IDictionary parameterValues = null) { throw null; } + public static Azure.AI.Projects.CronTrigger CronTrigger(string expression = null, string timeZone = null, string startTime = null, string endTime = null) { throw null; } + public static Azure.AI.Projects.DailyRecurrenceSchedule DailyRecurrenceSchedule(System.Collections.Generic.IEnumerable hours = null) { throw null; } public static Azure.AI.Projects.DatasetCredential DatasetCredential(Azure.AI.Projects.AIProjectBlobReference blobReference = null) { throw null; } + public static Azure.AI.Projects.DeleteMemoryStoreResponse DeleteMemoryStoreResponse(string name = null, bool deleted = false) { throw null; } public static Azure.AI.Projects.EmbeddingConfiguration EmbeddingConfiguration(string modelDeploymentName = null, string embeddingField = null) { throw null; } + public static Azure.AI.Projects.EvalCompareReport EvalCompareReport(System.Collections.Generic.IEnumerable comparisons = null, string method = null) { throw null; } + public static Azure.AI.Projects.EvalResult EvalResult(string name = null, string type = null, float score = 0f, bool passed = false) { throw null; } + public static Azure.AI.Projects.EvalRunResultCompareItem EvalRunResultCompareItem(string treatmentRunId = null, Azure.AI.Projects.EvalRunResultSummary treatmentRunSummary = null, float deltaEstimate = 0f, float pValue = 0f, Azure.AI.Projects.TreatmentEffectType treatmentEffect = default(Azure.AI.Projects.TreatmentEffectType)) { throw null; } + public static Azure.AI.Projects.EvalRunResultComparison EvalRunResultComparison(string testingCriteria = null, string metric = null, string evaluator = null, Azure.AI.Projects.EvalRunResultSummary baselineRunSummary = null, System.Collections.Generic.IEnumerable compareItems = null) { throw null; } + public static Azure.AI.Projects.EvalRunResultSummary EvalRunResultSummary(string runId = null, int sampleCount = 0, float average = 0f, float standardDeviation = 0f) { throw null; } + public static Azure.AI.Projects.EvaluationComparisonRequest EvaluationComparisonRequest(string evalId = null, string baselineRunId = null, System.Collections.Generic.IEnumerable treatmentRunIds = null) { throw null; } + public static Azure.AI.Projects.EvaluationResultSample EvaluationResultSample(string id = null, System.Collections.Generic.IDictionary features = null, System.Collections.Generic.IDictionary correlationInfo = null, Azure.AI.Projects.EvalResult evaluationResult = null) { throw null; } + public static Azure.AI.Projects.EvaluationRule EvaluationRule(string id = null, string displayName = null, string description = null, Azure.AI.Projects.EvaluationRuleAction action = null, Azure.AI.Projects.EvaluationRuleFilter filter = null, Azure.AI.Projects.EvaluationRuleEventType eventType = default(Azure.AI.Projects.EvaluationRuleEventType), bool enabled = false, System.Collections.Generic.IReadOnlyDictionary systemData = null) { throw null; } + public static Azure.AI.Projects.EvaluationRuleAction EvaluationRuleAction(string type = null) { throw null; } + public static Azure.AI.Projects.EvaluationRuleFilter EvaluationRuleFilter(string agentName = null) { throw null; } + public static Azure.AI.Projects.EvaluationRunClusterInsightResult EvaluationRunClusterInsightResult(Azure.AI.Projects.ClusterInsightResult clusterInsight = null) { throw null; } + public static Azure.AI.Projects.EvaluationRunClusterInsightsRequest EvaluationRunClusterInsightsRequest(string evalId = null, System.Collections.Generic.IEnumerable runIds = null, Azure.AI.Projects.InsightModelConfiguration modelConfiguration = null) { throw null; } + public static Azure.AI.Projects.EvaluationScheduleTask EvaluationScheduleTask(System.Collections.Generic.IDictionary configuration = null, string evalId = null, Azure.AI.Projects.EvaluationScheduleTaskEvalRun evalRun = null) { throw null; } + public static Azure.AI.Projects.EvaluationScheduleTaskEvalRun EvaluationScheduleTaskEvalRun() { throw null; } + public static Azure.AI.Projects.EvaluationTaxonomy EvaluationTaxonomy(string id = null, string name = null, string version = null, string description = null, System.Collections.Generic.IDictionary tags = null, Azure.AI.Projects.EvaluationTaxonomyInput taxonomyInput = null, System.Collections.Generic.IEnumerable taxonomyCategories = null, System.Collections.Generic.IDictionary properties = null) { throw null; } + public static Azure.AI.Projects.EvaluationTaxonomyInput EvaluationTaxonomyInput(string type = null) { throw null; } + public static Azure.AI.Projects.EvaluatorDefinition EvaluatorDefinition(string type = null, System.BinaryData initParameters = null, System.BinaryData dataSchema = null, System.Collections.Generic.IDictionary metrics = null) { throw null; } + public static Azure.AI.Projects.EvaluatorMetric EvaluatorMetric(Azure.AI.Projects.EvaluatorMetricType? type = default(Azure.AI.Projects.EvaluatorMetricType?), Azure.AI.Projects.EvaluatorMetricDirection? desirableDirection = default(Azure.AI.Projects.EvaluatorMetricDirection?), float? minValue = default(float?), float? maxValue = default(float?), bool? isPrimary = default(bool?)) { throw null; } + public static Azure.AI.Projects.EvaluatorVersion EvaluatorVersion(string displayName = null, System.Collections.Generic.IDictionary metadata = null, Azure.AI.Projects.EvaluatorType evaluatorType = default(Azure.AI.Projects.EvaluatorType), System.Collections.Generic.IEnumerable categories = null, Azure.AI.Projects.EvaluatorDefinition definition = null, string createdBy = null, long createdAt = (long)0, long modifiedAt = (long)0, string id = null, string name = null, string version = null, string description = null, System.Collections.Generic.IDictionary tags = null) { throw null; } public static Azure.AI.Projects.FileDataset FileDataset(System.Uri dataUri = null, bool? isReference = default(bool?), string connectionName = null, string id = null, string name = null, string version = null, string description = null, System.Collections.Generic.IDictionary tags = null) { throw null; } public static Azure.AI.Projects.FolderDataset FolderDataset(System.Uri dataUri = null, bool? isReference = default(bool?), string connectionName = null, string id = null, string name = null, string version = null, string description = null, System.Collections.Generic.IDictionary tags = null) { throw null; } + public static Azure.AI.Projects.HourlyRecurrenceSchedule HourlyRecurrenceSchedule() { throw null; } + public static Azure.AI.Projects.HumanEvaluationRuleAction HumanEvaluationRuleAction(string templateId = null) { throw null; } + public static Azure.AI.Projects.Insight Insight(string id = null, Azure.AI.Projects.InsightsMetadata metadata = null, Azure.Core.Foundations.OperationStatus state = default(Azure.Core.Foundations.OperationStatus), string displayName = null, Azure.AI.Projects.InsightRequest request = null, Azure.AI.Projects.InsightResult result = null) { throw null; } + public static Azure.AI.Projects.InsightCluster InsightCluster(string id = null, string label = null, string suggestion = null, string suggestionTitle = null, string description = null, int weight = 0, System.Collections.Generic.IEnumerable subClusters = null, System.Collections.Generic.IEnumerable samples = null) { throw null; } + public static Azure.AI.Projects.InsightModelConfiguration InsightModelConfiguration(string modelDeploymentName = null) { throw null; } + public static Azure.AI.Projects.InsightRequest InsightRequest(string type = null) { throw null; } + public static Azure.AI.Projects.InsightResult InsightResult(string type = null) { throw null; } + public static Azure.AI.Projects.InsightSample InsightSample(string id = null, string type = null, System.Collections.Generic.IDictionary features = null, System.Collections.Generic.IDictionary correlationInfo = null) { throw null; } + public static Azure.AI.Projects.InsightScheduleTask InsightScheduleTask(System.Collections.Generic.IDictionary configuration = null, Azure.AI.Projects.Insight insight = null) { throw null; } + public static Azure.AI.Projects.InsightsMetadata InsightsMetadata(System.DateTimeOffset createdAt = default(System.DateTimeOffset), System.DateTimeOffset? completedAt = default(System.DateTimeOffset?)) { throw null; } + public static Azure.AI.Projects.InsightSummary InsightSummary(int sampleCount = 0, int uniqueSubclusterCount = 0, int uniqueClusterCount = 0, string method = null, Azure.AI.Projects.ClusterTokenUsage usage = null) { throw null; } public static Azure.AI.Projects.ManagedAzureAISearchIndex ManagedAzureAISearchIndex(string id = null, string name = null, string version = null, string description = null, System.Collections.Generic.IDictionary tags = null, string vectorStoreId = null) { throw null; } + public static Azure.AI.Projects.MemoryItem MemoryItem(string memoryId = null, System.DateTimeOffset updatedAt = default(System.DateTimeOffset), string scope = null, string content = null, string kind = null) { throw null; } + public static Azure.AI.Projects.MemoryOperation MemoryOperation(Azure.AI.Projects.MemoryOperationKind kind = default(Azure.AI.Projects.MemoryOperationKind), Azure.AI.Projects.MemoryItem memoryItem = null) { throw null; } + public static Azure.AI.Projects.MemorySearchItem MemorySearchItem(Azure.AI.Projects.MemoryItem memoryItem = null) { throw null; } + public static Azure.AI.Projects.MemorySearchResultOptions MemorySearchResultOptions(int? maxMemories = default(int?)) { throw null; } + public static Azure.AI.Projects.MemoryStore MemoryStore(string id = null, System.DateTimeOffset createdAt = default(System.DateTimeOffset), System.DateTimeOffset updatedAt = default(System.DateTimeOffset), string name = null, string description = null, System.Collections.Generic.IDictionary metadata = null, Azure.AI.Projects.MemoryStoreDefinition definition = null) { throw null; } + public static Azure.AI.Projects.MemoryStoreDefaultDefinition MemoryStoreDefaultDefinition(string chatModel = null, string embeddingModel = null, Azure.AI.Projects.MemoryStoreDefaultOptions options = null) { throw null; } + public static Azure.AI.Projects.MemoryStoreDefaultOptions MemoryStoreDefaultOptions(bool userProfileEnabled = false, string userProfileDetails = null, bool chatSummaryEnabled = false) { throw null; } + public static Azure.AI.Projects.MemoryStoreDefinition MemoryStoreDefinition(string kind = null) { throw null; } + public static Azure.AI.Projects.MemoryStoreDeleteScopeResponse MemoryStoreDeleteScopeResponse(string name = null, string scope = null, bool deleted = false) { throw null; } + public static Azure.AI.Projects.MemoryStoreOperationUsage MemoryStoreOperationUsage(int embeddingTokens = 0, int inputTokens = 0, Azure.AI.Projects.MemoryStoreOperationUsageInputTokensDetails inputTokensDetails = null, int outputTokens = 0, Azure.AI.Projects.MemoryStoreOperationUsageOutputTokensDetails outputTokensDetails = null, int totalTokens = 0) { throw null; } + public static Azure.AI.Projects.MemoryStoreOperationUsageInputTokensDetails MemoryStoreOperationUsageInputTokensDetails(int cachedTokens = 0) { throw null; } + public static Azure.AI.Projects.MemoryStoreOperationUsageOutputTokensDetails MemoryStoreOperationUsageOutputTokensDetails(int reasoningTokens = 0) { throw null; } + public static Azure.AI.Projects.MemoryStoreSearchResponse MemoryStoreSearchResponse(string searchId = null, System.Collections.Generic.IEnumerable memories = null, Azure.AI.Projects.MemoryStoreOperationUsage usage = null) { throw null; } + public static Azure.AI.Projects.MemoryUpdateResultDetails MemoryUpdateResultDetails(System.Collections.Generic.IEnumerable memoryOperations = null, Azure.AI.Projects.MemoryStoreOperationUsage usage = null) { throw null; } public static Azure.AI.Projects.ModelDeployment ModelDeployment(string name = null, string modelName = null, string modelVersion = null, string modelPublisher = null, System.Collections.Generic.IReadOnlyDictionary capabilities = null, Azure.AI.Projects.ModelDeploymentSku sku = null, string connectionName = null) { throw null; } public static Azure.AI.Projects.ModelDeploymentSku ModelDeploymentSku(long capacity = (long)0, string family = null, string name = null, string size = null, string tier = null) { throw null; } + public static Azure.AI.Projects.ModelSamplingParams ModelSamplingParams(float temperature = 0f, float topP = 0f, int seed = 0, int maxCompletionTokens = 0) { throw null; } + public static Azure.AI.Projects.MonthlyRecurrenceSchedule MonthlyRecurrenceSchedule(System.Collections.Generic.IEnumerable daysOfMonth = null) { throw null; } public static Azure.AI.Projects.NoAuthenticationCredentials NoAuthenticationCredentials() { throw null; } + public static Azure.AI.Projects.OneTimeTrigger OneTimeTrigger(string triggerAt = null, string timeZone = null) { throw null; } public static Azure.AI.Projects.PendingUploadConfiguration PendingUploadConfiguration(string pendingUploadId = null, string connectionName = null) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.AI.Projects.PendingUploadConfiguration PendingUploadConfiguration(string pendingUploadId, string connectionName, Azure.AI.Projects.PendingUploadType pendingUploadType) { throw null; } public static Azure.AI.Projects.PendingUploadResult PendingUploadResult(Azure.AI.Projects.AIProjectBlobReference blobReference = null, string pendingUploadId = null, string version = null) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.AI.Projects.PendingUploadResult PendingUploadResult(Azure.AI.Projects.AIProjectBlobReference blobReference, string pendingUploadId, string version, Azure.AI.Projects.PendingUploadType pendingUploadType) { throw null; } + public static Azure.AI.Projects.PromptBasedEvaluatorDefinition PromptBasedEvaluatorDefinition(System.BinaryData initParameters = null, System.BinaryData dataSchema = null, System.Collections.Generic.IDictionary metrics = null, string promptText = null) { throw null; } + public static Azure.AI.Projects.RecurrenceSchedule RecurrenceSchedule(string type = null) { throw null; } + public static Azure.AI.Projects.RecurrenceTrigger RecurrenceTrigger(string startTime = null, string endTime = null, string timeZone = null, int interval = 0, Azure.AI.Projects.RecurrenceSchedule schedule = null) { throw null; } + public static Azure.AI.Projects.RedTeam RedTeam(string name = null, string displayName = null, int? numTurns = default(int?), System.Collections.Generic.IEnumerable attackStrategies = null, bool? simulationOnly = default(bool?), System.Collections.Generic.IEnumerable riskCategories = null, string applicationScenario = null, System.Collections.Generic.IDictionary tags = null, System.Collections.Generic.IDictionary properties = null, string status = null, Azure.AI.Projects.TargetConfig target = null) { throw null; } + public static Azure.AI.Projects.Schedule Schedule(string id = null, string displayName = null, string description = null, bool enabled = false, Azure.AI.Projects.ScheduleProvisioningStatus? provisioningStatus = default(Azure.AI.Projects.ScheduleProvisioningStatus?), Azure.AI.Projects.Trigger trigger = null, Azure.AI.Projects.ScheduleTask task = null, System.Collections.Generic.IDictionary tags = null, System.Collections.Generic.IDictionary properties = null, System.Collections.Generic.IReadOnlyDictionary systemData = null) { throw null; } + public static Azure.AI.Projects.ScheduleRun ScheduleRun(string runId = null, string scheduleId = null, bool success = false, string triggerTime = null, string error = null, System.Collections.Generic.IReadOnlyDictionary properties = null) { throw null; } + public static Azure.AI.Projects.ScheduleTask ScheduleTask(string type = null, System.Collections.Generic.IDictionary configuration = null) { throw null; } + public static Azure.AI.Projects.Target Target(string type = null) { throw null; } + public static Azure.AI.Projects.TargetConfig TargetConfig(string type = null) { throw null; } + public static Azure.AI.Projects.TaxonomyCategory TaxonomyCategory(string id = null, string name = null, string description = null, Azure.AI.Projects.RiskCategory riskCategory = default(Azure.AI.Projects.RiskCategory), System.Collections.Generic.IEnumerable subCategories = null, System.Collections.Generic.IDictionary properties = null) { throw null; } + public static Azure.AI.Projects.TaxonomySubCategory TaxonomySubCategory(string id = null, string name = null, string description = null, bool enabled = false, System.Collections.Generic.IDictionary properties = null) { throw null; } + public static Azure.AI.Projects.ToolDescription ToolDescription(string name = null, string description = null) { throw null; } + public static Azure.AI.Projects.Trigger Trigger(string type = null) { throw null; } + public static Azure.AI.Projects.UserProfileMemoryItem UserProfileMemoryItem(string memoryId = null, System.DateTimeOffset updatedAt = default(System.DateTimeOffset), string scope = null, string content = null) { throw null; } + public static Azure.AI.Projects.WeeklyRecurrenceSchedule WeeklyRecurrenceSchedule(System.Collections.Generic.IEnumerable daysOfWeek = null) { throw null; } } public partial class AzureAISearchIndex : Azure.AI.Projects.AIProjectIndex, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { @@ -430,6 +845,20 @@ protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter write string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } + public partial class AzureOpenAIModelConfiguration : Azure.AI.Projects.TargetConfig, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AzureOpenAIModelConfiguration(string modelDeploymentName) { } + public string ModelDeploymentName { get { throw null; } set { } } + protected override Azure.AI.Projects.TargetConfig JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.TargetConfig PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.AzureOpenAIModelConfiguration System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.AzureOpenAIModelConfiguration System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } public partial class BlobReferenceSasCredential : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal BlobReferenceSasCredential() { } @@ -445,6 +874,81 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } + public partial class ChartCoordinate : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ChartCoordinate() { } + public int Size { get { throw null; } } + public int X { get { throw null; } } + public int Y { get { throw null; } } + protected virtual Azure.AI.Projects.ChartCoordinate JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.ChartCoordinate PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.ChartCoordinate System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.ChartCoordinate System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ChatSummaryMemoryItem : Azure.AI.Projects.MemoryItem, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ChatSummaryMemoryItem(string memoryId, System.DateTimeOffset updatedAt, string scope, string content) { } + protected override Azure.AI.Projects.MemoryItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.MemoryItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.ChatSummaryMemoryItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.ChatSummaryMemoryItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ClusterInsightResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ClusterInsightResult() { } + public System.Collections.Generic.IList Clusters { get { throw null; } } + public System.Collections.Generic.IDictionary Coordinates { get { throw null; } } + public Azure.AI.Projects.InsightSummary Summary { get { throw null; } } + protected virtual Azure.AI.Projects.ClusterInsightResult JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.ClusterInsightResult PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.ClusterInsightResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.ClusterInsightResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ClusterTokenUsage : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ClusterTokenUsage() { } + public int InputTokenUsage { get { throw null; } } + public int OutputTokenUsage { get { throw null; } } + public int TotalTokenUsage { get { throw null; } } + protected virtual Azure.AI.Projects.ClusterTokenUsage JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.ClusterTokenUsage PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.ClusterTokenUsage System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.ClusterTokenUsage System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class CodeBasedEvaluatorDefinition : Azure.AI.Projects.EvaluatorDefinition, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public CodeBasedEvaluatorDefinition(string codeText) { } + public string CodeText { get { throw null; } set { } } + protected override Azure.AI.Projects.EvaluatorDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.EvaluatorDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.CodeBasedEvaluatorDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.CodeBasedEvaluatorDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct ConnectionType : System.IEquatable { @@ -460,6 +964,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public static Azure.AI.Projects.ConnectionType AzureStorageAccount { get { throw null; } } public static Azure.AI.Projects.ConnectionType CosmosDB { get { throw null; } } public static Azure.AI.Projects.ConnectionType Custom { get { throw null; } } + public static Azure.AI.Projects.ConnectionType RemoteTool { get { throw null; } } public bool Equals(Azure.AI.Projects.ConnectionType other) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override bool Equals(object obj) { throw null; } @@ -471,6 +976,69 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public static bool operator !=(Azure.AI.Projects.ConnectionType left, Azure.AI.Projects.ConnectionType right) { throw null; } public override string ToString() { throw null; } } + public partial class ContinuousEvaluationRuleAction : Azure.AI.Projects.EvaluationRuleAction, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ContinuousEvaluationRuleAction(string evalId) { } + public string EvalId { get { throw null; } set { } } + public int? MaxHourlyRuns { get { throw null; } set { } } + protected override Azure.AI.Projects.EvaluationRuleAction JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.EvaluationRuleAction PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.ContinuousEvaluationRuleAction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.ContinuousEvaluationRuleAction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class CreateAgentVersionFromManifestRequest : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public CreateAgentVersionFromManifestRequest(string manifestId, System.Collections.Generic.IDictionary parameterValues) { } + public string Description { get { throw null; } set { } } + public string ManifestId { get { throw null; } } + public System.Collections.Generic.IDictionary Metadata { get { throw null; } } + public System.Collections.Generic.IDictionary ParameterValues { get { throw null; } } + protected virtual Azure.AI.Projects.CreateAgentVersionFromManifestRequest JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.CreateAgentVersionFromManifestRequest PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.CreateAgentVersionFromManifestRequest System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.CreateAgentVersionFromManifestRequest System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class CronTrigger : Azure.AI.Projects.Trigger, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public CronTrigger(string expression) { } + public string EndTime { get { throw null; } set { } } + public string Expression { get { throw null; } set { } } + public string StartTime { get { throw null; } set { } } + public string TimeZone { get { throw null; } set { } } + protected override Azure.AI.Projects.Trigger JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.Trigger PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.CronTrigger System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.CronTrigger System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class DailyRecurrenceSchedule : Azure.AI.Projects.RecurrenceSchedule, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public DailyRecurrenceSchedule(System.Collections.Generic.IEnumerable hours) { } + public System.Collections.Generic.IList Hours { get { throw null; } } + protected override Azure.AI.Projects.RecurrenceSchedule JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.RecurrenceSchedule PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.DailyRecurrenceSchedule System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.DailyRecurrenceSchedule System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } public partial class DatasetCredential : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal DatasetCredential() { } @@ -486,6 +1054,47 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct DayOfWeek : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public DayOfWeek(string value) { throw null; } + public static Azure.AI.Projects.DayOfWeek Friday { get { throw null; } } + public static Azure.AI.Projects.DayOfWeek Monday { get { throw null; } } + public static Azure.AI.Projects.DayOfWeek Saturday { get { throw null; } } + public static Azure.AI.Projects.DayOfWeek Sunday { get { throw null; } } + public static Azure.AI.Projects.DayOfWeek Thursday { get { throw null; } } + public static Azure.AI.Projects.DayOfWeek Tuesday { get { throw null; } } + public static Azure.AI.Projects.DayOfWeek Wednesday { get { throw null; } } + public bool Equals(Azure.AI.Projects.DayOfWeek other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.DayOfWeek left, Azure.AI.Projects.DayOfWeek right) { throw null; } + public static implicit operator Azure.AI.Projects.DayOfWeek (string value) { throw null; } + public static implicit operator Azure.AI.Projects.DayOfWeek? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.DayOfWeek left, Azure.AI.Projects.DayOfWeek right) { throw null; } + public override string ToString() { throw null; } + } + public partial class DeleteMemoryStoreResponse : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal DeleteMemoryStoreResponse() { } + public bool Deleted { get { throw null; } } + public string Name { get { throw null; } } + public string Object { get { throw null; } } + protected virtual Azure.AI.Projects.DeleteMemoryStoreResponse JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static explicit operator Azure.AI.Projects.DeleteMemoryStoreResponse (System.ClientModel.ClientResult result) { throw null; } + protected virtual Azure.AI.Projects.DeleteMemoryStoreResponse PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.DeleteMemoryStoreResponse System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.DeleteMemoryStoreResponse System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } public partial class EmbeddingConfiguration : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public EmbeddingConfiguration(string modelDeploymentName, string embeddingField) { } @@ -501,118 +1110,1199 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class FileDataset : Azure.AI.Projects.AIProjectDataset, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + public partial class EvalCompareReport : Azure.AI.Projects.InsightResult, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - public FileDataset(System.Uri dataUri) { } - protected override Azure.AI.Projects.AIProjectDataset JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + internal EvalCompareReport() { } + public System.Collections.Generic.IList Comparisons { get { throw null; } } + public string Method { get { throw null; } } + protected override Azure.AI.Projects.InsightResult JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - protected override Azure.AI.Projects.AIProjectDataset PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override Azure.AI.Projects.InsightResult PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - Azure.AI.Projects.FileDataset System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.AI.Projects.FileDataset System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvalCompareReport System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvalCompareReport System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class FolderDataset : Azure.AI.Projects.AIProjectDataset, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + public partial class EvalResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - public FolderDataset(System.Uri dataUri) { } - protected override Azure.AI.Projects.AIProjectDataset JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - protected override Azure.AI.Projects.AIProjectDataset PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - Azure.AI.Projects.FolderDataset System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.AI.Projects.FolderDataset System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + internal EvalResult() { } + public string Name { get { throw null; } } + public bool Passed { get { throw null; } } + public float Score { get { throw null; } } + public string Type { get { throw null; } } + protected virtual Azure.AI.Projects.EvalResult JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.EvalResult PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvalResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvalResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ManagedAzureAISearchIndex : Azure.AI.Projects.AIProjectIndex, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + public partial class EvalRunResultCompareItem : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - public ManagedAzureAISearchIndex(string vectorStoreId) { } - public string VectorStoreId { get { throw null; } set { } } - protected override Azure.AI.Projects.AIProjectIndex JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - protected override Azure.AI.Projects.AIProjectIndex PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - Azure.AI.Projects.ManagedAzureAISearchIndex System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.AI.Projects.ManagedAzureAISearchIndex System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + internal EvalRunResultCompareItem() { } + public float DeltaEstimate { get { throw null; } } + public float PValue { get { throw null; } } + public Azure.AI.Projects.TreatmentEffectType TreatmentEffect { get { throw null; } } + public string TreatmentRunId { get { throw null; } } + public Azure.AI.Projects.EvalRunResultSummary TreatmentRunSummary { get { throw null; } } + protected virtual Azure.AI.Projects.EvalRunResultCompareItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.EvalRunResultCompareItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvalRunResultCompareItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvalRunResultCompareItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ModelDeployment : Azure.AI.Projects.AIProjectDeployment, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + public partial class EvalRunResultComparison : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - internal ModelDeployment() { } - public System.Collections.Generic.IReadOnlyDictionary Capabilities { get { throw null; } } - public string ConnectionName { get { throw null; } } - public string ModelName { get { throw null; } } - public string ModelPublisher { get { throw null; } } - public string ModelVersion { get { throw null; } } - public Azure.AI.Projects.ModelDeploymentSku Sku { get { throw null; } } - protected override Azure.AI.Projects.AIProjectDeployment JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - protected override Azure.AI.Projects.AIProjectDeployment PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - Azure.AI.Projects.ModelDeployment System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.AI.Projects.ModelDeployment System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + internal EvalRunResultComparison() { } + public Azure.AI.Projects.EvalRunResultSummary BaselineRunSummary { get { throw null; } } + public System.Collections.Generic.IList CompareItems { get { throw null; } } + public string Evaluator { get { throw null; } } + public string Metric { get { throw null; } } + public string TestingCriteria { get { throw null; } } + protected virtual Azure.AI.Projects.EvalRunResultComparison JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.EvalRunResultComparison PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvalRunResultComparison System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvalRunResultComparison System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ModelDeploymentSku : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + public partial class EvalRunResultSummary : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - internal ModelDeploymentSku() { } - public long Capacity { get { throw null; } } - public string Family { get { throw null; } } - public string Name { get { throw null; } } - public string Size { get { throw null; } } - public string Tier { get { throw null; } } - protected virtual Azure.AI.Projects.ModelDeploymentSku JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + internal EvalRunResultSummary() { } + public float Average { get { throw null; } } + public string RunId { get { throw null; } } + public int SampleCount { get { throw null; } } + public float StandardDeviation { get { throw null; } } + protected virtual Azure.AI.Projects.EvalRunResultSummary JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - protected virtual Azure.AI.Projects.ModelDeploymentSku PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual Azure.AI.Projects.EvalRunResultSummary PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - Azure.AI.Projects.ModelDeploymentSku System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.AI.Projects.ModelDeploymentSku System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvalRunResultSummary System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvalRunResultSummary System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class NoAuthenticationCredentials : Azure.AI.Projects.AIProjectConnectionBaseCredential, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + public partial class EvaluationComparisonRequest : Azure.AI.Projects.InsightRequest, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - internal NoAuthenticationCredentials() { } - protected override Azure.AI.Projects.AIProjectConnectionBaseCredential JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + public EvaluationComparisonRequest(string evalId, string baselineRunId, System.Collections.Generic.IEnumerable treatmentRunIds) { } + public string BaselineRunId { get { throw null; } set { } } + public string EvalId { get { throw null; } set { } } + public System.Collections.Generic.IList TreatmentRunIds { get { throw null; } } + protected override Azure.AI.Projects.InsightRequest JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - protected override Azure.AI.Projects.AIProjectConnectionBaseCredential PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override Azure.AI.Projects.InsightRequest PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - Azure.AI.Projects.NoAuthenticationCredentials System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.AI.Projects.NoAuthenticationCredentials System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluationComparisonRequest System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluationComparisonRequest System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class PendingUploadConfiguration : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + public partial class EvaluationResultSample : Azure.AI.Projects.InsightSample, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - public PendingUploadConfiguration() { } - public string ConnectionName { get { throw null; } set { } } - public string PendingUploadId { get { throw null; } set { } } - public Azure.AI.Projects.PendingUploadType PendingUploadType { get { throw null; } } - protected virtual Azure.AI.Projects.PendingUploadConfiguration JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + internal EvaluationResultSample() { } + public Azure.AI.Projects.EvalResult EvaluationResult { get { throw null; } } + protected override Azure.AI.Projects.InsightSample JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.InsightSample PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluationResultSample System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluationResultSample System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class EvaluationRule : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public EvaluationRule(Azure.AI.Projects.EvaluationRuleAction action, Azure.AI.Projects.EvaluationRuleEventType eventType, bool enabled) { } + public Azure.AI.Projects.EvaluationRuleAction Action { get { throw null; } set { } } + public string Description { get { throw null; } set { } } + public string DisplayName { get { throw null; } set { } } + public bool Enabled { get { throw null; } set { } } + public Azure.AI.Projects.EvaluationRuleEventType EventType { get { throw null; } set { } } + public Azure.AI.Projects.EvaluationRuleFilter Filter { get { throw null; } set { } } + public string Id { get { throw null; } } + public System.Collections.Generic.IReadOnlyDictionary SystemData { get { throw null; } } + protected virtual Azure.AI.Projects.EvaluationRule JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - public static implicit operator System.ClientModel.BinaryContent (Azure.AI.Projects.PendingUploadConfiguration pendingUploadConfiguration) { throw null; } - protected virtual Azure.AI.Projects.PendingUploadConfiguration PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + public static explicit operator Azure.AI.Projects.EvaluationRule (System.ClientModel.ClientResult result) { throw null; } + public static implicit operator System.ClientModel.BinaryContent (Azure.AI.Projects.EvaluationRule evaluationRule) { throw null; } + protected virtual Azure.AI.Projects.EvaluationRule PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - Azure.AI.Projects.PendingUploadConfiguration System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.AI.Projects.PendingUploadConfiguration System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluationRule System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluationRule System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class PendingUploadResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + public abstract partial class EvaluationRuleAction : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - internal PendingUploadResult() { } - public Azure.AI.Projects.AIProjectBlobReference BlobReference { get { throw null; } } - public string PendingUploadId { get { throw null; } } + internal EvaluationRuleAction() { } + protected virtual Azure.AI.Projects.EvaluationRuleAction JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.EvaluationRuleAction PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluationRuleAction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluationRuleAction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct EvaluationRuleActionType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public EvaluationRuleActionType(string value) { throw null; } + public static Azure.AI.Projects.EvaluationRuleActionType ContinuousEvaluation { get { throw null; } } + public static Azure.AI.Projects.EvaluationRuleActionType HumanEvaluation { get { throw null; } } + public bool Equals(Azure.AI.Projects.EvaluationRuleActionType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.EvaluationRuleActionType left, Azure.AI.Projects.EvaluationRuleActionType right) { throw null; } + public static implicit operator Azure.AI.Projects.EvaluationRuleActionType (string value) { throw null; } + public static implicit operator Azure.AI.Projects.EvaluationRuleActionType? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.EvaluationRuleActionType left, Azure.AI.Projects.EvaluationRuleActionType right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct EvaluationRuleEventType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public EvaluationRuleEventType(string value) { throw null; } + public static Azure.AI.Projects.EvaluationRuleEventType Manual { get { throw null; } } + public static Azure.AI.Projects.EvaluationRuleEventType ResponseCompleted { get { throw null; } } + public bool Equals(Azure.AI.Projects.EvaluationRuleEventType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.EvaluationRuleEventType left, Azure.AI.Projects.EvaluationRuleEventType right) { throw null; } + public static implicit operator Azure.AI.Projects.EvaluationRuleEventType (string value) { throw null; } + public static implicit operator Azure.AI.Projects.EvaluationRuleEventType? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.EvaluationRuleEventType left, Azure.AI.Projects.EvaluationRuleEventType right) { throw null; } + public override string ToString() { throw null; } + } + public partial class EvaluationRuleFilter : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public EvaluationRuleFilter(string agentName) { } + public string AgentName { get { throw null; } set { } } + protected virtual Azure.AI.Projects.EvaluationRuleFilter JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.EvaluationRuleFilter PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluationRuleFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluationRuleFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class EvaluationRules + { + protected EvaluationRules() { } + public System.ClientModel.Primitives.ClientPipeline Pipeline { get { throw null; } } + public virtual System.ClientModel.ClientResult CreateOrUpdate(string id, Azure.AI.Projects.EvaluationRule evaluationRule, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult CreateOrUpdate(string id, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(string id, Azure.AI.Projects.EvaluationRule evaluationRule, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task CreateOrUpdateAsync(string id, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult Delete(string id, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult Delete(string id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(string id, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(string id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult Get(string id, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult Get(string id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.CollectionResult GetAll(Azure.AI.Projects.EvaluationRuleActionType? actionType = default(Azure.AI.Projects.EvaluationRuleActionType?), string agentName = null, bool? enabled = default(bool?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.CollectionResult GetAll(string actionType, string agentName, bool? enabled, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetAllAsync(Azure.AI.Projects.EvaluationRuleActionType? actionType = default(Azure.AI.Projects.EvaluationRuleActionType?), string agentName = null, bool? enabled = default(bool?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.AsyncCollectionResult GetAllAsync(string actionType, string agentName, bool? enabled, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task GetAsync(string id, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class EvaluationRunClusterInsightResult : Azure.AI.Projects.InsightResult, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal EvaluationRunClusterInsightResult() { } + public Azure.AI.Projects.ClusterInsightResult ClusterInsight { get { throw null; } } + protected override Azure.AI.Projects.InsightResult JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.InsightResult PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluationRunClusterInsightResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluationRunClusterInsightResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class EvaluationRunClusterInsightsRequest : Azure.AI.Projects.InsightRequest, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public EvaluationRunClusterInsightsRequest(string evalId, System.Collections.Generic.IEnumerable runIds) { } + public string EvalId { get { throw null; } set { } } + public Azure.AI.Projects.InsightModelConfiguration ModelConfiguration { get { throw null; } set { } } + public System.Collections.Generic.IList RunIds { get { throw null; } } + protected override Azure.AI.Projects.InsightRequest JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.InsightRequest PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluationRunClusterInsightsRequest System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluationRunClusterInsightsRequest System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class EvaluationScheduleTask : Azure.AI.Projects.ScheduleTask, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public EvaluationScheduleTask(string evalId, Azure.AI.Projects.EvaluationScheduleTaskEvalRun evalRun) { } + public string EvalId { get { throw null; } set { } } + public Azure.AI.Projects.EvaluationScheduleTaskEvalRun EvalRun { get { throw null; } set { } } + protected override Azure.AI.Projects.ScheduleTask JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.ScheduleTask PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluationScheduleTask System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluationScheduleTask System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class EvaluationScheduleTaskEvalRun : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public EvaluationScheduleTaskEvalRun() { } + protected virtual Azure.AI.Projects.EvaluationScheduleTaskEvalRun JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.EvaluationScheduleTaskEvalRun PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluationScheduleTaskEvalRun System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluationScheduleTaskEvalRun System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class EvaluationTaxonomies + { + protected EvaluationTaxonomies() { } + public System.ClientModel.Primitives.ClientPipeline Pipeline { get { throw null; } } + public virtual System.ClientModel.ClientResult Create(string name, Azure.AI.Projects.EvaluationTaxonomy body, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult Create(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> CreateAsync(string name, Azure.AI.Projects.EvaluationTaxonomy body, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task CreateAsync(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult Delete(string name, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult Delete(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(string name, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult Get(string name, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult Get(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.CollectionResult GetAll(string inputName, string inputType, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.CollectionResult GetAll(string inputName = null, string inputType = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.AsyncCollectionResult GetAllAsync(string inputName, string inputType, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetAllAsync(string inputName = null, string inputType = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GetAsync(string name, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult Update(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task UpdateAsync(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + } + public partial class EvaluationTaxonomy : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public EvaluationTaxonomy(Azure.AI.Projects.EvaluationTaxonomyInput taxonomyInput) { } + public string Description { get { throw null; } set { } } + public string Id { get { throw null; } } + public string Name { get { throw null; } } + public System.Collections.Generic.IDictionary Properties { get { throw null; } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + public System.Collections.Generic.IList TaxonomyCategories { get { throw null; } } + public Azure.AI.Projects.EvaluationTaxonomyInput TaxonomyInput { get { throw null; } set { } } + public string Version { get { throw null; } } + protected virtual Azure.AI.Projects.EvaluationTaxonomy JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static explicit operator Azure.AI.Projects.EvaluationTaxonomy (System.ClientModel.ClientResult result) { throw null; } + public static implicit operator System.ClientModel.BinaryContent (Azure.AI.Projects.EvaluationTaxonomy evaluationTaxonomy) { throw null; } + protected virtual Azure.AI.Projects.EvaluationTaxonomy PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluationTaxonomy System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluationTaxonomy System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public abstract partial class EvaluationTaxonomyInput : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal EvaluationTaxonomyInput() { } + protected virtual Azure.AI.Projects.EvaluationTaxonomyInput JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.EvaluationTaxonomyInput PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluationTaxonomyInput System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluationTaxonomyInput System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct EvaluatorCategory : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public EvaluatorCategory(string value) { throw null; } + public static Azure.AI.Projects.EvaluatorCategory Agents { get { throw null; } } + public static Azure.AI.Projects.EvaluatorCategory Quality { get { throw null; } } + public static Azure.AI.Projects.EvaluatorCategory Safety { get { throw null; } } + public bool Equals(Azure.AI.Projects.EvaluatorCategory other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.EvaluatorCategory left, Azure.AI.Projects.EvaluatorCategory right) { throw null; } + public static implicit operator Azure.AI.Projects.EvaluatorCategory (string value) { throw null; } + public static implicit operator Azure.AI.Projects.EvaluatorCategory? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.EvaluatorCategory left, Azure.AI.Projects.EvaluatorCategory right) { throw null; } + public override string ToString() { throw null; } + } + public abstract partial class EvaluatorDefinition : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal EvaluatorDefinition() { } + public System.BinaryData DataSchema { get { throw null; } set { } } + public System.BinaryData InitParameters { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Metrics { get { throw null; } } + protected virtual Azure.AI.Projects.EvaluatorDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.EvaluatorDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluatorDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluatorDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class EvaluatorMetric : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public EvaluatorMetric() { } + public Azure.AI.Projects.EvaluatorMetricDirection? DesirableDirection { get { throw null; } set { } } + public bool? IsPrimary { get { throw null; } set { } } + public float? MaxValue { get { throw null; } set { } } + public float? MinValue { get { throw null; } set { } } + public Azure.AI.Projects.EvaluatorMetricType? Type { get { throw null; } set { } } + protected virtual Azure.AI.Projects.EvaluatorMetric JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.EvaluatorMetric PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluatorMetric System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluatorMetric System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct EvaluatorMetricDirection : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public EvaluatorMetricDirection(string value) { throw null; } + public static Azure.AI.Projects.EvaluatorMetricDirection Decrease { get { throw null; } } + public static Azure.AI.Projects.EvaluatorMetricDirection Increase { get { throw null; } } + public static Azure.AI.Projects.EvaluatorMetricDirection Neutral { get { throw null; } } + public bool Equals(Azure.AI.Projects.EvaluatorMetricDirection other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.EvaluatorMetricDirection left, Azure.AI.Projects.EvaluatorMetricDirection right) { throw null; } + public static implicit operator Azure.AI.Projects.EvaluatorMetricDirection (string value) { throw null; } + public static implicit operator Azure.AI.Projects.EvaluatorMetricDirection? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.EvaluatorMetricDirection left, Azure.AI.Projects.EvaluatorMetricDirection right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct EvaluatorMetricType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public EvaluatorMetricType(string value) { throw null; } + public static Azure.AI.Projects.EvaluatorMetricType Boolean { get { throw null; } } + public static Azure.AI.Projects.EvaluatorMetricType Continuous { get { throw null; } } + public static Azure.AI.Projects.EvaluatorMetricType Ordinal { get { throw null; } } + public bool Equals(Azure.AI.Projects.EvaluatorMetricType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.EvaluatorMetricType left, Azure.AI.Projects.EvaluatorMetricType right) { throw null; } + public static implicit operator Azure.AI.Projects.EvaluatorMetricType (string value) { throw null; } + public static implicit operator Azure.AI.Projects.EvaluatorMetricType? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.EvaluatorMetricType left, Azure.AI.Projects.EvaluatorMetricType right) { throw null; } + public override string ToString() { throw null; } + } + public partial class Evaluators + { + protected Evaluators() { } + public System.ClientModel.Primitives.ClientPipeline Pipeline { get { throw null; } } + public virtual System.ClientModel.ClientResult CreateVersion(string name, Azure.AI.Projects.EvaluatorVersion evaluatorVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult CreateVersion(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> CreateVersionAsync(string name, Azure.AI.Projects.EvaluatorVersion evaluatorVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task CreateVersionAsync(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult DeleteVersion(string name, string version, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult DeleteVersion(string name, string version, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteVersionAsync(string name, string version, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task DeleteVersionAsync(string name, string version, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.CollectionResult GetLatestVersions(Azure.AI.Projects.ListVersionsRequestType? type = default(Azure.AI.Projects.ListVersionsRequestType?), int? limit = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.CollectionResult GetLatestVersions(string type, int? limit, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetLatestVersionsAsync(Azure.AI.Projects.ListVersionsRequestType? type = default(Azure.AI.Projects.ListVersionsRequestType?), int? limit = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.AsyncCollectionResult GetLatestVersionsAsync(string type, int? limit, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult GetVersion(string name, string version, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult GetVersion(string name, string version, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GetVersionAsync(string name, string version, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task> GetVersionAsync(string name, string version, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.CollectionResult GetVersions(string name, Azure.AI.Projects.ListVersionsRequestType? type = default(Azure.AI.Projects.ListVersionsRequestType?), int? limit = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.CollectionResult GetVersions(string name, string type, int? limit, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetVersionsAsync(string name, Azure.AI.Projects.ListVersionsRequestType? type = default(Azure.AI.Projects.ListVersionsRequestType?), int? limit = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.AsyncCollectionResult GetVersionsAsync(string name, string type, int? limit, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult UpdateVersion(string name, string version, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task UpdateVersionAsync(string name, string version, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct EvaluatorType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public EvaluatorType(string value) { throw null; } + public static Azure.AI.Projects.EvaluatorType BuiltIn { get { throw null; } } + public static Azure.AI.Projects.EvaluatorType Custom { get { throw null; } } + public bool Equals(Azure.AI.Projects.EvaluatorType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.EvaluatorType left, Azure.AI.Projects.EvaluatorType right) { throw null; } + public static implicit operator Azure.AI.Projects.EvaluatorType (string value) { throw null; } + public static implicit operator Azure.AI.Projects.EvaluatorType? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.EvaluatorType left, Azure.AI.Projects.EvaluatorType right) { throw null; } + public override string ToString() { throw null; } + } + public partial class EvaluatorVersion : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public EvaluatorVersion(Azure.AI.Projects.EvaluatorType evaluatorType, System.Collections.Generic.IEnumerable categories, Azure.AI.Projects.EvaluatorDefinition definition) { } + public System.Collections.Generic.IList Categories { get { throw null; } } + public long CreatedAt { get { throw null; } } + public string CreatedBy { get { throw null; } } + public Azure.AI.Projects.EvaluatorDefinition Definition { get { throw null; } set { } } + public string Description { get { throw null; } set { } } + public string DisplayName { get { throw null; } set { } } + public Azure.AI.Projects.EvaluatorType EvaluatorType { get { throw null; } set { } } + public string Id { get { throw null; } } + public System.Collections.Generic.IDictionary Metadata { get { throw null; } } + public long ModifiedAt { get { throw null; } } + public string Name { get { throw null; } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + public string Version { get { throw null; } } + protected virtual Azure.AI.Projects.EvaluatorVersion JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static explicit operator Azure.AI.Projects.EvaluatorVersion (System.ClientModel.ClientResult result) { throw null; } + public static implicit operator System.ClientModel.BinaryContent (Azure.AI.Projects.EvaluatorVersion evaluatorVersion) { throw null; } + protected virtual Azure.AI.Projects.EvaluatorVersion PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluatorVersion System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluatorVersion System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class FileDataset : Azure.AI.Projects.AIProjectDataset, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public FileDataset(System.Uri dataUri) { } + protected override Azure.AI.Projects.AIProjectDataset JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.AIProjectDataset PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.FileDataset System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.FileDataset System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class FolderDataset : Azure.AI.Projects.AIProjectDataset, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public FolderDataset(System.Uri dataUri) { } + protected override Azure.AI.Projects.AIProjectDataset JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.AIProjectDataset PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.FolderDataset System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.FolderDataset System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class HourlyRecurrenceSchedule : Azure.AI.Projects.RecurrenceSchedule, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public HourlyRecurrenceSchedule() { } + protected override Azure.AI.Projects.RecurrenceSchedule JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.RecurrenceSchedule PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.HourlyRecurrenceSchedule System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.HourlyRecurrenceSchedule System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class HumanEvaluationRuleAction : Azure.AI.Projects.EvaluationRuleAction, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public HumanEvaluationRuleAction(string templateId) { } + public string TemplateId { get { throw null; } set { } } + protected override Azure.AI.Projects.EvaluationRuleAction JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.EvaluationRuleAction PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.HumanEvaluationRuleAction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.HumanEvaluationRuleAction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class Insight : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public Insight(string displayName, Azure.AI.Projects.InsightRequest request) { } + public string DisplayName { get { throw null; } set { } } + public string Id { get { throw null; } } + public Azure.AI.Projects.InsightsMetadata Metadata { get { throw null; } } + public Azure.AI.Projects.InsightRequest Request { get { throw null; } set { } } + public Azure.AI.Projects.InsightResult Result { get { throw null; } } + public Azure.Core.Foundations.OperationStatus State { get { throw null; } } + protected virtual Azure.AI.Projects.Insight JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static explicit operator Azure.AI.Projects.Insight (System.ClientModel.ClientResult result) { throw null; } + public static implicit operator System.ClientModel.BinaryContent (Azure.AI.Projects.Insight insight) { throw null; } + protected virtual Azure.AI.Projects.Insight PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.Insight System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.Insight System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class InsightCluster : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal InsightCluster() { } + public string Description { get { throw null; } } + public string Id { get { throw null; } } + public string Label { get { throw null; } } + public System.Collections.Generic.IList Samples { get { throw null; } } + public System.Collections.Generic.IList SubClusters { get { throw null; } } + public string Suggestion { get { throw null; } } + public string SuggestionTitle { get { throw null; } } + public int Weight { get { throw null; } } + protected virtual Azure.AI.Projects.InsightCluster JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.InsightCluster PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.InsightCluster System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.InsightCluster System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class InsightModelConfiguration : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public InsightModelConfiguration(string modelDeploymentName) { } + public string ModelDeploymentName { get { throw null; } set { } } + protected virtual Azure.AI.Projects.InsightModelConfiguration JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.InsightModelConfiguration PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.InsightModelConfiguration System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.InsightModelConfiguration System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public abstract partial class InsightRequest : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal InsightRequest() { } + protected virtual Azure.AI.Projects.InsightRequest JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.InsightRequest PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.InsightRequest System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.InsightRequest System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public abstract partial class InsightResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal InsightResult() { } + protected virtual Azure.AI.Projects.InsightResult JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.InsightResult PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.InsightResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.InsightResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class Insights + { + protected Insights() { } + public System.ClientModel.Primitives.ClientPipeline Pipeline { get { throw null; } } + public virtual System.ClientModel.ClientResult Generate(Azure.AI.Projects.Insight insight, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult Generate(System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> GenerateAsync(Azure.AI.Projects.Insight insight, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GenerateAsync(System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult Get(string id, bool? includeCoordinates, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult Get(string id, bool? includeCoordinates = default(bool?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.CollectionResult GetAll(Azure.AI.Projects.InsightType? type = default(Azure.AI.Projects.InsightType?), string evalId = null, string runId = null, string agentName = null, bool? includeCoordinates = default(bool?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.CollectionResult GetAll(string type, string evalId, string runId, string agentName, bool? includeCoordinates, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetAllAsync(Azure.AI.Projects.InsightType? type = default(Azure.AI.Projects.InsightType?), string evalId = null, string runId = null, string agentName = null, bool? includeCoordinates = default(bool?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.AsyncCollectionResult GetAllAsync(string type, string evalId, string runId, string agentName, bool? includeCoordinates, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task GetAsync(string id, bool? includeCoordinates, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string id, bool? includeCoordinates = default(bool?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public abstract partial class InsightSample : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal InsightSample() { } + public System.Collections.Generic.IDictionary CorrelationInfo { get { throw null; } } + public System.Collections.Generic.IDictionary Features { get { throw null; } } + public string Id { get { throw null; } } + protected virtual Azure.AI.Projects.InsightSample JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.InsightSample PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.InsightSample System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.InsightSample System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class InsightScheduleTask : Azure.AI.Projects.ScheduleTask, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public InsightScheduleTask(Azure.AI.Projects.Insight insight) { } + public Azure.AI.Projects.Insight Insight { get { throw null; } set { } } + protected override Azure.AI.Projects.ScheduleTask JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.ScheduleTask PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.InsightScheduleTask System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.InsightScheduleTask System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class InsightsMetadata : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal InsightsMetadata() { } + public System.DateTimeOffset? CompletedAt { get { throw null; } } + public System.DateTimeOffset CreatedAt { get { throw null; } } + protected virtual Azure.AI.Projects.InsightsMetadata JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.InsightsMetadata PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.InsightsMetadata System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.InsightsMetadata System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class InsightSummary : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal InsightSummary() { } + public string Method { get { throw null; } } + public int SampleCount { get { throw null; } } + public int UniqueClusterCount { get { throw null; } } + public int UniqueSubclusterCount { get { throw null; } } + public Azure.AI.Projects.ClusterTokenUsage Usage { get { throw null; } } + protected virtual Azure.AI.Projects.InsightSummary JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.InsightSummary PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.InsightSummary System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.InsightSummary System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct InsightType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public InsightType(string value) { throw null; } + public static Azure.AI.Projects.InsightType AgentClusterInsight { get { throw null; } } + public static Azure.AI.Projects.InsightType EvaluationComparison { get { throw null; } } + public static Azure.AI.Projects.InsightType EvaluationRunClusterInsight { get { throw null; } } + public bool Equals(Azure.AI.Projects.InsightType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.InsightType left, Azure.AI.Projects.InsightType right) { throw null; } + public static implicit operator Azure.AI.Projects.InsightType (string value) { throw null; } + public static implicit operator Azure.AI.Projects.InsightType? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.InsightType left, Azure.AI.Projects.InsightType right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ListVersionsRequestType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ListVersionsRequestType(string value) { throw null; } + public static Azure.AI.Projects.ListVersionsRequestType All { get { throw null; } } + public static Azure.AI.Projects.ListVersionsRequestType BuiltIn { get { throw null; } } + public static Azure.AI.Projects.ListVersionsRequestType Custom { get { throw null; } } + public bool Equals(Azure.AI.Projects.ListVersionsRequestType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.ListVersionsRequestType left, Azure.AI.Projects.ListVersionsRequestType right) { throw null; } + public static implicit operator Azure.AI.Projects.ListVersionsRequestType (string value) { throw null; } + public static implicit operator Azure.AI.Projects.ListVersionsRequestType? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.ListVersionsRequestType left, Azure.AI.Projects.ListVersionsRequestType right) { throw null; } + public override string ToString() { throw null; } + } + public partial class ManagedAzureAISearchIndex : Azure.AI.Projects.AIProjectIndex, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ManagedAzureAISearchIndex(string vectorStoreId) { } + public string VectorStoreId { get { throw null; } set { } } + protected override Azure.AI.Projects.AIProjectIndex JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.AIProjectIndex PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.ManagedAzureAISearchIndex System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.ManagedAzureAISearchIndex System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public abstract partial class MemoryItem : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemoryItem() { } + public string Content { get { throw null; } set { } } + public string MemoryId { get { throw null; } set { } } + public string Scope { get { throw null; } set { } } + public System.DateTimeOffset UpdatedAt { get { throw null; } set { } } + protected virtual Azure.AI.Projects.MemoryItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.MemoryItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemoryOperation : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemoryOperation() { } + public Azure.AI.Projects.MemoryOperationKind Kind { get { throw null; } } + public Azure.AI.Projects.MemoryItem MemoryItem { get { throw null; } } + protected virtual Azure.AI.Projects.MemoryOperation JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.MemoryOperation PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryOperation System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryOperation System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct MemoryOperationKind : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public MemoryOperationKind(string value) { throw null; } + public static Azure.AI.Projects.MemoryOperationKind Create { get { throw null; } } + public static Azure.AI.Projects.MemoryOperationKind Delete { get { throw null; } } + public static Azure.AI.Projects.MemoryOperationKind Update { get { throw null; } } + public bool Equals(Azure.AI.Projects.MemoryOperationKind other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.MemoryOperationKind left, Azure.AI.Projects.MemoryOperationKind right) { throw null; } + public static implicit operator Azure.AI.Projects.MemoryOperationKind (string value) { throw null; } + public static implicit operator Azure.AI.Projects.MemoryOperationKind? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.MemoryOperationKind left, Azure.AI.Projects.MemoryOperationKind right) { throw null; } + public override string ToString() { throw null; } + } + public partial class MemorySearchItem : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MemorySearchItem(Azure.AI.Projects.MemoryItem memoryItem) { } + public Azure.AI.Projects.MemoryItem MemoryItem { get { throw null; } set { } } + protected virtual Azure.AI.Projects.MemorySearchItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.MemorySearchItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemorySearchItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemorySearchItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemorySearchOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MemorySearchOptions(string scope) { } + public System.Collections.Generic.IList Items { get { throw null; } } + public string PreviousSearchId { get { throw null; } set { } } + public Azure.AI.Projects.MemorySearchResultOptions ResultOptions { get { throw null; } set { } } + public string Scope { get { throw null; } } + Azure.AI.Projects.MemorySearchOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemorySearchOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemorySearchResultOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MemorySearchResultOptions() { } + public int? MaxMemories { get { throw null; } set { } } + protected virtual Azure.AI.Projects.MemorySearchResultOptions JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.MemorySearchResultOptions PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemorySearchResultOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemorySearchResultOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemoryStore : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemoryStore() { } + public System.DateTimeOffset CreatedAt { get { throw null; } } + public Azure.AI.Projects.MemoryStoreDefinition Definition { get { throw null; } } + public string Description { get { throw null; } } + public string Id { get { throw null; } } + public System.Collections.Generic.IDictionary Metadata { get { throw null; } } + public string Name { get { throw null; } } + public System.DateTimeOffset UpdatedAt { get { throw null; } } + protected virtual Azure.AI.Projects.MemoryStore JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static explicit operator Azure.AI.Projects.MemoryStore (System.ClientModel.ClientResult result) { throw null; } + protected virtual Azure.AI.Projects.MemoryStore PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryStore System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryStore System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemoryStoreDefaultDefinition : Azure.AI.Projects.MemoryStoreDefinition, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MemoryStoreDefaultDefinition(string chatModel, string embeddingModel) { } + public string ChatModel { get { throw null; } set { } } + public string EmbeddingModel { get { throw null; } set { } } + public Azure.AI.Projects.MemoryStoreDefaultOptions Options { get { throw null; } set { } } + protected override Azure.AI.Projects.MemoryStoreDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.MemoryStoreDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryStoreDefaultDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryStoreDefaultDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemoryStoreDefaultOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MemoryStoreDefaultOptions(bool userProfileEnabled, bool chatSummaryEnabled) { } + public bool ChatSummaryEnabled { get { throw null; } set { } } + public string UserProfileDetails { get { throw null; } set { } } + public bool UserProfileEnabled { get { throw null; } set { } } + protected virtual Azure.AI.Projects.MemoryStoreDefaultOptions JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.MemoryStoreDefaultOptions PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryStoreDefaultOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryStoreDefaultOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public abstract partial class MemoryStoreDefinition : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemoryStoreDefinition() { } + protected virtual Azure.AI.Projects.MemoryStoreDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.MemoryStoreDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryStoreDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryStoreDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemoryStoreDeleteScopeResponse : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemoryStoreDeleteScopeResponse() { } + public bool Deleted { get { throw null; } } + public string Name { get { throw null; } } + public string Object { get { throw null; } } + public string Scope { get { throw null; } } + protected virtual Azure.AI.Projects.MemoryStoreDeleteScopeResponse JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static explicit operator Azure.AI.Projects.MemoryStoreDeleteScopeResponse (System.ClientModel.ClientResult result) { throw null; } + protected virtual Azure.AI.Projects.MemoryStoreDeleteScopeResponse PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryStoreDeleteScopeResponse System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryStoreDeleteScopeResponse System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemoryStoreOperationUsage : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemoryStoreOperationUsage() { } + public int EmbeddingTokens { get { throw null; } } + public int InputTokens { get { throw null; } } + public Azure.AI.Projects.MemoryStoreOperationUsageInputTokensDetails InputTokensDetails { get { throw null; } } + public int OutputTokens { get { throw null; } } + public Azure.AI.Projects.MemoryStoreOperationUsageOutputTokensDetails OutputTokensDetails { get { throw null; } } + public int TotalTokens { get { throw null; } } + protected virtual Azure.AI.Projects.MemoryStoreOperationUsage JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.MemoryStoreOperationUsage PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryStoreOperationUsage System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryStoreOperationUsage System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemoryStoreOperationUsageInputTokensDetails : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemoryStoreOperationUsageInputTokensDetails() { } + public int CachedTokens { get { throw null; } } + protected virtual Azure.AI.Projects.MemoryStoreOperationUsageInputTokensDetails JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.MemoryStoreOperationUsageInputTokensDetails PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryStoreOperationUsageInputTokensDetails System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryStoreOperationUsageInputTokensDetails System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemoryStoreOperationUsageOutputTokensDetails : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemoryStoreOperationUsageOutputTokensDetails() { } + public int ReasoningTokens { get { throw null; } } + protected virtual Azure.AI.Projects.MemoryStoreOperationUsageOutputTokensDetails JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.MemoryStoreOperationUsageOutputTokensDetails PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryStoreOperationUsageOutputTokensDetails System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryStoreOperationUsageOutputTokensDetails System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemoryStoreSearchResponse : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemoryStoreSearchResponse() { } + public System.Collections.Generic.IList Memories { get { throw null; } } + public string SearchId { get { throw null; } } + public Azure.AI.Projects.MemoryStoreOperationUsage Usage { get { throw null; } } + protected virtual Azure.AI.Projects.MemoryStoreSearchResponse JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static explicit operator Azure.AI.Projects.MemoryStoreSearchResponse (System.ClientModel.ClientResult result) { throw null; } + protected virtual Azure.AI.Projects.MemoryStoreSearchResponse PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryStoreSearchResponse System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryStoreSearchResponse System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public enum MemoryStoreUpdateStatus + { + Queued = 0, + InProgress = 1, + Completed = 2, + Failed = 3, + Superseded = 4, + } + public partial class MemoryUpdateOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MemoryUpdateOptions(string scope) { } + public System.Collections.Generic.IList Items { get { throw null; } } + public string PreviousUpdateId { get { throw null; } set { } } + public string Scope { get { throw null; } } + public int? UpdateDelay { get { throw null; } set { } } + Azure.AI.Projects.MemoryUpdateOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryUpdateOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemoryUpdateResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemoryUpdateResult() { } + public Azure.AI.Projects.MemoryUpdateResultDetails Details { get { throw null; } } + public string ErrorDetails { get { throw null; } } + public Azure.AI.Projects.MemoryStoreUpdateStatus Status { get { throw null; } } + public string SupersededBy { get { throw null; } } + public string UpdateId { get { throw null; } } + protected virtual Azure.AI.Projects.MemoryUpdateResult JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static explicit operator Azure.AI.Projects.MemoryUpdateResult (System.ClientModel.ClientResult result) { throw null; } + protected virtual Azure.AI.Projects.MemoryUpdateResult PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryUpdateResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryUpdateResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemoryUpdateResultDetails : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemoryUpdateResultDetails() { } + public System.Collections.Generic.IList MemoryOperations { get { throw null; } } + public Azure.AI.Projects.MemoryStoreOperationUsage Usage { get { throw null; } } + protected virtual Azure.AI.Projects.MemoryUpdateResultDetails JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static explicit operator Azure.AI.Projects.MemoryUpdateResultDetails (System.ClientModel.ClientResult result) { throw null; } + protected virtual Azure.AI.Projects.MemoryUpdateResultDetails PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryUpdateResultDetails System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryUpdateResultDetails System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ModelDeployment : Azure.AI.Projects.AIProjectDeployment, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ModelDeployment() { } + public System.Collections.Generic.IReadOnlyDictionary Capabilities { get { throw null; } } + public string ConnectionName { get { throw null; } } + public string ModelName { get { throw null; } } + public string ModelPublisher { get { throw null; } } + public string ModelVersion { get { throw null; } } + public Azure.AI.Projects.ModelDeploymentSku Sku { get { throw null; } } + protected override Azure.AI.Projects.AIProjectDeployment JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.AIProjectDeployment PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.ModelDeployment System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.ModelDeployment System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ModelDeploymentSku : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ModelDeploymentSku() { } + public long Capacity { get { throw null; } } + public string Family { get { throw null; } } + public string Name { get { throw null; } } + public string Size { get { throw null; } } + public string Tier { get { throw null; } } + protected virtual Azure.AI.Projects.ModelDeploymentSku JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.ModelDeploymentSku PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.ModelDeploymentSku System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.ModelDeploymentSku System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ModelSamplingParams : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ModelSamplingParams() { } + public int MaxCompletionTokens { get { throw null; } } + public int Seed { get { throw null; } } + public float Temperature { get { throw null; } } + public float TopP { get { throw null; } } + protected virtual Azure.AI.Projects.ModelSamplingParams JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.ModelSamplingParams PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.ModelSamplingParams System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.ModelSamplingParams System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MonthlyRecurrenceSchedule : Azure.AI.Projects.RecurrenceSchedule, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MonthlyRecurrenceSchedule(System.Collections.Generic.IEnumerable daysOfMonth) { } + public System.Collections.Generic.IList DaysOfMonth { get { throw null; } } + protected override Azure.AI.Projects.RecurrenceSchedule JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.RecurrenceSchedule PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MonthlyRecurrenceSchedule System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MonthlyRecurrenceSchedule System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class NoAuthenticationCredentials : Azure.AI.Projects.AIProjectConnectionBaseCredential, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal NoAuthenticationCredentials() { } + protected override Azure.AI.Projects.AIProjectConnectionBaseCredential JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.AIProjectConnectionBaseCredential PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.NoAuthenticationCredentials System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.NoAuthenticationCredentials System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class OneTimeTrigger : Azure.AI.Projects.Trigger, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public OneTimeTrigger(string triggerAt) { } + public string TimeZone { get { throw null; } set { } } + public string TriggerAt { get { throw null; } set { } } + protected override Azure.AI.Projects.Trigger JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.Trigger PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OneTimeTrigger System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OneTimeTrigger System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class PendingUploadConfiguration : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public PendingUploadConfiguration() { } + public string ConnectionName { get { throw null; } set { } } + public string PendingUploadId { get { throw null; } set { } } + public Azure.AI.Projects.PendingUploadType PendingUploadType { get { throw null; } } + protected virtual Azure.AI.Projects.PendingUploadConfiguration JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static implicit operator System.ClientModel.BinaryContent (Azure.AI.Projects.PendingUploadConfiguration pendingUploadConfiguration) { throw null; } + protected virtual Azure.AI.Projects.PendingUploadConfiguration PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.PendingUploadConfiguration System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.PendingUploadConfiguration System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class PendingUploadResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal PendingUploadResult() { } + public Azure.AI.Projects.AIProjectBlobReference BlobReference { get { throw null; } } + public string PendingUploadId { get { throw null; } } public Azure.AI.Projects.PendingUploadType PendingUploadType { get { throw null; } } public string Version { get { throw null; } } protected virtual Azure.AI.Projects.PendingUploadResult JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -645,4 +2335,394 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public static bool operator !=(Azure.AI.Projects.PendingUploadType left, Azure.AI.Projects.PendingUploadType right) { throw null; } public override string ToString() { throw null; } } + public partial class PromptBasedEvaluatorDefinition : Azure.AI.Projects.EvaluatorDefinition, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public PromptBasedEvaluatorDefinition(string promptText) { } + public string PromptText { get { throw null; } set { } } + protected override Azure.AI.Projects.EvaluatorDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.EvaluatorDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.PromptBasedEvaluatorDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.PromptBasedEvaluatorDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public abstract partial class RecurrenceSchedule : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal RecurrenceSchedule() { } + protected virtual Azure.AI.Projects.RecurrenceSchedule JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.RecurrenceSchedule PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.RecurrenceSchedule System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.RecurrenceSchedule System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class RecurrenceTrigger : Azure.AI.Projects.Trigger, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public RecurrenceTrigger(int interval, Azure.AI.Projects.RecurrenceSchedule schedule) { } + public string EndTime { get { throw null; } set { } } + public int Interval { get { throw null; } set { } } + public Azure.AI.Projects.RecurrenceSchedule Schedule { get { throw null; } set { } } + public string StartTime { get { throw null; } set { } } + public string TimeZone { get { throw null; } set { } } + protected override Azure.AI.Projects.Trigger JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.Trigger PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.RecurrenceTrigger System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.RecurrenceTrigger System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class RedTeam : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public RedTeam(Azure.AI.Projects.TargetConfig target) { } + public string ApplicationScenario { get { throw null; } set { } } + public System.Collections.Generic.IList AttackStrategies { get { throw null; } } + public string DisplayName { get { throw null; } set { } } + public string Name { get { throw null; } } + public int? NumTurns { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Properties { get { throw null; } } + public System.Collections.Generic.IList RiskCategories { get { throw null; } } + public bool? SimulationOnly { get { throw null; } set { } } + public string Status { get { throw null; } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + public Azure.AI.Projects.TargetConfig Target { get { throw null; } set { } } + protected virtual Azure.AI.Projects.RedTeam JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static explicit operator Azure.AI.Projects.RedTeam (System.ClientModel.ClientResult result) { throw null; } + public static implicit operator System.ClientModel.BinaryContent (Azure.AI.Projects.RedTeam redTeam) { throw null; } + protected virtual Azure.AI.Projects.RedTeam PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.RedTeam System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.RedTeam System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class RedTeams + { + protected RedTeams() { } + public System.ClientModel.Primitives.ClientPipeline Pipeline { get { throw null; } } + public virtual System.ClientModel.ClientResult Create(Azure.AI.Projects.RedTeam redTeam, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult Create(System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> CreateAsync(Azure.AI.Projects.RedTeam redTeam, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task CreateAsync(System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult Get(string name, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult Get(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.CollectionResult GetAll(System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.CollectionResult GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.AsyncCollectionResult GetAllAsync(System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GetAsync(string name, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct RiskCategory : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public RiskCategory(string value) { throw null; } + public static Azure.AI.Projects.RiskCategory CodeVulnerability { get { throw null; } } + public static Azure.AI.Projects.RiskCategory HateUnfairness { get { throw null; } } + public static Azure.AI.Projects.RiskCategory ProhibitedActions { get { throw null; } } + public static Azure.AI.Projects.RiskCategory ProtectedMaterial { get { throw null; } } + public static Azure.AI.Projects.RiskCategory SelfHarm { get { throw null; } } + public static Azure.AI.Projects.RiskCategory SensitiveDataLeakage { get { throw null; } } + public static Azure.AI.Projects.RiskCategory Sexual { get { throw null; } } + public static Azure.AI.Projects.RiskCategory TaskAdherence { get { throw null; } } + public static Azure.AI.Projects.RiskCategory UngroundedAttributes { get { throw null; } } + public static Azure.AI.Projects.RiskCategory Violence { get { throw null; } } + public bool Equals(Azure.AI.Projects.RiskCategory other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.RiskCategory left, Azure.AI.Projects.RiskCategory right) { throw null; } + public static implicit operator Azure.AI.Projects.RiskCategory (string value) { throw null; } + public static implicit operator Azure.AI.Projects.RiskCategory? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.RiskCategory left, Azure.AI.Projects.RiskCategory right) { throw null; } + public override string ToString() { throw null; } + } + public partial class Schedule : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public Schedule(bool enabled, Azure.AI.Projects.Trigger trigger, Azure.AI.Projects.ScheduleTask task) { } + public string Description { get { throw null; } set { } } + public string DisplayName { get { throw null; } set { } } + public bool Enabled { get { throw null; } set { } } + public string Id { get { throw null; } } + public System.Collections.Generic.IDictionary Properties { get { throw null; } } + public Azure.AI.Projects.ScheduleProvisioningStatus? ProvisioningStatus { get { throw null; } } + public System.Collections.Generic.IReadOnlyDictionary SystemData { get { throw null; } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + public Azure.AI.Projects.ScheduleTask Task { get { throw null; } set { } } + public Azure.AI.Projects.Trigger Trigger { get { throw null; } set { } } + protected virtual Azure.AI.Projects.Schedule JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static explicit operator Azure.AI.Projects.Schedule (System.ClientModel.ClientResult result) { throw null; } + public static implicit operator System.ClientModel.BinaryContent (Azure.AI.Projects.Schedule schedule) { throw null; } + protected virtual Azure.AI.Projects.Schedule PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.Schedule System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.Schedule System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ScheduleProvisioningStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ScheduleProvisioningStatus(string value) { throw null; } + public static Azure.AI.Projects.ScheduleProvisioningStatus Creating { get { throw null; } } + public static Azure.AI.Projects.ScheduleProvisioningStatus Deleting { get { throw null; } } + public static Azure.AI.Projects.ScheduleProvisioningStatus Failed { get { throw null; } } + public static Azure.AI.Projects.ScheduleProvisioningStatus Succeeded { get { throw null; } } + public static Azure.AI.Projects.ScheduleProvisioningStatus Updating { get { throw null; } } + public bool Equals(Azure.AI.Projects.ScheduleProvisioningStatus other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.ScheduleProvisioningStatus left, Azure.AI.Projects.ScheduleProvisioningStatus right) { throw null; } + public static implicit operator Azure.AI.Projects.ScheduleProvisioningStatus (string value) { throw null; } + public static implicit operator Azure.AI.Projects.ScheduleProvisioningStatus? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.ScheduleProvisioningStatus left, Azure.AI.Projects.ScheduleProvisioningStatus right) { throw null; } + public override string ToString() { throw null; } + } + public partial class ScheduleRun : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ScheduleRun() { } + public string Error { get { throw null; } } + public System.Collections.Generic.IReadOnlyDictionary Properties { get { throw null; } } + public string RunId { get { throw null; } } + public string ScheduleId { get { throw null; } } + public bool Success { get { throw null; } } + public string TriggerTime { get { throw null; } } + protected virtual Azure.AI.Projects.ScheduleRun JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static explicit operator Azure.AI.Projects.ScheduleRun (System.ClientModel.ClientResult result) { throw null; } + protected virtual Azure.AI.Projects.ScheduleRun PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.ScheduleRun System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.ScheduleRun System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class Schedules + { + protected Schedules() { } + public System.ClientModel.Primitives.ClientPipeline Pipeline { get { throw null; } } + public virtual System.ClientModel.ClientResult CreateOrUpdate(string id, Azure.AI.Projects.Schedule schedule, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult CreateOrUpdate(string id, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(string id, Azure.AI.Projects.Schedule schedule, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task CreateOrUpdateAsync(string id, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult Delete(string id, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult Delete(string id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(string id, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(string id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult Get(string id, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult Get(string id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.CollectionResult GetAll(System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.CollectionResult GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.AsyncCollectionResult GetAllAsync(System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GetAsync(string id, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult GetRun(string scheduleId, string runId, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult GetRun(string scheduleId, string runId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GetRunAsync(string scheduleId, string runId, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task> GetRunAsync(string scheduleId, string runId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.CollectionResult GetRuns(string id, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.CollectionResult GetRuns(string id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.AsyncCollectionResult GetRunsAsync(string id, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetRunsAsync(string id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public abstract partial class ScheduleTask : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ScheduleTask() { } + public System.Collections.Generic.IDictionary Configuration { get { throw null; } } + protected virtual Azure.AI.Projects.ScheduleTask JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.ScheduleTask PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.ScheduleTask System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.ScheduleTask System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public abstract partial class Target : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal Target() { } + protected virtual Azure.AI.Projects.Target JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.Target PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.Target System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.Target System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public abstract partial class TargetConfig : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal TargetConfig() { } + protected virtual Azure.AI.Projects.TargetConfig JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.TargetConfig PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.TargetConfig System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.TargetConfig System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class TaxonomyCategory : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TaxonomyCategory(string id, string name, Azure.AI.Projects.RiskCategory riskCategory, System.Collections.Generic.IEnumerable subCategories) { } + public string Description { get { throw null; } set { } } + public string Id { get { throw null; } set { } } + public string Name { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Properties { get { throw null; } } + public Azure.AI.Projects.RiskCategory RiskCategory { get { throw null; } set { } } + public System.Collections.Generic.IList SubCategories { get { throw null; } } + protected virtual Azure.AI.Projects.TaxonomyCategory JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.TaxonomyCategory PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.TaxonomyCategory System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.TaxonomyCategory System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class TaxonomySubCategory : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TaxonomySubCategory(string id, string name, bool enabled) { } + public string Description { get { throw null; } set { } } + public bool Enabled { get { throw null; } set { } } + public string Id { get { throw null; } set { } } + public string Name { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Properties { get { throw null; } } + protected virtual Azure.AI.Projects.TaxonomySubCategory JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.TaxonomySubCategory PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.TaxonomySubCategory System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.TaxonomySubCategory System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ToolDescription : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ToolDescription() { } + public string Description { get { throw null; } set { } } + public string Name { get { throw null; } set { } } + protected virtual Azure.AI.Projects.ToolDescription JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.ToolDescription PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.ToolDescription System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.ToolDescription System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct TreatmentEffectType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public TreatmentEffectType(string value) { throw null; } + public static Azure.AI.Projects.TreatmentEffectType Changed { get { throw null; } } + public static Azure.AI.Projects.TreatmentEffectType Degraded { get { throw null; } } + public static Azure.AI.Projects.TreatmentEffectType Improved { get { throw null; } } + public static Azure.AI.Projects.TreatmentEffectType Inconclusive { get { throw null; } } + public static Azure.AI.Projects.TreatmentEffectType TooFewSamples { get { throw null; } } + public bool Equals(Azure.AI.Projects.TreatmentEffectType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.TreatmentEffectType left, Azure.AI.Projects.TreatmentEffectType right) { throw null; } + public static implicit operator Azure.AI.Projects.TreatmentEffectType (string value) { throw null; } + public static implicit operator Azure.AI.Projects.TreatmentEffectType? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.TreatmentEffectType left, Azure.AI.Projects.TreatmentEffectType right) { throw null; } + public override string ToString() { throw null; } + } + public abstract partial class Trigger : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal Trigger() { } + protected virtual Azure.AI.Projects.Trigger JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.Trigger PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.Trigger System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.Trigger System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class UserProfileMemoryItem : Azure.AI.Projects.MemoryItem, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public UserProfileMemoryItem(string memoryId, System.DateTimeOffset updatedAt, string scope, string content) { } + protected override Azure.AI.Projects.MemoryItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.MemoryItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.UserProfileMemoryItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.UserProfileMemoryItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class WeeklyRecurrenceSchedule : Azure.AI.Projects.RecurrenceSchedule, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public WeeklyRecurrenceSchedule(System.Collections.Generic.IEnumerable daysOfWeek) { } + public System.Collections.Generic.IList DaysOfWeek { get { throw null; } } + protected override Azure.AI.Projects.RecurrenceSchedule JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.RecurrenceSchedule PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.WeeklyRecurrenceSchedule System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.WeeklyRecurrenceSchedule System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } +} +namespace Azure.Core.Foundations +{ + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct OperationStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public OperationStatus(string value) { throw null; } + public static Azure.Core.Foundations.OperationStatus Canceled { get { throw null; } } + public static Azure.Core.Foundations.OperationStatus Failed { get { throw null; } } + public static Azure.Core.Foundations.OperationStatus NotStarted { get { throw null; } } + public static Azure.Core.Foundations.OperationStatus Running { get { throw null; } } + public static Azure.Core.Foundations.OperationStatus Succeeded { get { throw null; } } + public bool Equals(Azure.Core.Foundations.OperationStatus other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.Core.Foundations.OperationStatus left, Azure.Core.Foundations.OperationStatus right) { throw null; } + public static implicit operator Azure.Core.Foundations.OperationStatus (string value) { throw null; } + public static implicit operator Azure.Core.Foundations.OperationStatus? (string value) { throw null; } + public static bool operator !=(Azure.Core.Foundations.OperationStatus left, Azure.Core.Foundations.OperationStatus right) { throw null; } + public override string ToString() { throw null; } + } } diff --git a/sdk/ai/Azure.AI.Projects/api/Azure.AI.Projects.netstandard2.0.cs b/sdk/ai/Azure.AI.Projects/api/Azure.AI.Projects.netstandard2.0.cs index b6e019b3dd83..b4705864886c 100644 --- a/sdk/ai/Azure.AI.Projects/api/Azure.AI.Projects.netstandard2.0.cs +++ b/sdk/ai/Azure.AI.Projects/api/Azure.AI.Projects.netstandard2.0.cs @@ -1,5 +1,197 @@ namespace Azure.AI.Projects { + public partial class AgentClusterInsightResult : Azure.AI.Projects.InsightResult, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AgentClusterInsightResult() { } + public Azure.AI.Projects.ClusterInsightResult ClusterInsight { get { throw null; } } + protected override Azure.AI.Projects.InsightResult JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.InsightResult PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.AgentClusterInsightResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.AgentClusterInsightResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AgentClusterInsightsRequest : Azure.AI.Projects.InsightRequest, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AgentClusterInsightsRequest(string agentName) { } + public string AgentName { get { throw null; } set { } } + public Azure.AI.Projects.InsightModelConfiguration ModelConfiguration { get { throw null; } set { } } + protected override Azure.AI.Projects.InsightRequest JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.InsightRequest PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.AgentClusterInsightsRequest System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.AgentClusterInsightsRequest System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AgenticIdentityCredentials : Azure.AI.Projects.AIProjectConnectionBaseCredential, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AgenticIdentityCredentials() { } + protected override Azure.AI.Projects.AIProjectConnectionBaseCredential JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.AIProjectConnectionBaseCredential PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.AgenticIdentityCredentials System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.AgenticIdentityCredentials System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct AgentKind : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public AgentKind(string value) { throw null; } + public static Azure.AI.Projects.AgentKind ContainerApp { get { throw null; } } + public static Azure.AI.Projects.AgentKind Hosted { get { throw null; } } + public static Azure.AI.Projects.AgentKind Prompt { get { throw null; } } + public static Azure.AI.Projects.AgentKind Workflow { get { throw null; } } + public bool Equals(Azure.AI.Projects.AgentKind other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.AgentKind left, Azure.AI.Projects.AgentKind right) { throw null; } + public static implicit operator Azure.AI.Projects.AgentKind (string value) { throw null; } + public static implicit operator Azure.AI.Projects.AgentKind? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.AgentKind left, Azure.AI.Projects.AgentKind right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct AgentListOrder : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public AgentListOrder(string value) { throw null; } + public static Azure.AI.Projects.AgentListOrder Ascending { get { throw null; } } + public static Azure.AI.Projects.AgentListOrder Descending { get { throw null; } } + public bool Equals(Azure.AI.Projects.AgentListOrder other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.AgentListOrder left, Azure.AI.Projects.AgentListOrder right) { throw null; } + public static implicit operator Azure.AI.Projects.AgentListOrder (string value) { throw null; } + public static implicit operator Azure.AI.Projects.AgentListOrder? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.AgentListOrder left, Azure.AI.Projects.AgentListOrder right) { throw null; } + public override string ToString() { throw null; } + } + public partial class AgentManifestOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AgentManifestOptions() { } + public string Description { get { throw null; } } + public string ManifestId { get { throw null; } } + public System.Collections.Generic.IDictionary Metadata { get { throw null; } } + public System.Collections.Generic.IDictionary ParameterValues { get { throw null; } } + protected virtual Azure.AI.Projects.AgentManifestOptions JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static implicit operator System.ClientModel.BinaryContent (Azure.AI.Projects.AgentManifestOptions agentManifestOptions) { throw null; } + protected virtual Azure.AI.Projects.AgentManifestOptions PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.AgentManifestOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.AgentManifestOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AgentTaxonomyInput : Azure.AI.Projects.EvaluationTaxonomyInput, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AgentTaxonomyInput(Azure.AI.Projects.AzureAIAgentTarget target, System.Collections.Generic.IEnumerable riskCategories) { } + public System.Collections.Generic.IList RiskCategories { get { throw null; } } + public Azure.AI.Projects.AzureAIAgentTarget Target { get { throw null; } set { } } + protected override Azure.AI.Projects.EvaluationTaxonomyInput JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.EvaluationTaxonomyInput PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.AgentTaxonomyInput System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.AgentTaxonomyInput System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AgentVersionCreationOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AgentVersionCreationOptions(Azure.AI.Projects.OpenAI.AgentDefinition definition) { } + public Azure.AI.Projects.OpenAI.AgentDefinition Definition { get { throw null; } set { } } + public string Description { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Metadata { get { throw null; } } + protected virtual Azure.AI.Projects.AgentVersionCreationOptions JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.AgentVersionCreationOptions PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.AgentVersionCreationOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.AgentVersionCreationOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AIProjectAgentsOperations + { + protected AIProjectAgentsOperations() { } + public System.ClientModel.Primitives.ClientPipeline Pipeline { get { throw null; } } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.ClientModel.ClientResult CreateAgent(System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.Threading.Tasks.Task CreateAgentAsync(System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.ClientModel.ClientResult CreateAgentFromManifest(System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.Threading.Tasks.Task CreateAgentFromManifestAsync(System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult CreateAgentVersion(string agentName, Azure.AI.Projects.AgentVersionCreationOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.ClientModel.ClientResult CreateAgentVersion(string agentName, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> CreateAgentVersionAsync(string agentName, Azure.AI.Projects.AgentVersionCreationOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.Threading.Tasks.Task CreateAgentVersionAsync(string agentName, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.ClientModel.ClientResult CreateAgentVersionFromManifest(string agentName, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult CreateAgentVersionFromManifest(string agentName, string manifestId, Azure.AI.Projects.AgentManifestOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.Threading.Tasks.Task CreateAgentVersionFromManifestAsync(string agentName, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> CreateAgentVersionFromManifestAsync(string agentName, string manifestId, Azure.AI.Projects.AgentManifestOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.ClientModel.ClientResult DeleteAgent(string agentName, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult DeleteAgent(string agentName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.Threading.Tasks.Task DeleteAgentAsync(string agentName, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAgentAsync(string agentName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.ClientModel.ClientResult DeleteAgentVersion(string agentName, string agentVersion, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult DeleteAgentVersion(string agentName, string agentVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.Threading.Tasks.Task DeleteAgentVersionAsync(string agentName, string agentVersion, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAgentVersionAsync(string agentName, string agentVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.ClientModel.ClientResult GetAgent(string agentName, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult GetAgent(string agentName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.Threading.Tasks.Task GetAgentAsync(string agentName, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task> GetAgentAsync(string agentName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.CollectionResult GetAgents(Azure.AI.Projects.AgentKind? kind = default(Azure.AI.Projects.AgentKind?), int? limit = default(int?), Azure.AI.Projects.AgentListOrder? order = default(Azure.AI.Projects.AgentListOrder?), string after = null, string before = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetAgentsAsync(Azure.AI.Projects.AgentKind? kind = default(Azure.AI.Projects.AgentKind?), int? limit = default(int?), Azure.AI.Projects.AgentListOrder? order = default(Azure.AI.Projects.AgentListOrder?), string after = null, string before = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.ClientModel.ClientResult GetAgentVersion(string agentName, string agentVersion, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult GetAgentVersion(string agentName, string agentVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.Threading.Tasks.Task GetAgentVersionAsync(string agentName, string agentVersion, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task> GetAgentVersionAsync(string agentName, string agentVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.CollectionResult GetAgentVersions(string agentName, int? limit = default(int?), Azure.AI.Projects.AgentListOrder? order = default(Azure.AI.Projects.AgentListOrder?), string after = null, string before = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetAgentVersionsAsync(string agentName, int? limit = default(int?), Azure.AI.Projects.AgentListOrder? order = default(Azure.AI.Projects.AgentListOrder?), string after = null, string before = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.ClientModel.ClientResult UpdateAgent(string agentName, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.Threading.Tasks.Task UpdateAgentAsync(string agentName, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.ClientModel.ClientResult UpdateAgentFromManifest(string agentName, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public virtual System.Threading.Tasks.Task UpdateAgentFromManifestAsync(string agentName, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + } public partial class AIProjectBlobReference : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal AIProjectBlobReference() { } @@ -21,11 +213,20 @@ public partial class AIProjectClient : System.ClientModel.Primitives.ClientConne protected AIProjectClient() : base (default(int)) { } public AIProjectClient(System.Uri endpoint, System.ClientModel.AuthenticationTokenProvider tokenProvider) : base (default(int)) { } public AIProjectClient(System.Uri endpoint, System.ClientModel.AuthenticationTokenProvider tokenProvider, Azure.AI.Projects.AIProjectClientOptions options) : base (default(int)) { } + public virtual Azure.AI.Projects.AIProjectAgentsOperations Agents { get { throw null; } } public virtual Azure.AI.Projects.AIProjectConnectionsOperations Connections { get { throw null; } } public virtual Azure.AI.Projects.AIProjectDatasetsOperations Datasets { get { throw null; } } public virtual Azure.AI.Projects.AIProjectDeploymentsOperations Deployments { get { throw null; } } + public virtual Azure.AI.Projects.EvaluationRules EvaluationRules { get { throw null; } } + public virtual Azure.AI.Projects.EvaluationTaxonomies EvaluationTaxonomies { get { throw null; } } + public virtual Azure.AI.Projects.Evaluators Evaluators { get { throw null; } } public virtual Azure.AI.Projects.AIProjectIndexesOperations Indexes { get { throw null; } } + public virtual Azure.AI.Projects.Insights Insights { get { throw null; } } + public virtual Azure.AI.Projects.AIProjectMemoryStoresOperations MemoryStores { get { throw null; } } + public virtual Azure.AI.Projects.OpenAI.ProjectOpenAIClient OpenAI { get { throw null; } } public System.ClientModel.Primitives.ClientPipeline Pipeline { get { throw null; } } + public virtual Azure.AI.Projects.RedTeams RedTeams { get { throw null; } } + public virtual Azure.AI.Projects.Schedules Schedules { get { throw null; } } public virtual Azure.AI.Projects.AIProjectTelemetry Telemetry { get { throw null; } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override System.Collections.Generic.IEnumerable GetAllConnections() { throw null; } @@ -34,11 +235,14 @@ public AIProjectClient(System.Uri endpoint, System.ClientModel.AuthenticationTok } public partial class AIProjectClientOptions : System.ClientModel.Primitives.ClientPipelineOptions { - public AIProjectClientOptions(Azure.AI.Projects.AIProjectClientOptions.ServiceVersion version = Azure.AI.Projects.AIProjectClientOptions.ServiceVersion.V1) { } + public AIProjectClientOptions(Azure.AI.Projects.AIProjectClientOptions.ServiceVersion version = Azure.AI.Projects.AIProjectClientOptions.ServiceVersion.V2025_11_15_Preview) { } + public string UserAgentApplicationId { get { throw null; } set { } } public enum ServiceVersion { V2025_05_01 = 1, V1 = 2, + V2025_05_15_Preview = 3, + V2025_11_15_Preview = 4, } } public partial class AIProjectConnection : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel @@ -369,12 +573,142 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } + public partial class AIProjectMemoryStoresOperations + { + protected AIProjectMemoryStoresOperations() { } + public System.ClientModel.Primitives.ClientPipeline Pipeline { get { throw null; } } + public virtual System.ClientModel.ClientResult CreateMemoryStore(System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult CreateMemoryStore(string name, Azure.AI.Projects.MemoryStoreDefinition definition, string description = null, System.Collections.Generic.IDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task CreateMemoryStoreAsync(System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> CreateMemoryStoreAsync(string name, Azure.AI.Projects.MemoryStoreDefinition definition, string description = null, System.Collections.Generic.IDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult DeleteMemoryStore(string name, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult DeleteMemoryStore(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteMemoryStoreAsync(string name, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task> DeleteMemoryStoreAsync(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult DeleteScope(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult DeleteScope(string name, string scope, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteScopeAsync(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> DeleteScopeAsync(string name, string scope, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult GetMemoryStore(string name, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult GetMemoryStore(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GetMemoryStoreAsync(string name, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task> GetMemoryStoreAsync(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.CollectionResult GetMemoryStores(int? limit = default(int?), Azure.AI.Projects.AgentListOrder? order = default(Azure.AI.Projects.AgentListOrder?), string after = null, string before = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetMemoryStoresAsync(int? limit = default(int?), Azure.AI.Projects.AgentListOrder? order = default(Azure.AI.Projects.AgentListOrder?), string after = null, string before = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult GetUpdateResult(string name, string updateId, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult GetUpdateResult(string name, string updateId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GetUpdateResultAsync(string name, string updateId, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task> GetUpdateResultAsync(string name, string updateId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult SearchMemories(string memoryStoreName, Azure.AI.Projects.MemorySearchOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult SearchMemories(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> SearchMemoriesAsync(string memoryStoreName, Azure.AI.Projects.MemorySearchOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task SearchMemoriesAsync(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult UpdateMemories(string memoryStoreName, Azure.AI.Projects.MemoryUpdateOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult UpdateMemories(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateMemoriesAsync(string memoryStoreName, Azure.AI.Projects.MemoryUpdateOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task UpdateMemoriesAsync(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult UpdateMemoryStore(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult UpdateMemoryStore(string name, string description = null, System.Collections.Generic.IDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task UpdateMemoryStoreAsync(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> UpdateMemoryStoreAsync(string name, string description = null, System.Collections.Generic.IDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } public partial class AIProjectTelemetry { public AIProjectTelemetry(Azure.AI.Projects.AIProjectClient outerInstance) { } public string GetApplicationInsightsConnectionString() { throw null; } public System.Threading.Tasks.Task GetApplicationInsightsConnectionStringAsync() { throw null; } } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct AttackStrategy : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public AttackStrategy(string value) { throw null; } + public static Azure.AI.Projects.AttackStrategy AnsiiAttack { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy AsciiArt { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy AsciiSmuggler { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Atbash { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Base64 { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Baseline { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Binary { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Caesar { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy CharacterSpace { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy CharacterSwap { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Crescendo { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Diacritic { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Difficult { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Easy { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Flip { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy IndirectJailbreak { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Jailbreak { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Leetspeak { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Moderate { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Morse { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy MultiTurn { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy ROT13 { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy StringJoin { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy SuffixAppend { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Tense { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy UnicodeConfusable { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy UnicodeSubstitution { get { throw null; } } + public static Azure.AI.Projects.AttackStrategy Url { get { throw null; } } + public bool Equals(Azure.AI.Projects.AttackStrategy other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.AttackStrategy left, Azure.AI.Projects.AttackStrategy right) { throw null; } + public static implicit operator Azure.AI.Projects.AttackStrategy (string value) { throw null; } + public static implicit operator Azure.AI.Projects.AttackStrategy? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.AttackStrategy left, Azure.AI.Projects.AttackStrategy right) { throw null; } + public override string ToString() { throw null; } + } + public partial class AzureAIAgentTarget : Azure.AI.Projects.Target, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AzureAIAgentTarget(string name) { } + public string Name { get { throw null; } set { } } + public System.Collections.Generic.IList ToolDescriptions { get { throw null; } } + public string Version { get { throw null; } set { } } + protected override Azure.AI.Projects.Target JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.Target PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.AzureAIAgentTarget System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.AzureAIAgentTarget System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AzureAIAssistantTarget : Azure.AI.Projects.Target, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AzureAIAssistantTarget() { } + public string Id { get { throw null; } } + public System.Collections.Generic.IList ToolDescriptions { get { throw null; } } + protected override Azure.AI.Projects.Target JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.Target PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.AzureAIAssistantTarget System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.AzureAIAssistantTarget System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class AzureAIModelTarget : Azure.AI.Projects.Target, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal AzureAIModelTarget() { } + public string Model { get { throw null; } } + public Azure.AI.Projects.ModelSamplingParams SamplingParams { get { throw null; } } + protected override Azure.AI.Projects.Target JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.Target PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.AzureAIModelTarget System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.AzureAIModelTarget System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } public partial class AzureAIProjectsContext : System.ClientModel.Primitives.ModelReaderWriterContext { internal AzureAIProjectsContext() { } @@ -383,6 +717,11 @@ internal AzureAIProjectsContext() { } } public static partial class AzureAIProjectsModelFactory { + public static Azure.AI.Projects.AgentClusterInsightResult AgentClusterInsightResult(Azure.AI.Projects.ClusterInsightResult clusterInsight = null) { throw null; } + public static Azure.AI.Projects.AgentClusterInsightsRequest AgentClusterInsightsRequest(string agentName = null, Azure.AI.Projects.InsightModelConfiguration modelConfiguration = null) { throw null; } + public static Azure.AI.Projects.AgenticIdentityCredentials AgenticIdentityCredentials() { throw null; } + public static Azure.AI.Projects.AgentManifestOptions AgentManifestOptions(System.Collections.Generic.IDictionary metadata = null, string description = null, string manifestId = null, System.Collections.Generic.IDictionary parameterValues = null) { throw null; } + public static Azure.AI.Projects.AgentTaxonomyInput AgentTaxonomyInput(Azure.AI.Projects.AzureAIAgentTarget target = null, System.Collections.Generic.IEnumerable riskCategories = null) { throw null; } public static Azure.AI.Projects.AIProjectBlobReference AIProjectBlobReference(System.Uri blobUri = null, string storageAccountArmId = null, Azure.AI.Projects.BlobReferenceSasCredential credential = null) { throw null; } public static Azure.AI.Projects.AIProjectConnection AIProjectConnection(string name = null, string id = null, Azure.AI.Projects.ConnectionType type = default(Azure.AI.Projects.ConnectionType), string target = null, bool isDefault = false, Azure.AI.Projects.AIProjectConnectionBaseCredential credentials = null, System.Collections.Generic.IReadOnlyDictionary metadata = null) { throw null; } public static Azure.AI.Projects.AIProjectConnectionApiKeyCredential AIProjectConnectionApiKeyCredential(string apiKey = null) { throw null; } @@ -395,24 +734,100 @@ public static partial class AzureAIProjectsModelFactory public static Azure.AI.Projects.AIProjectDeployment AIProjectDeployment(string type = null, string name = null) { throw null; } public static Azure.AI.Projects.AIProjectIndex AIProjectIndex(string type = null, string id = null, string name = null, string version = null, string description = null, System.Collections.Generic.IDictionary tags = null) { throw null; } public static Azure.AI.Projects.AIProjectIndexFieldMapping AIProjectIndexFieldMapping(System.Collections.Generic.IEnumerable contentFields = null, string filepathField = null, string titleField = null, string urlField = null, System.Collections.Generic.IEnumerable vectorFields = null, System.Collections.Generic.IEnumerable metadataFields = null) { throw null; } + public static Azure.AI.Projects.AzureAIAgentTarget AzureAIAgentTarget(string name = null, string version = null, System.Collections.Generic.IEnumerable toolDescriptions = null) { throw null; } + public static Azure.AI.Projects.AzureAIAssistantTarget AzureAIAssistantTarget(string id = null, System.Collections.Generic.IEnumerable toolDescriptions = null) { throw null; } + public static Azure.AI.Projects.AzureAIModelTarget AzureAIModelTarget(string model = null, Azure.AI.Projects.ModelSamplingParams samplingParams = null) { throw null; } public static Azure.AI.Projects.AzureAISearchIndex AzureAISearchIndex(string id = null, string name = null, string version = null, string description = null, System.Collections.Generic.IDictionary tags = null, string connectionName = null, string indexName = null, Azure.AI.Projects.AIProjectIndexFieldMapping fieldMapping = null) { throw null; } + public static Azure.AI.Projects.AzureOpenAIModelConfiguration AzureOpenAIModelConfiguration(string modelDeploymentName = null) { throw null; } public static Azure.AI.Projects.BlobReferenceSasCredential BlobReferenceSasCredential(System.Uri sasUri = null) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.AI.Projects.BlobReferenceSasCredential BlobReferenceSasCredential(System.Uri sasUri, string type) { throw null; } + public static Azure.AI.Projects.ChartCoordinate ChartCoordinate(int x = 0, int y = 0, int size = 0) { throw null; } + public static Azure.AI.Projects.ChatSummaryMemoryItem ChatSummaryMemoryItem(string memoryId = null, System.DateTimeOffset updatedAt = default(System.DateTimeOffset), string scope = null, string content = null) { throw null; } + public static Azure.AI.Projects.ClusterInsightResult ClusterInsightResult(Azure.AI.Projects.InsightSummary summary = null, System.Collections.Generic.IEnumerable clusters = null, System.Collections.Generic.IDictionary coordinates = null) { throw null; } + public static Azure.AI.Projects.ClusterTokenUsage ClusterTokenUsage(int inputTokenUsage = 0, int outputTokenUsage = 0, int totalTokenUsage = 0) { throw null; } + public static Azure.AI.Projects.CodeBasedEvaluatorDefinition CodeBasedEvaluatorDefinition(System.BinaryData initParameters = null, System.BinaryData dataSchema = null, System.Collections.Generic.IDictionary metrics = null, string codeText = null) { throw null; } + public static Azure.AI.Projects.ContinuousEvaluationRuleAction ContinuousEvaluationRuleAction(string evalId = null, int? maxHourlyRuns = default(int?)) { throw null; } + public static Azure.AI.Projects.CreateAgentVersionFromManifestRequest CreateAgentVersionFromManifestRequest(System.Collections.Generic.IDictionary metadata = null, string description = null, string manifestId = null, System.Collections.Generic.IDictionary parameterValues = null) { throw null; } + public static Azure.AI.Projects.CronTrigger CronTrigger(string expression = null, string timeZone = null, string startTime = null, string endTime = null) { throw null; } + public static Azure.AI.Projects.DailyRecurrenceSchedule DailyRecurrenceSchedule(System.Collections.Generic.IEnumerable hours = null) { throw null; } public static Azure.AI.Projects.DatasetCredential DatasetCredential(Azure.AI.Projects.AIProjectBlobReference blobReference = null) { throw null; } + public static Azure.AI.Projects.DeleteMemoryStoreResponse DeleteMemoryStoreResponse(string name = null, bool deleted = false) { throw null; } public static Azure.AI.Projects.EmbeddingConfiguration EmbeddingConfiguration(string modelDeploymentName = null, string embeddingField = null) { throw null; } + public static Azure.AI.Projects.EvalCompareReport EvalCompareReport(System.Collections.Generic.IEnumerable comparisons = null, string method = null) { throw null; } + public static Azure.AI.Projects.EvalResult EvalResult(string name = null, string type = null, float score = 0f, bool passed = false) { throw null; } + public static Azure.AI.Projects.EvalRunResultCompareItem EvalRunResultCompareItem(string treatmentRunId = null, Azure.AI.Projects.EvalRunResultSummary treatmentRunSummary = null, float deltaEstimate = 0f, float pValue = 0f, Azure.AI.Projects.TreatmentEffectType treatmentEffect = default(Azure.AI.Projects.TreatmentEffectType)) { throw null; } + public static Azure.AI.Projects.EvalRunResultComparison EvalRunResultComparison(string testingCriteria = null, string metric = null, string evaluator = null, Azure.AI.Projects.EvalRunResultSummary baselineRunSummary = null, System.Collections.Generic.IEnumerable compareItems = null) { throw null; } + public static Azure.AI.Projects.EvalRunResultSummary EvalRunResultSummary(string runId = null, int sampleCount = 0, float average = 0f, float standardDeviation = 0f) { throw null; } + public static Azure.AI.Projects.EvaluationComparisonRequest EvaluationComparisonRequest(string evalId = null, string baselineRunId = null, System.Collections.Generic.IEnumerable treatmentRunIds = null) { throw null; } + public static Azure.AI.Projects.EvaluationResultSample EvaluationResultSample(string id = null, System.Collections.Generic.IDictionary features = null, System.Collections.Generic.IDictionary correlationInfo = null, Azure.AI.Projects.EvalResult evaluationResult = null) { throw null; } + public static Azure.AI.Projects.EvaluationRule EvaluationRule(string id = null, string displayName = null, string description = null, Azure.AI.Projects.EvaluationRuleAction action = null, Azure.AI.Projects.EvaluationRuleFilter filter = null, Azure.AI.Projects.EvaluationRuleEventType eventType = default(Azure.AI.Projects.EvaluationRuleEventType), bool enabled = false, System.Collections.Generic.IReadOnlyDictionary systemData = null) { throw null; } + public static Azure.AI.Projects.EvaluationRuleAction EvaluationRuleAction(string type = null) { throw null; } + public static Azure.AI.Projects.EvaluationRuleFilter EvaluationRuleFilter(string agentName = null) { throw null; } + public static Azure.AI.Projects.EvaluationRunClusterInsightResult EvaluationRunClusterInsightResult(Azure.AI.Projects.ClusterInsightResult clusterInsight = null) { throw null; } + public static Azure.AI.Projects.EvaluationRunClusterInsightsRequest EvaluationRunClusterInsightsRequest(string evalId = null, System.Collections.Generic.IEnumerable runIds = null, Azure.AI.Projects.InsightModelConfiguration modelConfiguration = null) { throw null; } + public static Azure.AI.Projects.EvaluationScheduleTask EvaluationScheduleTask(System.Collections.Generic.IDictionary configuration = null, string evalId = null, Azure.AI.Projects.EvaluationScheduleTaskEvalRun evalRun = null) { throw null; } + public static Azure.AI.Projects.EvaluationScheduleTaskEvalRun EvaluationScheduleTaskEvalRun() { throw null; } + public static Azure.AI.Projects.EvaluationTaxonomy EvaluationTaxonomy(string id = null, string name = null, string version = null, string description = null, System.Collections.Generic.IDictionary tags = null, Azure.AI.Projects.EvaluationTaxonomyInput taxonomyInput = null, System.Collections.Generic.IEnumerable taxonomyCategories = null, System.Collections.Generic.IDictionary properties = null) { throw null; } + public static Azure.AI.Projects.EvaluationTaxonomyInput EvaluationTaxonomyInput(string type = null) { throw null; } + public static Azure.AI.Projects.EvaluatorDefinition EvaluatorDefinition(string type = null, System.BinaryData initParameters = null, System.BinaryData dataSchema = null, System.Collections.Generic.IDictionary metrics = null) { throw null; } + public static Azure.AI.Projects.EvaluatorMetric EvaluatorMetric(Azure.AI.Projects.EvaluatorMetricType? type = default(Azure.AI.Projects.EvaluatorMetricType?), Azure.AI.Projects.EvaluatorMetricDirection? desirableDirection = default(Azure.AI.Projects.EvaluatorMetricDirection?), float? minValue = default(float?), float? maxValue = default(float?), bool? isPrimary = default(bool?)) { throw null; } + public static Azure.AI.Projects.EvaluatorVersion EvaluatorVersion(string displayName = null, System.Collections.Generic.IDictionary metadata = null, Azure.AI.Projects.EvaluatorType evaluatorType = default(Azure.AI.Projects.EvaluatorType), System.Collections.Generic.IEnumerable categories = null, Azure.AI.Projects.EvaluatorDefinition definition = null, string createdBy = null, long createdAt = (long)0, long modifiedAt = (long)0, string id = null, string name = null, string version = null, string description = null, System.Collections.Generic.IDictionary tags = null) { throw null; } public static Azure.AI.Projects.FileDataset FileDataset(System.Uri dataUri = null, bool? isReference = default(bool?), string connectionName = null, string id = null, string name = null, string version = null, string description = null, System.Collections.Generic.IDictionary tags = null) { throw null; } public static Azure.AI.Projects.FolderDataset FolderDataset(System.Uri dataUri = null, bool? isReference = default(bool?), string connectionName = null, string id = null, string name = null, string version = null, string description = null, System.Collections.Generic.IDictionary tags = null) { throw null; } + public static Azure.AI.Projects.HourlyRecurrenceSchedule HourlyRecurrenceSchedule() { throw null; } + public static Azure.AI.Projects.HumanEvaluationRuleAction HumanEvaluationRuleAction(string templateId = null) { throw null; } + public static Azure.AI.Projects.Insight Insight(string id = null, Azure.AI.Projects.InsightsMetadata metadata = null, Azure.Core.Foundations.OperationStatus state = default(Azure.Core.Foundations.OperationStatus), string displayName = null, Azure.AI.Projects.InsightRequest request = null, Azure.AI.Projects.InsightResult result = null) { throw null; } + public static Azure.AI.Projects.InsightCluster InsightCluster(string id = null, string label = null, string suggestion = null, string suggestionTitle = null, string description = null, int weight = 0, System.Collections.Generic.IEnumerable subClusters = null, System.Collections.Generic.IEnumerable samples = null) { throw null; } + public static Azure.AI.Projects.InsightModelConfiguration InsightModelConfiguration(string modelDeploymentName = null) { throw null; } + public static Azure.AI.Projects.InsightRequest InsightRequest(string type = null) { throw null; } + public static Azure.AI.Projects.InsightResult InsightResult(string type = null) { throw null; } + public static Azure.AI.Projects.InsightSample InsightSample(string id = null, string type = null, System.Collections.Generic.IDictionary features = null, System.Collections.Generic.IDictionary correlationInfo = null) { throw null; } + public static Azure.AI.Projects.InsightScheduleTask InsightScheduleTask(System.Collections.Generic.IDictionary configuration = null, Azure.AI.Projects.Insight insight = null) { throw null; } + public static Azure.AI.Projects.InsightsMetadata InsightsMetadata(System.DateTimeOffset createdAt = default(System.DateTimeOffset), System.DateTimeOffset? completedAt = default(System.DateTimeOffset?)) { throw null; } + public static Azure.AI.Projects.InsightSummary InsightSummary(int sampleCount = 0, int uniqueSubclusterCount = 0, int uniqueClusterCount = 0, string method = null, Azure.AI.Projects.ClusterTokenUsage usage = null) { throw null; } public static Azure.AI.Projects.ManagedAzureAISearchIndex ManagedAzureAISearchIndex(string id = null, string name = null, string version = null, string description = null, System.Collections.Generic.IDictionary tags = null, string vectorStoreId = null) { throw null; } + public static Azure.AI.Projects.MemoryItem MemoryItem(string memoryId = null, System.DateTimeOffset updatedAt = default(System.DateTimeOffset), string scope = null, string content = null, string kind = null) { throw null; } + public static Azure.AI.Projects.MemoryOperation MemoryOperation(Azure.AI.Projects.MemoryOperationKind kind = default(Azure.AI.Projects.MemoryOperationKind), Azure.AI.Projects.MemoryItem memoryItem = null) { throw null; } + public static Azure.AI.Projects.MemorySearchItem MemorySearchItem(Azure.AI.Projects.MemoryItem memoryItem = null) { throw null; } + public static Azure.AI.Projects.MemorySearchResultOptions MemorySearchResultOptions(int? maxMemories = default(int?)) { throw null; } + public static Azure.AI.Projects.MemoryStore MemoryStore(string id = null, System.DateTimeOffset createdAt = default(System.DateTimeOffset), System.DateTimeOffset updatedAt = default(System.DateTimeOffset), string name = null, string description = null, System.Collections.Generic.IDictionary metadata = null, Azure.AI.Projects.MemoryStoreDefinition definition = null) { throw null; } + public static Azure.AI.Projects.MemoryStoreDefaultDefinition MemoryStoreDefaultDefinition(string chatModel = null, string embeddingModel = null, Azure.AI.Projects.MemoryStoreDefaultOptions options = null) { throw null; } + public static Azure.AI.Projects.MemoryStoreDefaultOptions MemoryStoreDefaultOptions(bool userProfileEnabled = false, string userProfileDetails = null, bool chatSummaryEnabled = false) { throw null; } + public static Azure.AI.Projects.MemoryStoreDefinition MemoryStoreDefinition(string kind = null) { throw null; } + public static Azure.AI.Projects.MemoryStoreDeleteScopeResponse MemoryStoreDeleteScopeResponse(string name = null, string scope = null, bool deleted = false) { throw null; } + public static Azure.AI.Projects.MemoryStoreOperationUsage MemoryStoreOperationUsage(int embeddingTokens = 0, int inputTokens = 0, Azure.AI.Projects.MemoryStoreOperationUsageInputTokensDetails inputTokensDetails = null, int outputTokens = 0, Azure.AI.Projects.MemoryStoreOperationUsageOutputTokensDetails outputTokensDetails = null, int totalTokens = 0) { throw null; } + public static Azure.AI.Projects.MemoryStoreOperationUsageInputTokensDetails MemoryStoreOperationUsageInputTokensDetails(int cachedTokens = 0) { throw null; } + public static Azure.AI.Projects.MemoryStoreOperationUsageOutputTokensDetails MemoryStoreOperationUsageOutputTokensDetails(int reasoningTokens = 0) { throw null; } + public static Azure.AI.Projects.MemoryStoreSearchResponse MemoryStoreSearchResponse(string searchId = null, System.Collections.Generic.IEnumerable memories = null, Azure.AI.Projects.MemoryStoreOperationUsage usage = null) { throw null; } + public static Azure.AI.Projects.MemoryUpdateResultDetails MemoryUpdateResultDetails(System.Collections.Generic.IEnumerable memoryOperations = null, Azure.AI.Projects.MemoryStoreOperationUsage usage = null) { throw null; } public static Azure.AI.Projects.ModelDeployment ModelDeployment(string name = null, string modelName = null, string modelVersion = null, string modelPublisher = null, System.Collections.Generic.IReadOnlyDictionary capabilities = null, Azure.AI.Projects.ModelDeploymentSku sku = null, string connectionName = null) { throw null; } public static Azure.AI.Projects.ModelDeploymentSku ModelDeploymentSku(long capacity = (long)0, string family = null, string name = null, string size = null, string tier = null) { throw null; } + public static Azure.AI.Projects.ModelSamplingParams ModelSamplingParams(float temperature = 0f, float topP = 0f, int seed = 0, int maxCompletionTokens = 0) { throw null; } + public static Azure.AI.Projects.MonthlyRecurrenceSchedule MonthlyRecurrenceSchedule(System.Collections.Generic.IEnumerable daysOfMonth = null) { throw null; } public static Azure.AI.Projects.NoAuthenticationCredentials NoAuthenticationCredentials() { throw null; } + public static Azure.AI.Projects.OneTimeTrigger OneTimeTrigger(string triggerAt = null, string timeZone = null) { throw null; } public static Azure.AI.Projects.PendingUploadConfiguration PendingUploadConfiguration(string pendingUploadId = null, string connectionName = null) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.AI.Projects.PendingUploadConfiguration PendingUploadConfiguration(string pendingUploadId, string connectionName, Azure.AI.Projects.PendingUploadType pendingUploadType) { throw null; } public static Azure.AI.Projects.PendingUploadResult PendingUploadResult(Azure.AI.Projects.AIProjectBlobReference blobReference = null, string pendingUploadId = null, string version = null) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.AI.Projects.PendingUploadResult PendingUploadResult(Azure.AI.Projects.AIProjectBlobReference blobReference, string pendingUploadId, string version, Azure.AI.Projects.PendingUploadType pendingUploadType) { throw null; } + public static Azure.AI.Projects.PromptBasedEvaluatorDefinition PromptBasedEvaluatorDefinition(System.BinaryData initParameters = null, System.BinaryData dataSchema = null, System.Collections.Generic.IDictionary metrics = null, string promptText = null) { throw null; } + public static Azure.AI.Projects.RecurrenceSchedule RecurrenceSchedule(string type = null) { throw null; } + public static Azure.AI.Projects.RecurrenceTrigger RecurrenceTrigger(string startTime = null, string endTime = null, string timeZone = null, int interval = 0, Azure.AI.Projects.RecurrenceSchedule schedule = null) { throw null; } + public static Azure.AI.Projects.RedTeam RedTeam(string name = null, string displayName = null, int? numTurns = default(int?), System.Collections.Generic.IEnumerable attackStrategies = null, bool? simulationOnly = default(bool?), System.Collections.Generic.IEnumerable riskCategories = null, string applicationScenario = null, System.Collections.Generic.IDictionary tags = null, System.Collections.Generic.IDictionary properties = null, string status = null, Azure.AI.Projects.TargetConfig target = null) { throw null; } + public static Azure.AI.Projects.Schedule Schedule(string id = null, string displayName = null, string description = null, bool enabled = false, Azure.AI.Projects.ScheduleProvisioningStatus? provisioningStatus = default(Azure.AI.Projects.ScheduleProvisioningStatus?), Azure.AI.Projects.Trigger trigger = null, Azure.AI.Projects.ScheduleTask task = null, System.Collections.Generic.IDictionary tags = null, System.Collections.Generic.IDictionary properties = null, System.Collections.Generic.IReadOnlyDictionary systemData = null) { throw null; } + public static Azure.AI.Projects.ScheduleRun ScheduleRun(string runId = null, string scheduleId = null, bool success = false, string triggerTime = null, string error = null, System.Collections.Generic.IReadOnlyDictionary properties = null) { throw null; } + public static Azure.AI.Projects.ScheduleTask ScheduleTask(string type = null, System.Collections.Generic.IDictionary configuration = null) { throw null; } + public static Azure.AI.Projects.Target Target(string type = null) { throw null; } + public static Azure.AI.Projects.TargetConfig TargetConfig(string type = null) { throw null; } + public static Azure.AI.Projects.TaxonomyCategory TaxonomyCategory(string id = null, string name = null, string description = null, Azure.AI.Projects.RiskCategory riskCategory = default(Azure.AI.Projects.RiskCategory), System.Collections.Generic.IEnumerable subCategories = null, System.Collections.Generic.IDictionary properties = null) { throw null; } + public static Azure.AI.Projects.TaxonomySubCategory TaxonomySubCategory(string id = null, string name = null, string description = null, bool enabled = false, System.Collections.Generic.IDictionary properties = null) { throw null; } + public static Azure.AI.Projects.ToolDescription ToolDescription(string name = null, string description = null) { throw null; } + public static Azure.AI.Projects.Trigger Trigger(string type = null) { throw null; } + public static Azure.AI.Projects.UserProfileMemoryItem UserProfileMemoryItem(string memoryId = null, System.DateTimeOffset updatedAt = default(System.DateTimeOffset), string scope = null, string content = null) { throw null; } + public static Azure.AI.Projects.WeeklyRecurrenceSchedule WeeklyRecurrenceSchedule(System.Collections.Generic.IEnumerable daysOfWeek = null) { throw null; } } public partial class AzureAISearchIndex : Azure.AI.Projects.AIProjectIndex, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { @@ -430,6 +845,20 @@ protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter write string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } + public partial class AzureOpenAIModelConfiguration : Azure.AI.Projects.TargetConfig, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public AzureOpenAIModelConfiguration(string modelDeploymentName) { } + public string ModelDeploymentName { get { throw null; } set { } } + protected override Azure.AI.Projects.TargetConfig JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.TargetConfig PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.AzureOpenAIModelConfiguration System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.AzureOpenAIModelConfiguration System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } public partial class BlobReferenceSasCredential : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal BlobReferenceSasCredential() { } @@ -445,6 +874,81 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } + public partial class ChartCoordinate : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ChartCoordinate() { } + public int Size { get { throw null; } } + public int X { get { throw null; } } + public int Y { get { throw null; } } + protected virtual Azure.AI.Projects.ChartCoordinate JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.ChartCoordinate PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.ChartCoordinate System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.ChartCoordinate System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ChatSummaryMemoryItem : Azure.AI.Projects.MemoryItem, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ChatSummaryMemoryItem(string memoryId, System.DateTimeOffset updatedAt, string scope, string content) { } + protected override Azure.AI.Projects.MemoryItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.MemoryItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.ChatSummaryMemoryItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.ChatSummaryMemoryItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ClusterInsightResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ClusterInsightResult() { } + public System.Collections.Generic.IList Clusters { get { throw null; } } + public System.Collections.Generic.IDictionary Coordinates { get { throw null; } } + public Azure.AI.Projects.InsightSummary Summary { get { throw null; } } + protected virtual Azure.AI.Projects.ClusterInsightResult JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.ClusterInsightResult PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.ClusterInsightResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.ClusterInsightResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ClusterTokenUsage : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ClusterTokenUsage() { } + public int InputTokenUsage { get { throw null; } } + public int OutputTokenUsage { get { throw null; } } + public int TotalTokenUsage { get { throw null; } } + protected virtual Azure.AI.Projects.ClusterTokenUsage JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.ClusterTokenUsage PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.ClusterTokenUsage System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.ClusterTokenUsage System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class CodeBasedEvaluatorDefinition : Azure.AI.Projects.EvaluatorDefinition, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public CodeBasedEvaluatorDefinition(string codeText) { } + public string CodeText { get { throw null; } set { } } + protected override Azure.AI.Projects.EvaluatorDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.EvaluatorDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.CodeBasedEvaluatorDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.CodeBasedEvaluatorDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct ConnectionType : System.IEquatable { @@ -460,6 +964,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public static Azure.AI.Projects.ConnectionType AzureStorageAccount { get { throw null; } } public static Azure.AI.Projects.ConnectionType CosmosDB { get { throw null; } } public static Azure.AI.Projects.ConnectionType Custom { get { throw null; } } + public static Azure.AI.Projects.ConnectionType RemoteTool { get { throw null; } } public bool Equals(Azure.AI.Projects.ConnectionType other) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override bool Equals(object obj) { throw null; } @@ -471,6 +976,69 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public static bool operator !=(Azure.AI.Projects.ConnectionType left, Azure.AI.Projects.ConnectionType right) { throw null; } public override string ToString() { throw null; } } + public partial class ContinuousEvaluationRuleAction : Azure.AI.Projects.EvaluationRuleAction, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ContinuousEvaluationRuleAction(string evalId) { } + public string EvalId { get { throw null; } set { } } + public int? MaxHourlyRuns { get { throw null; } set { } } + protected override Azure.AI.Projects.EvaluationRuleAction JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.EvaluationRuleAction PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.ContinuousEvaluationRuleAction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.ContinuousEvaluationRuleAction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class CreateAgentVersionFromManifestRequest : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public CreateAgentVersionFromManifestRequest(string manifestId, System.Collections.Generic.IDictionary parameterValues) { } + public string Description { get { throw null; } set { } } + public string ManifestId { get { throw null; } } + public System.Collections.Generic.IDictionary Metadata { get { throw null; } } + public System.Collections.Generic.IDictionary ParameterValues { get { throw null; } } + protected virtual Azure.AI.Projects.CreateAgentVersionFromManifestRequest JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.CreateAgentVersionFromManifestRequest PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.CreateAgentVersionFromManifestRequest System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.CreateAgentVersionFromManifestRequest System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class CronTrigger : Azure.AI.Projects.Trigger, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public CronTrigger(string expression) { } + public string EndTime { get { throw null; } set { } } + public string Expression { get { throw null; } set { } } + public string StartTime { get { throw null; } set { } } + public string TimeZone { get { throw null; } set { } } + protected override Azure.AI.Projects.Trigger JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.Trigger PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.CronTrigger System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.CronTrigger System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class DailyRecurrenceSchedule : Azure.AI.Projects.RecurrenceSchedule, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public DailyRecurrenceSchedule(System.Collections.Generic.IEnumerable hours) { } + public System.Collections.Generic.IList Hours { get { throw null; } } + protected override Azure.AI.Projects.RecurrenceSchedule JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.RecurrenceSchedule PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.DailyRecurrenceSchedule System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.DailyRecurrenceSchedule System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } public partial class DatasetCredential : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { internal DatasetCredential() { } @@ -486,6 +1054,47 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct DayOfWeek : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public DayOfWeek(string value) { throw null; } + public static Azure.AI.Projects.DayOfWeek Friday { get { throw null; } } + public static Azure.AI.Projects.DayOfWeek Monday { get { throw null; } } + public static Azure.AI.Projects.DayOfWeek Saturday { get { throw null; } } + public static Azure.AI.Projects.DayOfWeek Sunday { get { throw null; } } + public static Azure.AI.Projects.DayOfWeek Thursday { get { throw null; } } + public static Azure.AI.Projects.DayOfWeek Tuesday { get { throw null; } } + public static Azure.AI.Projects.DayOfWeek Wednesday { get { throw null; } } + public bool Equals(Azure.AI.Projects.DayOfWeek other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.DayOfWeek left, Azure.AI.Projects.DayOfWeek right) { throw null; } + public static implicit operator Azure.AI.Projects.DayOfWeek (string value) { throw null; } + public static implicit operator Azure.AI.Projects.DayOfWeek? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.DayOfWeek left, Azure.AI.Projects.DayOfWeek right) { throw null; } + public override string ToString() { throw null; } + } + public partial class DeleteMemoryStoreResponse : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal DeleteMemoryStoreResponse() { } + public bool Deleted { get { throw null; } } + public string Name { get { throw null; } } + public string Object { get { throw null; } } + protected virtual Azure.AI.Projects.DeleteMemoryStoreResponse JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static explicit operator Azure.AI.Projects.DeleteMemoryStoreResponse (System.ClientModel.ClientResult result) { throw null; } + protected virtual Azure.AI.Projects.DeleteMemoryStoreResponse PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.DeleteMemoryStoreResponse System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.DeleteMemoryStoreResponse System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } public partial class EmbeddingConfiguration : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { public EmbeddingConfiguration(string modelDeploymentName, string embeddingField) { } @@ -501,118 +1110,1199 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class FileDataset : Azure.AI.Projects.AIProjectDataset, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + public partial class EvalCompareReport : Azure.AI.Projects.InsightResult, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - public FileDataset(System.Uri dataUri) { } - protected override Azure.AI.Projects.AIProjectDataset JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + internal EvalCompareReport() { } + public System.Collections.Generic.IList Comparisons { get { throw null; } } + public string Method { get { throw null; } } + protected override Azure.AI.Projects.InsightResult JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - protected override Azure.AI.Projects.AIProjectDataset PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override Azure.AI.Projects.InsightResult PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - Azure.AI.Projects.FileDataset System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.AI.Projects.FileDataset System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvalCompareReport System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvalCompareReport System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class FolderDataset : Azure.AI.Projects.AIProjectDataset, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + public partial class EvalResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - public FolderDataset(System.Uri dataUri) { } - protected override Azure.AI.Projects.AIProjectDataset JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - protected override Azure.AI.Projects.AIProjectDataset PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - Azure.AI.Projects.FolderDataset System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.AI.Projects.FolderDataset System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + internal EvalResult() { } + public string Name { get { throw null; } } + public bool Passed { get { throw null; } } + public float Score { get { throw null; } } + public string Type { get { throw null; } } + protected virtual Azure.AI.Projects.EvalResult JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.EvalResult PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvalResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvalResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ManagedAzureAISearchIndex : Azure.AI.Projects.AIProjectIndex, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + public partial class EvalRunResultCompareItem : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - public ManagedAzureAISearchIndex(string vectorStoreId) { } - public string VectorStoreId { get { throw null; } set { } } - protected override Azure.AI.Projects.AIProjectIndex JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - protected override Azure.AI.Projects.AIProjectIndex PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - Azure.AI.Projects.ManagedAzureAISearchIndex System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.AI.Projects.ManagedAzureAISearchIndex System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + internal EvalRunResultCompareItem() { } + public float DeltaEstimate { get { throw null; } } + public float PValue { get { throw null; } } + public Azure.AI.Projects.TreatmentEffectType TreatmentEffect { get { throw null; } } + public string TreatmentRunId { get { throw null; } } + public Azure.AI.Projects.EvalRunResultSummary TreatmentRunSummary { get { throw null; } } + protected virtual Azure.AI.Projects.EvalRunResultCompareItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.EvalRunResultCompareItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvalRunResultCompareItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvalRunResultCompareItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ModelDeployment : Azure.AI.Projects.AIProjectDeployment, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + public partial class EvalRunResultComparison : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - internal ModelDeployment() { } - public System.Collections.Generic.IReadOnlyDictionary Capabilities { get { throw null; } } - public string ConnectionName { get { throw null; } } - public string ModelName { get { throw null; } } - public string ModelPublisher { get { throw null; } } - public string ModelVersion { get { throw null; } } - public Azure.AI.Projects.ModelDeploymentSku Sku { get { throw null; } } - protected override Azure.AI.Projects.AIProjectDeployment JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - protected override Azure.AI.Projects.AIProjectDeployment PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - Azure.AI.Projects.ModelDeployment System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.AI.Projects.ModelDeployment System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + internal EvalRunResultComparison() { } + public Azure.AI.Projects.EvalRunResultSummary BaselineRunSummary { get { throw null; } } + public System.Collections.Generic.IList CompareItems { get { throw null; } } + public string Evaluator { get { throw null; } } + public string Metric { get { throw null; } } + public string TestingCriteria { get { throw null; } } + protected virtual Azure.AI.Projects.EvalRunResultComparison JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.EvalRunResultComparison PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvalRunResultComparison System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvalRunResultComparison System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class ModelDeploymentSku : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + public partial class EvalRunResultSummary : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - internal ModelDeploymentSku() { } - public long Capacity { get { throw null; } } - public string Family { get { throw null; } } - public string Name { get { throw null; } } - public string Size { get { throw null; } } - public string Tier { get { throw null; } } - protected virtual Azure.AI.Projects.ModelDeploymentSku JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + internal EvalRunResultSummary() { } + public float Average { get { throw null; } } + public string RunId { get { throw null; } } + public int SampleCount { get { throw null; } } + public float StandardDeviation { get { throw null; } } + protected virtual Azure.AI.Projects.EvalRunResultSummary JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - protected virtual Azure.AI.Projects.ModelDeploymentSku PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual Azure.AI.Projects.EvalRunResultSummary PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - Azure.AI.Projects.ModelDeploymentSku System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.AI.Projects.ModelDeploymentSku System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvalRunResultSummary System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvalRunResultSummary System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class NoAuthenticationCredentials : Azure.AI.Projects.AIProjectConnectionBaseCredential, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + public partial class EvaluationComparisonRequest : Azure.AI.Projects.InsightRequest, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - internal NoAuthenticationCredentials() { } - protected override Azure.AI.Projects.AIProjectConnectionBaseCredential JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + public EvaluationComparisonRequest(string evalId, string baselineRunId, System.Collections.Generic.IEnumerable treatmentRunIds) { } + public string BaselineRunId { get { throw null; } set { } } + public string EvalId { get { throw null; } set { } } + public System.Collections.Generic.IList TreatmentRunIds { get { throw null; } } + protected override Azure.AI.Projects.InsightRequest JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - protected override Azure.AI.Projects.AIProjectConnectionBaseCredential PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override Azure.AI.Projects.InsightRequest PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - Azure.AI.Projects.NoAuthenticationCredentials System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.AI.Projects.NoAuthenticationCredentials System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluationComparisonRequest System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluationComparisonRequest System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class PendingUploadConfiguration : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + public partial class EvaluationResultSample : Azure.AI.Projects.InsightSample, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - public PendingUploadConfiguration() { } - public string ConnectionName { get { throw null; } set { } } - public string PendingUploadId { get { throw null; } set { } } - public Azure.AI.Projects.PendingUploadType PendingUploadType { get { throw null; } } - protected virtual Azure.AI.Projects.PendingUploadConfiguration JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + internal EvaluationResultSample() { } + public Azure.AI.Projects.EvalResult EvaluationResult { get { throw null; } } + protected override Azure.AI.Projects.InsightSample JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.InsightSample PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluationResultSample System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluationResultSample System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class EvaluationRule : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public EvaluationRule(Azure.AI.Projects.EvaluationRuleAction action, Azure.AI.Projects.EvaluationRuleEventType eventType, bool enabled) { } + public Azure.AI.Projects.EvaluationRuleAction Action { get { throw null; } set { } } + public string Description { get { throw null; } set { } } + public string DisplayName { get { throw null; } set { } } + public bool Enabled { get { throw null; } set { } } + public Azure.AI.Projects.EvaluationRuleEventType EventType { get { throw null; } set { } } + public Azure.AI.Projects.EvaluationRuleFilter Filter { get { throw null; } set { } } + public string Id { get { throw null; } } + public System.Collections.Generic.IReadOnlyDictionary SystemData { get { throw null; } } + protected virtual Azure.AI.Projects.EvaluationRule JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - public static implicit operator System.ClientModel.BinaryContent (Azure.AI.Projects.PendingUploadConfiguration pendingUploadConfiguration) { throw null; } - protected virtual Azure.AI.Projects.PendingUploadConfiguration PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + public static explicit operator Azure.AI.Projects.EvaluationRule (System.ClientModel.ClientResult result) { throw null; } + public static implicit operator System.ClientModel.BinaryContent (Azure.AI.Projects.EvaluationRule evaluationRule) { throw null; } + protected virtual Azure.AI.Projects.EvaluationRule PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - Azure.AI.Projects.PendingUploadConfiguration System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } - Azure.AI.Projects.PendingUploadConfiguration System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } - System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluationRule System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluationRule System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } } - public partial class PendingUploadResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + public abstract partial class EvaluationRuleAction : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel { - internal PendingUploadResult() { } - public Azure.AI.Projects.AIProjectBlobReference BlobReference { get { throw null; } } - public string PendingUploadId { get { throw null; } } + internal EvaluationRuleAction() { } + protected virtual Azure.AI.Projects.EvaluationRuleAction JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.EvaluationRuleAction PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluationRuleAction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluationRuleAction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct EvaluationRuleActionType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public EvaluationRuleActionType(string value) { throw null; } + public static Azure.AI.Projects.EvaluationRuleActionType ContinuousEvaluation { get { throw null; } } + public static Azure.AI.Projects.EvaluationRuleActionType HumanEvaluation { get { throw null; } } + public bool Equals(Azure.AI.Projects.EvaluationRuleActionType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.EvaluationRuleActionType left, Azure.AI.Projects.EvaluationRuleActionType right) { throw null; } + public static implicit operator Azure.AI.Projects.EvaluationRuleActionType (string value) { throw null; } + public static implicit operator Azure.AI.Projects.EvaluationRuleActionType? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.EvaluationRuleActionType left, Azure.AI.Projects.EvaluationRuleActionType right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct EvaluationRuleEventType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public EvaluationRuleEventType(string value) { throw null; } + public static Azure.AI.Projects.EvaluationRuleEventType Manual { get { throw null; } } + public static Azure.AI.Projects.EvaluationRuleEventType ResponseCompleted { get { throw null; } } + public bool Equals(Azure.AI.Projects.EvaluationRuleEventType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.EvaluationRuleEventType left, Azure.AI.Projects.EvaluationRuleEventType right) { throw null; } + public static implicit operator Azure.AI.Projects.EvaluationRuleEventType (string value) { throw null; } + public static implicit operator Azure.AI.Projects.EvaluationRuleEventType? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.EvaluationRuleEventType left, Azure.AI.Projects.EvaluationRuleEventType right) { throw null; } + public override string ToString() { throw null; } + } + public partial class EvaluationRuleFilter : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public EvaluationRuleFilter(string agentName) { } + public string AgentName { get { throw null; } set { } } + protected virtual Azure.AI.Projects.EvaluationRuleFilter JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.EvaluationRuleFilter PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluationRuleFilter System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluationRuleFilter System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class EvaluationRules + { + protected EvaluationRules() { } + public System.ClientModel.Primitives.ClientPipeline Pipeline { get { throw null; } } + public virtual System.ClientModel.ClientResult CreateOrUpdate(string id, Azure.AI.Projects.EvaluationRule evaluationRule, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult CreateOrUpdate(string id, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(string id, Azure.AI.Projects.EvaluationRule evaluationRule, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task CreateOrUpdateAsync(string id, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult Delete(string id, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult Delete(string id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(string id, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(string id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult Get(string id, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult Get(string id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.CollectionResult GetAll(Azure.AI.Projects.EvaluationRuleActionType? actionType = default(Azure.AI.Projects.EvaluationRuleActionType?), string agentName = null, bool? enabled = default(bool?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.CollectionResult GetAll(string actionType, string agentName, bool? enabled, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetAllAsync(Azure.AI.Projects.EvaluationRuleActionType? actionType = default(Azure.AI.Projects.EvaluationRuleActionType?), string agentName = null, bool? enabled = default(bool?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.AsyncCollectionResult GetAllAsync(string actionType, string agentName, bool? enabled, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task GetAsync(string id, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class EvaluationRunClusterInsightResult : Azure.AI.Projects.InsightResult, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal EvaluationRunClusterInsightResult() { } + public Azure.AI.Projects.ClusterInsightResult ClusterInsight { get { throw null; } } + protected override Azure.AI.Projects.InsightResult JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.InsightResult PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluationRunClusterInsightResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluationRunClusterInsightResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class EvaluationRunClusterInsightsRequest : Azure.AI.Projects.InsightRequest, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public EvaluationRunClusterInsightsRequest(string evalId, System.Collections.Generic.IEnumerable runIds) { } + public string EvalId { get { throw null; } set { } } + public Azure.AI.Projects.InsightModelConfiguration ModelConfiguration { get { throw null; } set { } } + public System.Collections.Generic.IList RunIds { get { throw null; } } + protected override Azure.AI.Projects.InsightRequest JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.InsightRequest PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluationRunClusterInsightsRequest System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluationRunClusterInsightsRequest System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class EvaluationScheduleTask : Azure.AI.Projects.ScheduleTask, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public EvaluationScheduleTask(string evalId, Azure.AI.Projects.EvaluationScheduleTaskEvalRun evalRun) { } + public string EvalId { get { throw null; } set { } } + public Azure.AI.Projects.EvaluationScheduleTaskEvalRun EvalRun { get { throw null; } set { } } + protected override Azure.AI.Projects.ScheduleTask JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.ScheduleTask PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluationScheduleTask System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluationScheduleTask System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class EvaluationScheduleTaskEvalRun : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public EvaluationScheduleTaskEvalRun() { } + protected virtual Azure.AI.Projects.EvaluationScheduleTaskEvalRun JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.EvaluationScheduleTaskEvalRun PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluationScheduleTaskEvalRun System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluationScheduleTaskEvalRun System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class EvaluationTaxonomies + { + protected EvaluationTaxonomies() { } + public System.ClientModel.Primitives.ClientPipeline Pipeline { get { throw null; } } + public virtual System.ClientModel.ClientResult Create(string name, Azure.AI.Projects.EvaluationTaxonomy body, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult Create(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> CreateAsync(string name, Azure.AI.Projects.EvaluationTaxonomy body, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task CreateAsync(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult Delete(string name, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult Delete(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(string name, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult Get(string name, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult Get(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.CollectionResult GetAll(string inputName, string inputType, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.CollectionResult GetAll(string inputName = null, string inputType = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.AsyncCollectionResult GetAllAsync(string inputName, string inputType, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetAllAsync(string inputName = null, string inputType = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GetAsync(string name, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult Update(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task UpdateAsync(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + } + public partial class EvaluationTaxonomy : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public EvaluationTaxonomy(Azure.AI.Projects.EvaluationTaxonomyInput taxonomyInput) { } + public string Description { get { throw null; } set { } } + public string Id { get { throw null; } } + public string Name { get { throw null; } } + public System.Collections.Generic.IDictionary Properties { get { throw null; } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + public System.Collections.Generic.IList TaxonomyCategories { get { throw null; } } + public Azure.AI.Projects.EvaluationTaxonomyInput TaxonomyInput { get { throw null; } set { } } + public string Version { get { throw null; } } + protected virtual Azure.AI.Projects.EvaluationTaxonomy JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static explicit operator Azure.AI.Projects.EvaluationTaxonomy (System.ClientModel.ClientResult result) { throw null; } + public static implicit operator System.ClientModel.BinaryContent (Azure.AI.Projects.EvaluationTaxonomy evaluationTaxonomy) { throw null; } + protected virtual Azure.AI.Projects.EvaluationTaxonomy PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluationTaxonomy System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluationTaxonomy System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public abstract partial class EvaluationTaxonomyInput : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal EvaluationTaxonomyInput() { } + protected virtual Azure.AI.Projects.EvaluationTaxonomyInput JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.EvaluationTaxonomyInput PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluationTaxonomyInput System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluationTaxonomyInput System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct EvaluatorCategory : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public EvaluatorCategory(string value) { throw null; } + public static Azure.AI.Projects.EvaluatorCategory Agents { get { throw null; } } + public static Azure.AI.Projects.EvaluatorCategory Quality { get { throw null; } } + public static Azure.AI.Projects.EvaluatorCategory Safety { get { throw null; } } + public bool Equals(Azure.AI.Projects.EvaluatorCategory other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.EvaluatorCategory left, Azure.AI.Projects.EvaluatorCategory right) { throw null; } + public static implicit operator Azure.AI.Projects.EvaluatorCategory (string value) { throw null; } + public static implicit operator Azure.AI.Projects.EvaluatorCategory? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.EvaluatorCategory left, Azure.AI.Projects.EvaluatorCategory right) { throw null; } + public override string ToString() { throw null; } + } + public abstract partial class EvaluatorDefinition : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal EvaluatorDefinition() { } + public System.BinaryData DataSchema { get { throw null; } set { } } + public System.BinaryData InitParameters { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Metrics { get { throw null; } } + protected virtual Azure.AI.Projects.EvaluatorDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.EvaluatorDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluatorDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluatorDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class EvaluatorMetric : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public EvaluatorMetric() { } + public Azure.AI.Projects.EvaluatorMetricDirection? DesirableDirection { get { throw null; } set { } } + public bool? IsPrimary { get { throw null; } set { } } + public float? MaxValue { get { throw null; } set { } } + public float? MinValue { get { throw null; } set { } } + public Azure.AI.Projects.EvaluatorMetricType? Type { get { throw null; } set { } } + protected virtual Azure.AI.Projects.EvaluatorMetric JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.EvaluatorMetric PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluatorMetric System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluatorMetric System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct EvaluatorMetricDirection : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public EvaluatorMetricDirection(string value) { throw null; } + public static Azure.AI.Projects.EvaluatorMetricDirection Decrease { get { throw null; } } + public static Azure.AI.Projects.EvaluatorMetricDirection Increase { get { throw null; } } + public static Azure.AI.Projects.EvaluatorMetricDirection Neutral { get { throw null; } } + public bool Equals(Azure.AI.Projects.EvaluatorMetricDirection other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.EvaluatorMetricDirection left, Azure.AI.Projects.EvaluatorMetricDirection right) { throw null; } + public static implicit operator Azure.AI.Projects.EvaluatorMetricDirection (string value) { throw null; } + public static implicit operator Azure.AI.Projects.EvaluatorMetricDirection? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.EvaluatorMetricDirection left, Azure.AI.Projects.EvaluatorMetricDirection right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct EvaluatorMetricType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public EvaluatorMetricType(string value) { throw null; } + public static Azure.AI.Projects.EvaluatorMetricType Boolean { get { throw null; } } + public static Azure.AI.Projects.EvaluatorMetricType Continuous { get { throw null; } } + public static Azure.AI.Projects.EvaluatorMetricType Ordinal { get { throw null; } } + public bool Equals(Azure.AI.Projects.EvaluatorMetricType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.EvaluatorMetricType left, Azure.AI.Projects.EvaluatorMetricType right) { throw null; } + public static implicit operator Azure.AI.Projects.EvaluatorMetricType (string value) { throw null; } + public static implicit operator Azure.AI.Projects.EvaluatorMetricType? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.EvaluatorMetricType left, Azure.AI.Projects.EvaluatorMetricType right) { throw null; } + public override string ToString() { throw null; } + } + public partial class Evaluators + { + protected Evaluators() { } + public System.ClientModel.Primitives.ClientPipeline Pipeline { get { throw null; } } + public virtual System.ClientModel.ClientResult CreateVersion(string name, Azure.AI.Projects.EvaluatorVersion evaluatorVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult CreateVersion(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> CreateVersionAsync(string name, Azure.AI.Projects.EvaluatorVersion evaluatorVersion, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task CreateVersionAsync(string name, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult DeleteVersion(string name, string version, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult DeleteVersion(string name, string version, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteVersionAsync(string name, string version, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task DeleteVersionAsync(string name, string version, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.CollectionResult GetLatestVersions(Azure.AI.Projects.ListVersionsRequestType? type = default(Azure.AI.Projects.ListVersionsRequestType?), int? limit = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.CollectionResult GetLatestVersions(string type, int? limit, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetLatestVersionsAsync(Azure.AI.Projects.ListVersionsRequestType? type = default(Azure.AI.Projects.ListVersionsRequestType?), int? limit = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.AsyncCollectionResult GetLatestVersionsAsync(string type, int? limit, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult GetVersion(string name, string version, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult GetVersion(string name, string version, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GetVersionAsync(string name, string version, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task> GetVersionAsync(string name, string version, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.CollectionResult GetVersions(string name, Azure.AI.Projects.ListVersionsRequestType? type = default(Azure.AI.Projects.ListVersionsRequestType?), int? limit = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.CollectionResult GetVersions(string name, string type, int? limit, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetVersionsAsync(string name, Azure.AI.Projects.ListVersionsRequestType? type = default(Azure.AI.Projects.ListVersionsRequestType?), int? limit = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.AsyncCollectionResult GetVersionsAsync(string name, string type, int? limit, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult UpdateVersion(string name, string version, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task UpdateVersionAsync(string name, string version, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct EvaluatorType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public EvaluatorType(string value) { throw null; } + public static Azure.AI.Projects.EvaluatorType BuiltIn { get { throw null; } } + public static Azure.AI.Projects.EvaluatorType Custom { get { throw null; } } + public bool Equals(Azure.AI.Projects.EvaluatorType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.EvaluatorType left, Azure.AI.Projects.EvaluatorType right) { throw null; } + public static implicit operator Azure.AI.Projects.EvaluatorType (string value) { throw null; } + public static implicit operator Azure.AI.Projects.EvaluatorType? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.EvaluatorType left, Azure.AI.Projects.EvaluatorType right) { throw null; } + public override string ToString() { throw null; } + } + public partial class EvaluatorVersion : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public EvaluatorVersion(Azure.AI.Projects.EvaluatorType evaluatorType, System.Collections.Generic.IEnumerable categories, Azure.AI.Projects.EvaluatorDefinition definition) { } + public System.Collections.Generic.IList Categories { get { throw null; } } + public long CreatedAt { get { throw null; } } + public string CreatedBy { get { throw null; } } + public Azure.AI.Projects.EvaluatorDefinition Definition { get { throw null; } set { } } + public string Description { get { throw null; } set { } } + public string DisplayName { get { throw null; } set { } } + public Azure.AI.Projects.EvaluatorType EvaluatorType { get { throw null; } set { } } + public string Id { get { throw null; } } + public System.Collections.Generic.IDictionary Metadata { get { throw null; } } + public long ModifiedAt { get { throw null; } } + public string Name { get { throw null; } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + public string Version { get { throw null; } } + protected virtual Azure.AI.Projects.EvaluatorVersion JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static explicit operator Azure.AI.Projects.EvaluatorVersion (System.ClientModel.ClientResult result) { throw null; } + public static implicit operator System.ClientModel.BinaryContent (Azure.AI.Projects.EvaluatorVersion evaluatorVersion) { throw null; } + protected virtual Azure.AI.Projects.EvaluatorVersion PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.EvaluatorVersion System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.EvaluatorVersion System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class FileDataset : Azure.AI.Projects.AIProjectDataset, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public FileDataset(System.Uri dataUri) { } + protected override Azure.AI.Projects.AIProjectDataset JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.AIProjectDataset PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.FileDataset System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.FileDataset System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class FolderDataset : Azure.AI.Projects.AIProjectDataset, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public FolderDataset(System.Uri dataUri) { } + protected override Azure.AI.Projects.AIProjectDataset JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.AIProjectDataset PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.FolderDataset System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.FolderDataset System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class HourlyRecurrenceSchedule : Azure.AI.Projects.RecurrenceSchedule, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public HourlyRecurrenceSchedule() { } + protected override Azure.AI.Projects.RecurrenceSchedule JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.RecurrenceSchedule PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.HourlyRecurrenceSchedule System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.HourlyRecurrenceSchedule System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class HumanEvaluationRuleAction : Azure.AI.Projects.EvaluationRuleAction, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public HumanEvaluationRuleAction(string templateId) { } + public string TemplateId { get { throw null; } set { } } + protected override Azure.AI.Projects.EvaluationRuleAction JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.EvaluationRuleAction PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.HumanEvaluationRuleAction System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.HumanEvaluationRuleAction System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class Insight : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public Insight(string displayName, Azure.AI.Projects.InsightRequest request) { } + public string DisplayName { get { throw null; } set { } } + public string Id { get { throw null; } } + public Azure.AI.Projects.InsightsMetadata Metadata { get { throw null; } } + public Azure.AI.Projects.InsightRequest Request { get { throw null; } set { } } + public Azure.AI.Projects.InsightResult Result { get { throw null; } } + public Azure.Core.Foundations.OperationStatus State { get { throw null; } } + protected virtual Azure.AI.Projects.Insight JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static explicit operator Azure.AI.Projects.Insight (System.ClientModel.ClientResult result) { throw null; } + public static implicit operator System.ClientModel.BinaryContent (Azure.AI.Projects.Insight insight) { throw null; } + protected virtual Azure.AI.Projects.Insight PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.Insight System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.Insight System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class InsightCluster : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal InsightCluster() { } + public string Description { get { throw null; } } + public string Id { get { throw null; } } + public string Label { get { throw null; } } + public System.Collections.Generic.IList Samples { get { throw null; } } + public System.Collections.Generic.IList SubClusters { get { throw null; } } + public string Suggestion { get { throw null; } } + public string SuggestionTitle { get { throw null; } } + public int Weight { get { throw null; } } + protected virtual Azure.AI.Projects.InsightCluster JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.InsightCluster PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.InsightCluster System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.InsightCluster System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class InsightModelConfiguration : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public InsightModelConfiguration(string modelDeploymentName) { } + public string ModelDeploymentName { get { throw null; } set { } } + protected virtual Azure.AI.Projects.InsightModelConfiguration JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.InsightModelConfiguration PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.InsightModelConfiguration System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.InsightModelConfiguration System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public abstract partial class InsightRequest : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal InsightRequest() { } + protected virtual Azure.AI.Projects.InsightRequest JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.InsightRequest PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.InsightRequest System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.InsightRequest System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public abstract partial class InsightResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal InsightResult() { } + protected virtual Azure.AI.Projects.InsightResult JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.InsightResult PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.InsightResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.InsightResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class Insights + { + protected Insights() { } + public System.ClientModel.Primitives.ClientPipeline Pipeline { get { throw null; } } + public virtual System.ClientModel.ClientResult Generate(Azure.AI.Projects.Insight insight, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult Generate(System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> GenerateAsync(Azure.AI.Projects.Insight insight, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GenerateAsync(System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult Get(string id, bool? includeCoordinates, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult Get(string id, bool? includeCoordinates = default(bool?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.CollectionResult GetAll(Azure.AI.Projects.InsightType? type = default(Azure.AI.Projects.InsightType?), string evalId = null, string runId = null, string agentName = null, bool? includeCoordinates = default(bool?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.CollectionResult GetAll(string type, string evalId, string runId, string agentName, bool? includeCoordinates, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetAllAsync(Azure.AI.Projects.InsightType? type = default(Azure.AI.Projects.InsightType?), string evalId = null, string runId = null, string agentName = null, bool? includeCoordinates = default(bool?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.AsyncCollectionResult GetAllAsync(string type, string evalId, string runId, string agentName, bool? includeCoordinates, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task GetAsync(string id, bool? includeCoordinates, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string id, bool? includeCoordinates = default(bool?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public abstract partial class InsightSample : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal InsightSample() { } + public System.Collections.Generic.IDictionary CorrelationInfo { get { throw null; } } + public System.Collections.Generic.IDictionary Features { get { throw null; } } + public string Id { get { throw null; } } + protected virtual Azure.AI.Projects.InsightSample JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.InsightSample PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.InsightSample System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.InsightSample System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class InsightScheduleTask : Azure.AI.Projects.ScheduleTask, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public InsightScheduleTask(Azure.AI.Projects.Insight insight) { } + public Azure.AI.Projects.Insight Insight { get { throw null; } set { } } + protected override Azure.AI.Projects.ScheduleTask JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.ScheduleTask PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.InsightScheduleTask System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.InsightScheduleTask System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class InsightsMetadata : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal InsightsMetadata() { } + public System.DateTimeOffset? CompletedAt { get { throw null; } } + public System.DateTimeOffset CreatedAt { get { throw null; } } + protected virtual Azure.AI.Projects.InsightsMetadata JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.InsightsMetadata PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.InsightsMetadata System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.InsightsMetadata System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class InsightSummary : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal InsightSummary() { } + public string Method { get { throw null; } } + public int SampleCount { get { throw null; } } + public int UniqueClusterCount { get { throw null; } } + public int UniqueSubclusterCount { get { throw null; } } + public Azure.AI.Projects.ClusterTokenUsage Usage { get { throw null; } } + protected virtual Azure.AI.Projects.InsightSummary JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.InsightSummary PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.InsightSummary System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.InsightSummary System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct InsightType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public InsightType(string value) { throw null; } + public static Azure.AI.Projects.InsightType AgentClusterInsight { get { throw null; } } + public static Azure.AI.Projects.InsightType EvaluationComparison { get { throw null; } } + public static Azure.AI.Projects.InsightType EvaluationRunClusterInsight { get { throw null; } } + public bool Equals(Azure.AI.Projects.InsightType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.InsightType left, Azure.AI.Projects.InsightType right) { throw null; } + public static implicit operator Azure.AI.Projects.InsightType (string value) { throw null; } + public static implicit operator Azure.AI.Projects.InsightType? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.InsightType left, Azure.AI.Projects.InsightType right) { throw null; } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ListVersionsRequestType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ListVersionsRequestType(string value) { throw null; } + public static Azure.AI.Projects.ListVersionsRequestType All { get { throw null; } } + public static Azure.AI.Projects.ListVersionsRequestType BuiltIn { get { throw null; } } + public static Azure.AI.Projects.ListVersionsRequestType Custom { get { throw null; } } + public bool Equals(Azure.AI.Projects.ListVersionsRequestType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.ListVersionsRequestType left, Azure.AI.Projects.ListVersionsRequestType right) { throw null; } + public static implicit operator Azure.AI.Projects.ListVersionsRequestType (string value) { throw null; } + public static implicit operator Azure.AI.Projects.ListVersionsRequestType? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.ListVersionsRequestType left, Azure.AI.Projects.ListVersionsRequestType right) { throw null; } + public override string ToString() { throw null; } + } + public partial class ManagedAzureAISearchIndex : Azure.AI.Projects.AIProjectIndex, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ManagedAzureAISearchIndex(string vectorStoreId) { } + public string VectorStoreId { get { throw null; } set { } } + protected override Azure.AI.Projects.AIProjectIndex JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.AIProjectIndex PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.ManagedAzureAISearchIndex System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.ManagedAzureAISearchIndex System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public abstract partial class MemoryItem : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemoryItem() { } + public string Content { get { throw null; } set { } } + public string MemoryId { get { throw null; } set { } } + public string Scope { get { throw null; } set { } } + public System.DateTimeOffset UpdatedAt { get { throw null; } set { } } + protected virtual Azure.AI.Projects.MemoryItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.MemoryItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemoryOperation : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemoryOperation() { } + public Azure.AI.Projects.MemoryOperationKind Kind { get { throw null; } } + public Azure.AI.Projects.MemoryItem MemoryItem { get { throw null; } } + protected virtual Azure.AI.Projects.MemoryOperation JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.MemoryOperation PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryOperation System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryOperation System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct MemoryOperationKind : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public MemoryOperationKind(string value) { throw null; } + public static Azure.AI.Projects.MemoryOperationKind Create { get { throw null; } } + public static Azure.AI.Projects.MemoryOperationKind Delete { get { throw null; } } + public static Azure.AI.Projects.MemoryOperationKind Update { get { throw null; } } + public bool Equals(Azure.AI.Projects.MemoryOperationKind other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.MemoryOperationKind left, Azure.AI.Projects.MemoryOperationKind right) { throw null; } + public static implicit operator Azure.AI.Projects.MemoryOperationKind (string value) { throw null; } + public static implicit operator Azure.AI.Projects.MemoryOperationKind? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.MemoryOperationKind left, Azure.AI.Projects.MemoryOperationKind right) { throw null; } + public override string ToString() { throw null; } + } + public partial class MemorySearchItem : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MemorySearchItem(Azure.AI.Projects.MemoryItem memoryItem) { } + public Azure.AI.Projects.MemoryItem MemoryItem { get { throw null; } set { } } + protected virtual Azure.AI.Projects.MemorySearchItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.MemorySearchItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemorySearchItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemorySearchItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemorySearchOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MemorySearchOptions(string scope) { } + public System.Collections.Generic.IList Items { get { throw null; } } + public string PreviousSearchId { get { throw null; } set { } } + public Azure.AI.Projects.MemorySearchResultOptions ResultOptions { get { throw null; } set { } } + public string Scope { get { throw null; } } + Azure.AI.Projects.MemorySearchOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemorySearchOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemorySearchResultOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MemorySearchResultOptions() { } + public int? MaxMemories { get { throw null; } set { } } + protected virtual Azure.AI.Projects.MemorySearchResultOptions JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.MemorySearchResultOptions PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemorySearchResultOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemorySearchResultOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemoryStore : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemoryStore() { } + public System.DateTimeOffset CreatedAt { get { throw null; } } + public Azure.AI.Projects.MemoryStoreDefinition Definition { get { throw null; } } + public string Description { get { throw null; } } + public string Id { get { throw null; } } + public System.Collections.Generic.IDictionary Metadata { get { throw null; } } + public string Name { get { throw null; } } + public System.DateTimeOffset UpdatedAt { get { throw null; } } + protected virtual Azure.AI.Projects.MemoryStore JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static explicit operator Azure.AI.Projects.MemoryStore (System.ClientModel.ClientResult result) { throw null; } + protected virtual Azure.AI.Projects.MemoryStore PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryStore System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryStore System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemoryStoreDefaultDefinition : Azure.AI.Projects.MemoryStoreDefinition, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MemoryStoreDefaultDefinition(string chatModel, string embeddingModel) { } + public string ChatModel { get { throw null; } set { } } + public string EmbeddingModel { get { throw null; } set { } } + public Azure.AI.Projects.MemoryStoreDefaultOptions Options { get { throw null; } set { } } + protected override Azure.AI.Projects.MemoryStoreDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.MemoryStoreDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryStoreDefaultDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryStoreDefaultDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemoryStoreDefaultOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MemoryStoreDefaultOptions(bool userProfileEnabled, bool chatSummaryEnabled) { } + public bool ChatSummaryEnabled { get { throw null; } set { } } + public string UserProfileDetails { get { throw null; } set { } } + public bool UserProfileEnabled { get { throw null; } set { } } + protected virtual Azure.AI.Projects.MemoryStoreDefaultOptions JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.MemoryStoreDefaultOptions PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryStoreDefaultOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryStoreDefaultOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public abstract partial class MemoryStoreDefinition : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemoryStoreDefinition() { } + protected virtual Azure.AI.Projects.MemoryStoreDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.MemoryStoreDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryStoreDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryStoreDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemoryStoreDeleteScopeResponse : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemoryStoreDeleteScopeResponse() { } + public bool Deleted { get { throw null; } } + public string Name { get { throw null; } } + public string Object { get { throw null; } } + public string Scope { get { throw null; } } + protected virtual Azure.AI.Projects.MemoryStoreDeleteScopeResponse JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static explicit operator Azure.AI.Projects.MemoryStoreDeleteScopeResponse (System.ClientModel.ClientResult result) { throw null; } + protected virtual Azure.AI.Projects.MemoryStoreDeleteScopeResponse PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryStoreDeleteScopeResponse System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryStoreDeleteScopeResponse System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemoryStoreOperationUsage : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemoryStoreOperationUsage() { } + public int EmbeddingTokens { get { throw null; } } + public int InputTokens { get { throw null; } } + public Azure.AI.Projects.MemoryStoreOperationUsageInputTokensDetails InputTokensDetails { get { throw null; } } + public int OutputTokens { get { throw null; } } + public Azure.AI.Projects.MemoryStoreOperationUsageOutputTokensDetails OutputTokensDetails { get { throw null; } } + public int TotalTokens { get { throw null; } } + protected virtual Azure.AI.Projects.MemoryStoreOperationUsage JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.MemoryStoreOperationUsage PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryStoreOperationUsage System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryStoreOperationUsage System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemoryStoreOperationUsageInputTokensDetails : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemoryStoreOperationUsageInputTokensDetails() { } + public int CachedTokens { get { throw null; } } + protected virtual Azure.AI.Projects.MemoryStoreOperationUsageInputTokensDetails JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.MemoryStoreOperationUsageInputTokensDetails PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryStoreOperationUsageInputTokensDetails System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryStoreOperationUsageInputTokensDetails System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemoryStoreOperationUsageOutputTokensDetails : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemoryStoreOperationUsageOutputTokensDetails() { } + public int ReasoningTokens { get { throw null; } } + protected virtual Azure.AI.Projects.MemoryStoreOperationUsageOutputTokensDetails JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.MemoryStoreOperationUsageOutputTokensDetails PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryStoreOperationUsageOutputTokensDetails System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryStoreOperationUsageOutputTokensDetails System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemoryStoreSearchResponse : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemoryStoreSearchResponse() { } + public System.Collections.Generic.IList Memories { get { throw null; } } + public string SearchId { get { throw null; } } + public Azure.AI.Projects.MemoryStoreOperationUsage Usage { get { throw null; } } + protected virtual Azure.AI.Projects.MemoryStoreSearchResponse JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static explicit operator Azure.AI.Projects.MemoryStoreSearchResponse (System.ClientModel.ClientResult result) { throw null; } + protected virtual Azure.AI.Projects.MemoryStoreSearchResponse PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryStoreSearchResponse System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryStoreSearchResponse System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public enum MemoryStoreUpdateStatus + { + Queued = 0, + InProgress = 1, + Completed = 2, + Failed = 3, + Superseded = 4, + } + public partial class MemoryUpdateOptions : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MemoryUpdateOptions(string scope) { } + public System.Collections.Generic.IList Items { get { throw null; } } + public string PreviousUpdateId { get { throw null; } set { } } + public string Scope { get { throw null; } } + public int? UpdateDelay { get { throw null; } set { } } + Azure.AI.Projects.MemoryUpdateOptions System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryUpdateOptions System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemoryUpdateResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemoryUpdateResult() { } + public Azure.AI.Projects.MemoryUpdateResultDetails Details { get { throw null; } } + public string ErrorDetails { get { throw null; } } + public Azure.AI.Projects.MemoryStoreUpdateStatus Status { get { throw null; } } + public string SupersededBy { get { throw null; } } + public string UpdateId { get { throw null; } } + protected virtual Azure.AI.Projects.MemoryUpdateResult JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static explicit operator Azure.AI.Projects.MemoryUpdateResult (System.ClientModel.ClientResult result) { throw null; } + protected virtual Azure.AI.Projects.MemoryUpdateResult PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryUpdateResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryUpdateResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MemoryUpdateResultDetails : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal MemoryUpdateResultDetails() { } + public System.Collections.Generic.IList MemoryOperations { get { throw null; } } + public Azure.AI.Projects.MemoryStoreOperationUsage Usage { get { throw null; } } + protected virtual Azure.AI.Projects.MemoryUpdateResultDetails JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static explicit operator Azure.AI.Projects.MemoryUpdateResultDetails (System.ClientModel.ClientResult result) { throw null; } + protected virtual Azure.AI.Projects.MemoryUpdateResultDetails PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MemoryUpdateResultDetails System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MemoryUpdateResultDetails System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ModelDeployment : Azure.AI.Projects.AIProjectDeployment, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ModelDeployment() { } + public System.Collections.Generic.IReadOnlyDictionary Capabilities { get { throw null; } } + public string ConnectionName { get { throw null; } } + public string ModelName { get { throw null; } } + public string ModelPublisher { get { throw null; } } + public string ModelVersion { get { throw null; } } + public Azure.AI.Projects.ModelDeploymentSku Sku { get { throw null; } } + protected override Azure.AI.Projects.AIProjectDeployment JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.AIProjectDeployment PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.ModelDeployment System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.ModelDeployment System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ModelDeploymentSku : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ModelDeploymentSku() { } + public long Capacity { get { throw null; } } + public string Family { get { throw null; } } + public string Name { get { throw null; } } + public string Size { get { throw null; } } + public string Tier { get { throw null; } } + protected virtual Azure.AI.Projects.ModelDeploymentSku JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.ModelDeploymentSku PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.ModelDeploymentSku System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.ModelDeploymentSku System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ModelSamplingParams : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ModelSamplingParams() { } + public int MaxCompletionTokens { get { throw null; } } + public int Seed { get { throw null; } } + public float Temperature { get { throw null; } } + public float TopP { get { throw null; } } + protected virtual Azure.AI.Projects.ModelSamplingParams JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.ModelSamplingParams PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.ModelSamplingParams System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.ModelSamplingParams System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class MonthlyRecurrenceSchedule : Azure.AI.Projects.RecurrenceSchedule, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public MonthlyRecurrenceSchedule(System.Collections.Generic.IEnumerable daysOfMonth) { } + public System.Collections.Generic.IList DaysOfMonth { get { throw null; } } + protected override Azure.AI.Projects.RecurrenceSchedule JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.RecurrenceSchedule PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.MonthlyRecurrenceSchedule System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.MonthlyRecurrenceSchedule System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class NoAuthenticationCredentials : Azure.AI.Projects.AIProjectConnectionBaseCredential, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal NoAuthenticationCredentials() { } + protected override Azure.AI.Projects.AIProjectConnectionBaseCredential JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.AIProjectConnectionBaseCredential PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.NoAuthenticationCredentials System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.NoAuthenticationCredentials System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class OneTimeTrigger : Azure.AI.Projects.Trigger, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public OneTimeTrigger(string triggerAt) { } + public string TimeZone { get { throw null; } set { } } + public string TriggerAt { get { throw null; } set { } } + protected override Azure.AI.Projects.Trigger JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.Trigger PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.OneTimeTrigger System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.OneTimeTrigger System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class PendingUploadConfiguration : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public PendingUploadConfiguration() { } + public string ConnectionName { get { throw null; } set { } } + public string PendingUploadId { get { throw null; } set { } } + public Azure.AI.Projects.PendingUploadType PendingUploadType { get { throw null; } } + protected virtual Azure.AI.Projects.PendingUploadConfiguration JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static implicit operator System.ClientModel.BinaryContent (Azure.AI.Projects.PendingUploadConfiguration pendingUploadConfiguration) { throw null; } + protected virtual Azure.AI.Projects.PendingUploadConfiguration PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.PendingUploadConfiguration System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.PendingUploadConfiguration System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class PendingUploadResult : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal PendingUploadResult() { } + public Azure.AI.Projects.AIProjectBlobReference BlobReference { get { throw null; } } + public string PendingUploadId { get { throw null; } } public Azure.AI.Projects.PendingUploadType PendingUploadType { get { throw null; } } public string Version { get { throw null; } } protected virtual Azure.AI.Projects.PendingUploadResult JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -645,4 +2335,394 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer public static bool operator !=(Azure.AI.Projects.PendingUploadType left, Azure.AI.Projects.PendingUploadType right) { throw null; } public override string ToString() { throw null; } } + public partial class PromptBasedEvaluatorDefinition : Azure.AI.Projects.EvaluatorDefinition, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public PromptBasedEvaluatorDefinition(string promptText) { } + public string PromptText { get { throw null; } set { } } + protected override Azure.AI.Projects.EvaluatorDefinition JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.EvaluatorDefinition PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.PromptBasedEvaluatorDefinition System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.PromptBasedEvaluatorDefinition System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public abstract partial class RecurrenceSchedule : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal RecurrenceSchedule() { } + protected virtual Azure.AI.Projects.RecurrenceSchedule JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.RecurrenceSchedule PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.RecurrenceSchedule System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.RecurrenceSchedule System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class RecurrenceTrigger : Azure.AI.Projects.Trigger, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public RecurrenceTrigger(int interval, Azure.AI.Projects.RecurrenceSchedule schedule) { } + public string EndTime { get { throw null; } set { } } + public int Interval { get { throw null; } set { } } + public Azure.AI.Projects.RecurrenceSchedule Schedule { get { throw null; } set { } } + public string StartTime { get { throw null; } set { } } + public string TimeZone { get { throw null; } set { } } + protected override Azure.AI.Projects.Trigger JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.Trigger PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.RecurrenceTrigger System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.RecurrenceTrigger System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class RedTeam : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public RedTeam(Azure.AI.Projects.TargetConfig target) { } + public string ApplicationScenario { get { throw null; } set { } } + public System.Collections.Generic.IList AttackStrategies { get { throw null; } } + public string DisplayName { get { throw null; } set { } } + public string Name { get { throw null; } } + public int? NumTurns { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Properties { get { throw null; } } + public System.Collections.Generic.IList RiskCategories { get { throw null; } } + public bool? SimulationOnly { get { throw null; } set { } } + public string Status { get { throw null; } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + public Azure.AI.Projects.TargetConfig Target { get { throw null; } set { } } + protected virtual Azure.AI.Projects.RedTeam JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static explicit operator Azure.AI.Projects.RedTeam (System.ClientModel.ClientResult result) { throw null; } + public static implicit operator System.ClientModel.BinaryContent (Azure.AI.Projects.RedTeam redTeam) { throw null; } + protected virtual Azure.AI.Projects.RedTeam PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.RedTeam System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.RedTeam System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class RedTeams + { + protected RedTeams() { } + public System.ClientModel.Primitives.ClientPipeline Pipeline { get { throw null; } } + public virtual System.ClientModel.ClientResult Create(Azure.AI.Projects.RedTeam redTeam, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult Create(System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> CreateAsync(Azure.AI.Projects.RedTeam redTeam, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task CreateAsync(System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult Get(string name, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult Get(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.CollectionResult GetAll(System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.CollectionResult GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.AsyncCollectionResult GetAllAsync(System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GetAsync(string name, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct RiskCategory : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public RiskCategory(string value) { throw null; } + public static Azure.AI.Projects.RiskCategory CodeVulnerability { get { throw null; } } + public static Azure.AI.Projects.RiskCategory HateUnfairness { get { throw null; } } + public static Azure.AI.Projects.RiskCategory ProhibitedActions { get { throw null; } } + public static Azure.AI.Projects.RiskCategory ProtectedMaterial { get { throw null; } } + public static Azure.AI.Projects.RiskCategory SelfHarm { get { throw null; } } + public static Azure.AI.Projects.RiskCategory SensitiveDataLeakage { get { throw null; } } + public static Azure.AI.Projects.RiskCategory Sexual { get { throw null; } } + public static Azure.AI.Projects.RiskCategory TaskAdherence { get { throw null; } } + public static Azure.AI.Projects.RiskCategory UngroundedAttributes { get { throw null; } } + public static Azure.AI.Projects.RiskCategory Violence { get { throw null; } } + public bool Equals(Azure.AI.Projects.RiskCategory other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.RiskCategory left, Azure.AI.Projects.RiskCategory right) { throw null; } + public static implicit operator Azure.AI.Projects.RiskCategory (string value) { throw null; } + public static implicit operator Azure.AI.Projects.RiskCategory? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.RiskCategory left, Azure.AI.Projects.RiskCategory right) { throw null; } + public override string ToString() { throw null; } + } + public partial class Schedule : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public Schedule(bool enabled, Azure.AI.Projects.Trigger trigger, Azure.AI.Projects.ScheduleTask task) { } + public string Description { get { throw null; } set { } } + public string DisplayName { get { throw null; } set { } } + public bool Enabled { get { throw null; } set { } } + public string Id { get { throw null; } } + public System.Collections.Generic.IDictionary Properties { get { throw null; } } + public Azure.AI.Projects.ScheduleProvisioningStatus? ProvisioningStatus { get { throw null; } } + public System.Collections.Generic.IReadOnlyDictionary SystemData { get { throw null; } } + public System.Collections.Generic.IDictionary Tags { get { throw null; } } + public Azure.AI.Projects.ScheduleTask Task { get { throw null; } set { } } + public Azure.AI.Projects.Trigger Trigger { get { throw null; } set { } } + protected virtual Azure.AI.Projects.Schedule JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static explicit operator Azure.AI.Projects.Schedule (System.ClientModel.ClientResult result) { throw null; } + public static implicit operator System.ClientModel.BinaryContent (Azure.AI.Projects.Schedule schedule) { throw null; } + protected virtual Azure.AI.Projects.Schedule PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.Schedule System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.Schedule System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ScheduleProvisioningStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ScheduleProvisioningStatus(string value) { throw null; } + public static Azure.AI.Projects.ScheduleProvisioningStatus Creating { get { throw null; } } + public static Azure.AI.Projects.ScheduleProvisioningStatus Deleting { get { throw null; } } + public static Azure.AI.Projects.ScheduleProvisioningStatus Failed { get { throw null; } } + public static Azure.AI.Projects.ScheduleProvisioningStatus Succeeded { get { throw null; } } + public static Azure.AI.Projects.ScheduleProvisioningStatus Updating { get { throw null; } } + public bool Equals(Azure.AI.Projects.ScheduleProvisioningStatus other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.ScheduleProvisioningStatus left, Azure.AI.Projects.ScheduleProvisioningStatus right) { throw null; } + public static implicit operator Azure.AI.Projects.ScheduleProvisioningStatus (string value) { throw null; } + public static implicit operator Azure.AI.Projects.ScheduleProvisioningStatus? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.ScheduleProvisioningStatus left, Azure.AI.Projects.ScheduleProvisioningStatus right) { throw null; } + public override string ToString() { throw null; } + } + public partial class ScheduleRun : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ScheduleRun() { } + public string Error { get { throw null; } } + public System.Collections.Generic.IReadOnlyDictionary Properties { get { throw null; } } + public string RunId { get { throw null; } } + public string ScheduleId { get { throw null; } } + public bool Success { get { throw null; } } + public string TriggerTime { get { throw null; } } + protected virtual Azure.AI.Projects.ScheduleRun JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + public static explicit operator Azure.AI.Projects.ScheduleRun (System.ClientModel.ClientResult result) { throw null; } + protected virtual Azure.AI.Projects.ScheduleRun PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.ScheduleRun System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.ScheduleRun System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class Schedules + { + protected Schedules() { } + public System.ClientModel.Primitives.ClientPipeline Pipeline { get { throw null; } } + public virtual System.ClientModel.ClientResult CreateOrUpdate(string id, Azure.AI.Projects.Schedule schedule, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult CreateOrUpdate(string id, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.Threading.Tasks.Task> CreateOrUpdateAsync(string id, Azure.AI.Projects.Schedule schedule, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task CreateOrUpdateAsync(string id, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public virtual System.ClientModel.ClientResult Delete(string id, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult Delete(string id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(string id, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task DeleteAsync(string id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult Get(string id, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult Get(string id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.CollectionResult GetAll(System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.CollectionResult GetAll(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.AsyncCollectionResult GetAllAsync(System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetAllAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GetAsync(string id, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task> GetAsync(string id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.ClientResult GetRun(string scheduleId, string runId, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.ClientResult GetRun(string scheduleId, string runId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task GetRunAsync(string scheduleId, string runId, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.Threading.Tasks.Task> GetRunAsync(string scheduleId, string runId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.CollectionResult GetRuns(string id, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.CollectionResult GetRuns(string id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.ClientModel.Primitives.AsyncCollectionResult GetRunsAsync(string id, System.ClientModel.Primitives.RequestOptions options) { throw null; } + public virtual System.ClientModel.AsyncCollectionResult GetRunsAsync(string id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public abstract partial class ScheduleTask : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal ScheduleTask() { } + public System.Collections.Generic.IDictionary Configuration { get { throw null; } } + protected virtual Azure.AI.Projects.ScheduleTask JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.ScheduleTask PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.ScheduleTask System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.ScheduleTask System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public abstract partial class Target : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal Target() { } + protected virtual Azure.AI.Projects.Target JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.Target PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.Target System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.Target System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public abstract partial class TargetConfig : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal TargetConfig() { } + protected virtual Azure.AI.Projects.TargetConfig JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.TargetConfig PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.TargetConfig System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.TargetConfig System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class TaxonomyCategory : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TaxonomyCategory(string id, string name, Azure.AI.Projects.RiskCategory riskCategory, System.Collections.Generic.IEnumerable subCategories) { } + public string Description { get { throw null; } set { } } + public string Id { get { throw null; } set { } } + public string Name { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Properties { get { throw null; } } + public Azure.AI.Projects.RiskCategory RiskCategory { get { throw null; } set { } } + public System.Collections.Generic.IList SubCategories { get { throw null; } } + protected virtual Azure.AI.Projects.TaxonomyCategory JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.TaxonomyCategory PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.TaxonomyCategory System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.TaxonomyCategory System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class TaxonomySubCategory : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public TaxonomySubCategory(string id, string name, bool enabled) { } + public string Description { get { throw null; } set { } } + public bool Enabled { get { throw null; } set { } } + public string Id { get { throw null; } set { } } + public string Name { get { throw null; } set { } } + public System.Collections.Generic.IDictionary Properties { get { throw null; } } + protected virtual Azure.AI.Projects.TaxonomySubCategory JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.TaxonomySubCategory PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.TaxonomySubCategory System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.TaxonomySubCategory System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class ToolDescription : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public ToolDescription() { } + public string Description { get { throw null; } set { } } + public string Name { get { throw null; } set { } } + protected virtual Azure.AI.Projects.ToolDescription JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.ToolDescription PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.ToolDescription System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.ToolDescription System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct TreatmentEffectType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public TreatmentEffectType(string value) { throw null; } + public static Azure.AI.Projects.TreatmentEffectType Changed { get { throw null; } } + public static Azure.AI.Projects.TreatmentEffectType Degraded { get { throw null; } } + public static Azure.AI.Projects.TreatmentEffectType Improved { get { throw null; } } + public static Azure.AI.Projects.TreatmentEffectType Inconclusive { get { throw null; } } + public static Azure.AI.Projects.TreatmentEffectType TooFewSamples { get { throw null; } } + public bool Equals(Azure.AI.Projects.TreatmentEffectType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.AI.Projects.TreatmentEffectType left, Azure.AI.Projects.TreatmentEffectType right) { throw null; } + public static implicit operator Azure.AI.Projects.TreatmentEffectType (string value) { throw null; } + public static implicit operator Azure.AI.Projects.TreatmentEffectType? (string value) { throw null; } + public static bool operator !=(Azure.AI.Projects.TreatmentEffectType left, Azure.AI.Projects.TreatmentEffectType right) { throw null; } + public override string ToString() { throw null; } + } + public abstract partial class Trigger : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + internal Trigger() { } + protected virtual Azure.AI.Projects.Trigger JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.AI.Projects.Trigger PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.Trigger System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.Trigger System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class UserProfileMemoryItem : Azure.AI.Projects.MemoryItem, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public UserProfileMemoryItem(string memoryId, System.DateTimeOffset updatedAt, string scope, string content) { } + protected override Azure.AI.Projects.MemoryItem JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.MemoryItem PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.UserProfileMemoryItem System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.UserProfileMemoryItem System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } + public partial class WeeklyRecurrenceSchedule : Azure.AI.Projects.RecurrenceSchedule, System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel + { + public WeeklyRecurrenceSchedule(System.Collections.Generic.IEnumerable daysOfWeek) { } + public System.Collections.Generic.IList DaysOfWeek { get { throw null; } } + protected override Azure.AI.Projects.RecurrenceSchedule JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected override Azure.AI.Projects.RecurrenceSchedule PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected override System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + Azure.AI.Projects.WeeklyRecurrenceSchedule System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + Azure.AI.Projects.WeeklyRecurrenceSchedule System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + } +} +namespace Azure.Core.Foundations +{ + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct OperationStatus : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public OperationStatus(string value) { throw null; } + public static Azure.Core.Foundations.OperationStatus Canceled { get { throw null; } } + public static Azure.Core.Foundations.OperationStatus Failed { get { throw null; } } + public static Azure.Core.Foundations.OperationStatus NotStarted { get { throw null; } } + public static Azure.Core.Foundations.OperationStatus Running { get { throw null; } } + public static Azure.Core.Foundations.OperationStatus Succeeded { get { throw null; } } + public bool Equals(Azure.Core.Foundations.OperationStatus other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.Core.Foundations.OperationStatus left, Azure.Core.Foundations.OperationStatus right) { throw null; } + public static implicit operator Azure.Core.Foundations.OperationStatus (string value) { throw null; } + public static implicit operator Azure.Core.Foundations.OperationStatus? (string value) { throw null; } + public static bool operator !=(Azure.Core.Foundations.OperationStatus left, Azure.Core.Foundations.OperationStatus right) { throw null; } + public override string ToString() { throw null; } + } } diff --git a/sdk/ai/Azure.AI.Projects/assets.json b/sdk/ai/Azure.AI.Projects/assets.json index 34a5c7594ddc..1f711348f6b8 100644 --- a/sdk/ai/Azure.AI.Projects/assets.json +++ b/sdk/ai/Azure.AI.Projects/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "net/ai/Azure.AI.Projects", - "Tag": "net/ai/Azure.AI.Projects_c11aeaf283" + "Tag": "net/ai/Azure.AI.Projects_c6e86e3eb6" } diff --git a/sdk/ai/Azure.AI.Projects/samples/Sample15_Files.md b/sdk/ai/Azure.AI.Projects/samples/Sample15_Files.md new file mode 100644 index 000000000000..690d77d331ed --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/samples/Sample15_Files.md @@ -0,0 +1,46 @@ +# Sample using Files in Azure.AI.Projects + +This sample demonstrates how to use file operations with OpenAI Files API through the Azure AI Projects SDK. The file operations are accessed via the AgentsClient's GetOpenAIClient() method. + +## Prerequisites + +- Install the Azure.AI.Projects package. +- Install the Azure.AI.Agents package. +- Set the following environment variables: + - `PROJECT_ENDPOINT`: The Azure AI Project endpoint, as found in the overview page of your Azure AI Foundry project. + +## Asynchronous Sample + +```C# Snippet:AI_Projects_FileOperationsAsync +var endpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); +AIProjectClient projectClient = new(new Uri(endpoint), new DefaultAzureCredential()); +ProjectFilesClient fileClient = projectClient.OpenAI.Files; + +// Upload file +var dataDirectory = GetDataDirectory(); +var testFilePath = Path.Combine(dataDirectory, "training_set.jsonl"); +OpenAIFile uploadedFile = await fileClient.UploadFileAsync( + testFilePath, + FileUploadPurpose.FineTune); + +string fileId = uploadedFile.Id; + +// Retrieve file metadata +OpenAIFile retrievedFile = await fileClient.GetFileAsync(fileId); +Console.WriteLine($"File ID: {retrievedFile.Id}, Filename: {retrievedFile.Filename}"); + +// Download file content +BinaryData fileContent = await fileClient.DownloadFileAsync(fileId); +Console.WriteLine($"Content size: {fileContent.ToMemory().Length} bytes"); + +// List all files +ClientResult filesResult = await fileClient.GetFilesAsync(); +foreach (OpenAIFile file in filesResult.Value) +{ + Console.WriteLine($"File: {file.Filename} (ID: {file.Id})"); +} + +// Delete file +ClientResult deleteResult = await fileClient.DeleteFileAsync(fileId); +Console.WriteLine($"File deleted: {deleteResult.Value.Deleted}"); +``` diff --git a/sdk/ai/Azure.AI.Projects/samples/Sample16_Agents_CRUD.md b/sdk/ai/Azure.AI.Projects/samples/Sample16_Agents_CRUD.md new file mode 100644 index 000000000000..14ccc0fb1123 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/samples/Sample16_Agents_CRUD.md @@ -0,0 +1,95 @@ +# Sample for Agent Administration (creation, retrieval, update, deletion) in Azure.AI.Projects + +In this example we will demonstrate creation and basic use of an agent step by step. + +1. First, we need to create agent client and read the environment variables, which will be used in the next steps. + +```C# Snippet:Sample_CreateAgentClientCRUD +var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); +var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); +``` + +2. Use the client to create two versioned agent objects. + +Synchronous sample: +```C# Snippet:Sample_CreateAgentVersionCRUD_Sync +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a prompt agent." +}; +AgentVersion agentVersion1 = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent1", + options: new(agentDefinition)); +Console.WriteLine($"Agent created (id: {agentVersion1.Id}, name: {agentVersion1.Name}, version: {agentVersion1.Version})"); +AgentVersion agentVersion2 = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent2", + options: new(agentDefinition)); +Console.WriteLine($"Agent created (id: {agentVersion2.Id}, name: {agentVersion2.Name}, version: {agentVersion2.Version})"); +``` + +Asynchronous sample: +```C# Snippet:Sample_CreateAgentVersionCRUD_Async +PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) +{ + Instructions = "You are a prompt agent." +}; +AgentVersion agentVersion1 = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent1", + options: new(agentDefinition)); +Console.WriteLine($"Agent created (id: {agentVersion1.Id}, name: {agentVersion1.Name}, version: {agentVersion1.Version})"); +AgentVersion agentVersion2 = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent2", + options: new(agentDefinition)); +Console.WriteLine($"Agent created (id: {agentVersion2.Id}, name: {agentVersion2.Name}, version: {agentVersion2.Version})"); +``` + +3. Retrieve the agent object and list its labels. + +Synchronous sample: +```C# Snippet:Sample_GetAgentCRUD_Sync +AgentRecord result = projectClient.Agents.GetAgent(agentVersion1.Name); +Console.WriteLine($"Agent created (id: {result.Id}, name: {result.Name})"); +``` + +Asynchronous sample: +```C# Snippet:Sample_GetAgentCRUD_Async +AgentRecord result = await projectClient.Agents.GetAgentAsync(agentVersion1.Name); +Console.WriteLine($"Agent created (id: {result.Id}, name: {result.Name})"); +``` + +4. List all agents. + +Synchronous sample: +```C# Snippet:Sample_ListAgentsCRUD_Sync +foreach (AgentRecord agent in projectClient.Agents.GetAgents()) +{ + Console.WriteLine($"Listed Agent: id: {agent.Id}, name: {agent.Name}"); +} +``` + +Asynchronous sample: +```C# Snippet:Sample_ListAgentsCRUD_Async +await foreach (AgentRecord agent in projectClient.Agents.GetAgentsAsync()) +{ + Console.WriteLine($"Listed Agent: id: {agent.Id}, name: {agent.Name}"); +} +``` + +5. Finally, remove the agents we have created. + +Synchronous sample: +```C# Snippet:Sample_DeleteAgentCRUD_Sync +projectClient.Agents.DeleteAgentVersion(agentName: agentVersion1.Name, agentVersion: agentVersion1.Version); +Console.WriteLine($"Agent deleted (name: {agentVersion1.Name}, version: {agentVersion1.Version})"); +projectClient.Agents.DeleteAgentVersion(agentName: agentVersion2.Name, agentVersion: agentVersion2.Version); +Console.WriteLine($"Agent deleted (name: {agentVersion2.Name}, version: {agentVersion2.Version})"); +``` + +Asynchronous sample: +```C# Snippet:Sample_DeleteAgentCRUD_Async +await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion1.Name, agentVersion: agentVersion1.Version); +Console.WriteLine($"Agent deleted (name: {agentVersion1.Name}, version: {agentVersion1.Version})"); +await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion2.Name, agentVersion: agentVersion2.Version); +Console.WriteLine($"Agent deleted (name: {agentVersion2.Name}, version: {agentVersion2.Version})"); +``` diff --git a/sdk/ai/Azure.AI.Projects/samples/Sample6_Agents.md b/sdk/ai/Azure.AI.Projects/samples/Sample6_ClassicAgents.md similarity index 99% rename from sdk/ai/Azure.AI.Projects/samples/Sample6_Agents.md rename to sdk/ai/Azure.AI.Projects/samples/Sample6_ClassicAgents.md index 8fca3d9ede80..472cd36aa393 100644 --- a/sdk/ai/Azure.AI.Projects/samples/Sample6_Agents.md +++ b/sdk/ai/Azure.AI.Projects/samples/Sample6_ClassicAgents.md @@ -54,7 +54,7 @@ ThreadRun run = await agentsClient.Runs.CreateRunAsync( additionalInstructions: "Please address the user as Jane Doe. The user has a premium account."); ``` -6 . Whait while run complete. +6. Wait for the run to complete. ```C# Snippet:AI_Projects_ExtensionsAgentsOverviewWaitForRun do diff --git a/sdk/ai/Azure.AI.Projects/src/Azure.AI.Projects.csproj b/sdk/ai/Azure.AI.Projects/src/Azure.AI.Projects.csproj index 909a0f5a7867..32f40f3f38b6 100644 --- a/sdk/ai/Azure.AI.Projects/src/Azure.AI.Projects.csproj +++ b/sdk/ai/Azure.AI.Projects/src/Azure.AI.Projects.csproj @@ -2,32 +2,32 @@ This is the Azure.AI.Projects client library for developing .NET applications with rich experience. Microsoft Azure.AI.Projects client library - 1.2.0-beta.1 + 1.2.0-beta.4 1.1.0 Azure.AI.Projects true $(RequiredTargetFrameworks) true - latest true + + + preview + true + + - $(NoWarn); - CS1591; - AZC0012; - SA1649; - SA1402; + $(NoWarn) + + ;OPENAI001 + + ;CS1591 + + ;AZC0012 - - $(NoWarn);OPENAI001; @@ -35,7 +35,7 @@ - + @@ -46,8 +46,4 @@ - - - - diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/AIProjectClient.cs b/sdk/ai/Azure.AI.Projects/src/Custom/AIProjectClient.cs index 6b907caa3054..f119b7c87d2a 100644 --- a/sdk/ai/Azure.AI.Projects/src/Custom/AIProjectClient.cs +++ b/sdk/ai/Azure.AI.Projects/src/Custom/AIProjectClient.cs @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +global using System.ClientModel; +global using System.ClientModel.Primitives; +global using System.ComponentModel; using System; -using System.ClientModel; -using System.ClientModel.Primitives; using System.Collections.Generic; -using System.ComponentModel; using System.Threading; -using Azure.Core; +using Azure.AI.Projects.OpenAI; #pragma warning disable AZC0007 @@ -20,24 +20,15 @@ public partial class AIProjectClient : ClientConnectionProvider private const int _defaultMaxCacheSize = 100; private readonly ClientConnectionCacheManager _cacheManager; private static readonly string[] AuthorizationScopes = ["https://ai.azure.com/.default"]; + private ProjectOpenAIClient _cachedOpenAIClient; + private readonly TelemetryDetails _telemetryDetails; /// Initializes a new instance of AIProjectClient for mocking. - protected AIProjectClient() : base(maxCacheSize: _defaultMaxCacheSize) + protected AIProjectClient() + : base(maxCacheSize: _defaultMaxCacheSize) { } - /// Initializes a new instance of AIProjectClient. - /// Service endpoint. - /// The options for configuring the client. - internal AIProjectClient(Uri endpoint, AIProjectClientOptions options) : base(_defaultMaxCacheSize) - { - options ??= new AIProjectClientOptions(); - - _endpoint = endpoint; - Pipeline = ClientPipeline.Create(options, Array.Empty(), Array.Empty(), Array.Empty()); - _apiVersion = options.Version; - } - /// Initializes a new instance of AIProjectClient. /// Service endpoint. /// A credential provider used to authenticate to the service. @@ -59,12 +50,21 @@ public AIProjectClient(Uri endpoint, AuthenticationTokenProvider tokenProvider, options ??= new AIProjectClientOptions(); + _apiVersion = options.Version; _endpoint = endpoint; _tokenProvider = tokenProvider; + _telemetryDetails = new(typeof(AIProjectAgentsOperations).Assembly, options?.UserAgentApplicationId); + + PipelinePolicyHelpers.AddQueryParameterPolicy(options, "api-version", _apiVersion); + PipelinePolicyHelpers.AddRequestHeaderPolicy(options, "User-Agent", _telemetryDetails.UserAgent.ToString()); + PipelinePolicyHelpers.AddRequestHeaderPolicy(options, "x-ms-client-request-id", () => Guid.NewGuid().ToString().ToLowerInvariant()); + PipelinePolicyHelpers.OpenAI.AddResponseItemInputTransformPolicy(options); + PipelinePolicyHelpers.OpenAI.AddErrorTransformPolicy(options); + PipelinePolicyHelpers.OpenAI.AddAzureFinetuningParityPolicy(options); + Pipeline = ClientPipeline.Create(options, Array.Empty(), new PipelinePolicy[] { new BearerTokenPolicy(_tokenProvider, _flows) }, Array.Empty()); - _apiVersion = options.Version; - _cacheManager = new ClientConnectionCacheManager(_endpoint, tokenProvider); + _cacheManager = new ClientConnectionCacheManager(_endpoint, Pipeline, tokenProvider); } /// @@ -80,30 +80,83 @@ public AIProjectClient(Uri endpoint, AuthenticationTokenProvider tokenProvider, public override IEnumerable GetAllConnections() => _cacheManager.GetAllConnections(); /// Initializes a new instance of AIProjectConnectionsOperations. - internal AIProjectConnectionsOperations GetAIProjectConnectionsOperationsClient() + internal virtual AIProjectConnectionsOperations GetAIProjectConnectionsOperationsClient() { return Volatile.Read(ref _cachedAIProjectConnectionsOperations) ?? Interlocked.CompareExchange(ref _cachedAIProjectConnectionsOperations, new AIProjectConnectionsOperations(Pipeline, _endpoint, _apiVersion), null) ?? _cachedAIProjectConnectionsOperations; } /// Initializes a new instance of AIProjectIndexesOperations. - internal AIProjectIndexesOperations GetAIProjectIndexesOperationsClient() + internal virtual AIProjectIndexesOperations GetAIProjectIndexesOperationsClient() { return Volatile.Read(ref _cachedAIProjectIndexesOperations) ?? Interlocked.CompareExchange(ref _cachedAIProjectIndexesOperations, new AIProjectIndexesOperations(Pipeline, _endpoint, _apiVersion), null) ?? _cachedAIProjectIndexesOperations; } /// Initializes a new instance of AIProjectDeploymentsOperations. - internal AIProjectDeploymentsOperations GetAIProjectDeploymentsOperationsClient() + internal virtual AIProjectDeploymentsOperations GetAIProjectDeploymentsOperationsClient() { return Volatile.Read(ref _cachedAIProjectDeploymentsOperations) ?? Interlocked.CompareExchange(ref _cachedAIProjectDeploymentsOperations, new AIProjectDeploymentsOperations(Pipeline, _endpoint, _apiVersion), null) ?? _cachedAIProjectDeploymentsOperations; } /// Initializes a new instance of AIProjectDatasetsOperations. - internal AIProjectDatasetsOperations GetAIProjectDatasetsOperationsClient() + internal virtual AIProjectDatasetsOperations GetAIProjectDatasetsOperationsClient() { // Custom method to allow for passing of credential used when SAS is not provided. return Volatile.Read(ref _cachedAIProjectDatasetsOperations) ?? Interlocked.CompareExchange(ref _cachedAIProjectDatasetsOperations, new AIProjectDatasetsOperations(Pipeline, _endpoint, _apiVersion, _tokenProvider), null) ?? _cachedAIProjectDatasetsOperations; } + internal virtual ProjectOpenAIClient GetCachedOpenAIClient() + { + return Volatile.Read(ref _cachedOpenAIClient) ?? Interlocked.CompareExchange(ref _cachedOpenAIClient, this.GetProjectOpenAIClient(), null) ?? _cachedOpenAIClient; + } + + /// Initializes a new instance of RedTeams. + internal virtual RedTeams GetRedTeamsClient() + { + return Volatile.Read(ref _cachedRedTeams) ?? Interlocked.CompareExchange(ref _cachedRedTeams, new RedTeams(Pipeline, _endpoint, _apiVersion), null) ?? _cachedRedTeams; + } + + /// Initializes a new instance of EvaluationRules. + internal virtual EvaluationRules GetEvaluationRulesClient() + { + return Volatile.Read(ref _cachedEvaluationRules) ?? Interlocked.CompareExchange(ref _cachedEvaluationRules, new EvaluationRules(Pipeline, _endpoint, _apiVersion), null) ?? _cachedEvaluationRules; + } + + /// Initializes a new instance of EvaluationTaxonomies. + internal virtual EvaluationTaxonomies GetEvaluationTaxonomiesClient() + { + return Volatile.Read(ref _cachedEvaluationTaxonomies) ?? Interlocked.CompareExchange(ref _cachedEvaluationTaxonomies, new EvaluationTaxonomies(Pipeline, _endpoint, _apiVersion), null) ?? _cachedEvaluationTaxonomies; + } + + /// Initializes a new instance of Evaluators. + internal virtual Evaluators GetEvaluatorsClient() + { + return Volatile.Read(ref _cachedEvaluators) ?? Interlocked.CompareExchange(ref _cachedEvaluators, new Evaluators(Pipeline, _endpoint, _apiVersion), null) ?? _cachedEvaluators; + } + + /// Initializes a new instance of Insights. + internal virtual Insights GetInsightsClient() + { + return Volatile.Read(ref _cachedInsights) ?? Interlocked.CompareExchange(ref _cachedInsights, new Insights(Pipeline, _endpoint, _apiVersion), null) ?? _cachedInsights; + } + + /// Initializes a new instance of Schedules. + internal virtual Schedules GetSchedulesClient() + { + return Volatile.Read(ref _cachedSchedules) ?? Interlocked.CompareExchange(ref _cachedSchedules, new Schedules(Pipeline, _endpoint, _apiVersion), null) ?? _cachedSchedules; + } + + /// Initializes a new instance of AIProjectAgentsOperations. + internal virtual AIProjectAgentsOperations GetAIProjectAgentsOperationsClient() + { + return Volatile.Read(ref _cachedAIProjectAgentsOperations) ?? Interlocked.CompareExchange(ref _cachedAIProjectAgentsOperations, new AIProjectAgentsOperations(Pipeline, _endpoint, _apiVersion), null) ?? _cachedAIProjectAgentsOperations; + } + + /// Initializes a new instance of AIProjectMemoryStoresOperations. + internal virtual AIProjectMemoryStoresOperations GetAIProjectMemoryStoresOperationsClient() + { + return Volatile.Read(ref _cachedAIProjectMemoryStoresOperations) ?? Interlocked.CompareExchange(ref _cachedAIProjectMemoryStoresOperations, new AIProjectMemoryStoresOperations(Pipeline, _endpoint, _apiVersion), null) ?? _cachedAIProjectMemoryStoresOperations; + } + /// Gets the client for managing connections. public virtual AIProjectConnectionsOperations Connections { get => GetAIProjectConnectionsOperationsClient(); } /// Gets the client for managing datasets. @@ -112,35 +165,18 @@ internal AIProjectDatasetsOperations GetAIProjectDatasetsOperationsClient() public virtual AIProjectDeploymentsOperations Deployments { get => GetAIProjectDeploymentsOperationsClient(); } /// Gets the client for managing indexes. public virtual AIProjectIndexesOperations Indexes { get => GetAIProjectIndexesOperationsClient(); } + public virtual ProjectOpenAIClient OpenAI => GetCachedOpenAIClient(); + public virtual AIProjectAgentsOperations Agents => GetAIProjectAgentsOperationsClient(); + public virtual AIProjectMemoryStoresOperations MemoryStores => GetAIProjectMemoryStoresOperationsClient(); + public virtual RedTeams RedTeams => GetRedTeamsClient(); + public virtual EvaluationRules EvaluationRules => GetEvaluationRulesClient(); + public virtual EvaluationTaxonomies EvaluationTaxonomies => GetEvaluationTaxonomiesClient(); + public virtual Evaluators Evaluators => GetEvaluatorsClient(); + public virtual Insights Insights => GetInsightsClient(); + public virtual Schedules Schedules => GetSchedulesClient(); /// Gets the client for telemetry operations. public virtual AIProjectTelemetry Telemetry { get => new AIProjectTelemetry(this); } - private static ClientPipeline CreatePipeline(PipelinePolicy authenticationPolicy, AIProjectClientOptions options) - => ClientPipeline.Create( - options ?? new(), - perCallPolicies: - [ - // CreateAddUserAgentHeaderPolicy(options), - // CreateAddClientRequestIdHeaderPolicy(), - ], - perTryPolicies: - [ - authenticationPolicy, - ], - beforeTransportPolicies: []); - - internal static ClientPipeline CreatePipeline(ApiKeyCredential credential, AIProjectClientOptions options = null) - { - Argument.AssertNotNull(credential, nameof(credential)); - return CreatePipeline(ApiKeyAuthenticationPolicy.CreateHeaderApiKeyPolicy(credential, "api-key"), options); - } - - internal static ClientPipeline CreatePipeline(TokenCredential credential, AIProjectClientOptions options = null) - { - Argument.AssertNotNull(credential, nameof(credential)); - return CreatePipeline(new AzureTokenAuthenticationPolicy(credential, AuthorizationScopes), options); - } - private static PipelineMessageClassifier s_pipelineMessageClassifier; internal static PipelineMessageClassifier PipelineMessageClassifier => s_pipelineMessageClassifier ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200, 201 }); diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/AIProjectClientOptions.cs b/sdk/ai/Azure.AI.Projects/src/Custom/AIProjectClientOptions.cs index 88f9f10b91f7..85765c840875 100644 --- a/sdk/ai/Azure.AI.Projects/src/Custom/AIProjectClientOptions.cs +++ b/sdk/ai/Azure.AI.Projects/src/Custom/AIProjectClientOptions.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System.ClientModel.Primitives; - namespace Azure.AI.Projects { /// Client options for AIProjectClient. @@ -10,5 +8,19 @@ public partial class AIProjectClientOptions : ClientPipelineOptions { /// The size of the client cache. internal int ClientCacheSize { get; set; } = 100; + + private string _userAgentApplicationId; + /// + /// An optional application ID to use as part of the request User-Agent header. + /// + public string UserAgentApplicationId + { + get => _userAgentApplicationId; + set + { + AssertNotFrozen(); + _userAgentApplicationId = value; + } + } } } diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/AIProjectConnectionsOperations.cs b/sdk/ai/Azure.AI.Projects/src/Custom/AIProjectConnectionsOperations.cs index d7f5aebb4298..73a47663a9e8 100644 --- a/sdk/ai/Azure.AI.Projects/src/Custom/AIProjectConnectionsOperations.cs +++ b/sdk/ai/Azure.AI.Projects/src/Custom/AIProjectConnectionsOperations.cs @@ -2,8 +2,6 @@ // Licensed under the MIT License. using System; -using System.ClientModel; -using System.ClientModel.Primitives; using System.ComponentModel; using System.Threading; diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/AIProjectDeploymentsOperations.cs b/sdk/ai/Azure.AI.Projects/src/Custom/AIProjectDeploymentsOperations.cs index 0268f97944dc..e5e6115f2958 100644 --- a/sdk/ai/Azure.AI.Projects/src/Custom/AIProjectDeploymentsOperations.cs +++ b/sdk/ai/Azure.AI.Projects/src/Custom/AIProjectDeploymentsOperations.cs @@ -2,8 +2,6 @@ // Licensed under the MIT License. using System; -using System.ClientModel; -using System.ClientModel.Primitives; using System.ComponentModel; using System.Threading; using System.Threading.Tasks; diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/Agents/AIProjectAgentsOperations.RestClient.cs b/sdk/ai/Azure.AI.Projects/src/Custom/Agents/AIProjectAgentsOperations.RestClient.cs new file mode 100644 index 000000000000..6cf792eb5dd5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Custom/Agents/AIProjectAgentsOperations.RestClient.cs @@ -0,0 +1,665 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure.AI.Projects.OpenAI; +using Azure.AI.Projects.Telemetry; + +namespace Azure.AI.Projects; + +public partial class AIProjectAgentsOperations +{ + /// + /// [Protocol Method] Creates the agent. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual ClientResult CreateAgent(BinaryContent content, RequestOptions options = null) + { + using var otelScope = OpenTelemetryScope.StartCreateAgent(_endpoint, content, options); + Argument.AssertNotNull(content, nameof(content)); + + try + { + using PipelineMessage message = CreateCreateAgentRequest(content, options); + var result = ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + otelScope?.RecordCreateAgentResponse(result); + return result; + } + catch (Exception ex) + { + otelScope?.RecordError(ex); + throw; + } + } + + /// + /// [Protocol Method] Creates the agent. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual async Task CreateAgentAsync(BinaryContent content, RequestOptions options = null) + { + using var otelScope = OpenTelemetryScope.StartCreateAgent(_endpoint, content, options); + Argument.AssertNotNull(content, nameof(content)); + + try + { + using PipelineMessage message = CreateCreateAgentRequest(content, options); + var result = ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + otelScope?.RecordCreateAgentResponse(result); + return result; + } + catch (Exception ex) + { + otelScope?.RecordError(ex); + throw; + } + } + + /// + /// [Protocol Method] Create a new agent version. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the agent to create/modify. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual ClientResult CreateAgentVersion(string agentName, BinaryContent content, RequestOptions options = null) + { + using var otelScope = OpenTelemetryScope.StartCreateAgentVersion(_endpoint, agentName, content, options); + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + Argument.AssertNotNull(content, nameof(content)); + + try + { + using PipelineMessage message = CreateCreateAgentVersionRequest(agentName, content, options); + var result = ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + otelScope?.RecordCreateAgentVersionResponse(result); + return result; + } + catch (Exception ex) + { + otelScope?.RecordError(ex); + throw; + } + } + + /// + /// [Protocol Method] Create a new agent version. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the agent to create/modify. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual async Task CreateAgentVersionAsync(string agentName, BinaryContent content, RequestOptions options = null) + { + using var otelScope = OpenTelemetryScope.StartCreateAgentVersion(_endpoint, agentName, content, options); + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + Argument.AssertNotNull(content, nameof(content)); + + try + { + using PipelineMessage message = CreateCreateAgentVersionRequest(agentName, content, options); + var result = ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + otelScope?.RecordCreateAgentVersionResponse(result); + return result; + } + catch (Exception ex) + { + otelScope?.RecordError(ex); + throw; + } + } + + /// + /// [Protocol Method] Create a new agent version from a manifest. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the agent to create a version for. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual ClientResult CreateAgentVersionFromManifest(string agentName, BinaryContent content, RequestOptions options = null) + { + using var otelScope = OpenTelemetryScope.StartCreateAgentVersion(_endpoint, agentName, content, options); + + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + Argument.AssertNotNull(content, nameof(content)); + + try + { + using PipelineMessage message = CreateCreateAgentVersionFromManifestRequest(agentName, content, options); + var result = ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + otelScope?.RecordCreateAgentVersionResponse(result); + return result; + } + catch (Exception ex) + { + otelScope?.RecordError(ex); + throw; + } + } + + /// + /// [Protocol Method] Create a new agent version from a manifest. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the agent to create a version for. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual async Task CreateAgentVersionFromManifestAsync(string agentName, BinaryContent content, RequestOptions options = null) + { + using var otelScope = OpenTelemetryScope.StartCreateAgentVersion(_endpoint, agentName, content, options); + + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + Argument.AssertNotNull(content, nameof(content)); + + try + { + using PipelineMessage message = CreateCreateAgentVersionFromManifestRequest(agentName, content, options); + var result = ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + otelScope?.RecordCreateAgentVersionResponse(result); + return result; + } + catch (Exception ex) + { + otelScope?.RecordError(ex); + throw; + } + } + + /// + /// [Protocol Method] Creates an agent from a manifest. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual ClientResult CreateAgentFromManifest(BinaryContent content, RequestOptions options = null) + { + using var otelScope = OpenTelemetryScope.StartCreateAgent(_endpoint, content, options); + + Argument.AssertNotNull(content, nameof(content)); + + try + { + using PipelineMessage message = CreateCreateAgentFromManifestRequest(content, options); + var result = ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + otelScope?.RecordCreateAgentResponse(result); + return result; + } + catch (Exception ex) + { + otelScope?.RecordError(ex); + throw; + } + } + + /// + /// [Protocol Method] Creates an agent from a manifest. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual async Task CreateAgentFromManifestAsync(BinaryContent content, RequestOptions options = null) + { + using var otelScope = OpenTelemetryScope.StartCreateAgent(_endpoint, content, options); + + Argument.AssertNotNull(content, nameof(content)); + + try + { + using PipelineMessage message = CreateCreateAgentFromManifestRequest(content, options); + var result = ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + otelScope?.RecordCreateAgentResponse(result); + return result; + } + catch (Exception ex) + { + otelScope?.RecordError(ex); + throw; + } + } + + /// Retrieves a specific version of an agent. + /// The name of the agent to retrieve. + /// The version of the agent to retrieve. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult GetAgentVersion(string agentName, string agentVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + Argument.AssertNotNullOrEmpty(agentVersion, nameof(agentVersion)); + + ClientResult result = GetAgentVersion(agentName, agentVersion, cancellationToken.ToRequestOptions()); + return result.ToProjectOpenAIResult(); + } + + /// Retrieves a specific version of an agent. + /// The name of the agent to retrieve. + /// The version of the agent to retrieve. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> GetAgentVersionAsync(string agentName, string agentVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + Argument.AssertNotNullOrEmpty(agentVersion, nameof(agentVersion)); + + ClientResult result = await GetAgentVersionAsync(agentName, agentVersion, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return result.ToProjectOpenAIResult(); + } + + /// + /// [Protocol Method] Updates the agent by adding a new version if there are any changes to the agent definition. + /// If no changes, returns the existing agent version. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the agent to retrieve. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual ClientResult UpdateAgent(string agentName, BinaryContent content, RequestOptions options = null) + { + using var otelScope = OpenTelemetryScope.StartUpdateAgent(_endpoint, agentName, content, options); + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + Argument.AssertNotNull(content, nameof(content)); + + try + { + using PipelineMessage message = CreateUpdateAgentRequest(agentName, content, options); + var result = ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + otelScope?.RecordUpdateAgentResponse(result); + return result; + } + catch (Exception ex) + { + otelScope?.RecordError(ex); + throw; + } + } + + /// + /// [Protocol Method] Updates the agent by adding a new version if there are any changes to the agent definition. + /// If no changes, returns the existing agent version. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the agent to retrieve. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual async Task UpdateAgentAsync(string agentName, BinaryContent content, RequestOptions options = null) + { + using var otelScope = OpenTelemetryScope.StartUpdateAgent(_endpoint, agentName, content, options); + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + Argument.AssertNotNull(content, nameof(content)); + + try + { + using PipelineMessage message = CreateUpdateAgentRequest(agentName, content, options); + var result = ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + otelScope?.RecordUpdateAgentResponse(result); + return result; + } + catch (Exception ex) + { + otelScope?.RecordError(ex); + throw; + } + } + + /// + /// [Protocol Method] Updates the agent from a manifest by adding a new version if there are any changes to the agent definition. + /// If no changes, returns the existing agent version. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the agent to update. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual ClientResult UpdateAgentFromManifest(string agentName, BinaryContent content, RequestOptions options = null) + { + using var otelScope = OpenTelemetryScope.StartUpdateAgent(_endpoint, agentName, content, options); + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + Argument.AssertNotNull(content, nameof(content)); + + try + { + using PipelineMessage message = CreateUpdateAgentFromManifestRequest(agentName, content, options); + var result = ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + otelScope?.RecordUpdateAgentResponse(result); + return result; + } + catch (Exception ex) + { + otelScope?.RecordError(ex); + throw; + } + } + + /// + /// [Protocol Method] Updates the agent from a manifest by adding a new version if there are any changes to the agent definition. + /// If no changes, returns the existing agent version. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the agent to update. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual async Task UpdateAgentFromManifestAsync(string agentName, BinaryContent content, RequestOptions options = null) + { + using var otelScope = OpenTelemetryScope.StartUpdateAgent(_endpoint, agentName, content, options); + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + Argument.AssertNotNull(content, nameof(content)); + + try + { + using PipelineMessage message = CreateUpdateAgentFromManifestRequest(agentName, content, options); + var result = ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + otelScope?.RecordUpdateAgentResponse(result); + return result; + } + catch (Exception ex) + { + otelScope?.RecordError(ex); + throw; + } + } + + /// + /// [Protocol Method] Retrieves the agent. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the agent to retrieve. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual ClientResult GetAgent(string agentName, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + + using PipelineMessage message = CreateGetAgentRequest(agentName, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Retrieves the agent. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the agent to retrieve. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual async Task GetAgentAsync(string agentName, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + + using PipelineMessage message = CreateGetAgentRequest(agentName, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// + /// [Protocol Method] Deletes an agent. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the agent to delete. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual ClientResult DeleteAgent(string agentName, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + + using PipelineMessage message = CreateDeleteAgentRequest(agentName, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Deletes an agent. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the agent to delete. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual async Task DeleteAgentAsync(string agentName, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + + using PipelineMessage message = CreateDeleteAgentRequest(agentName, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// + /// [Protocol Method] Retrieves a specific version of an agent. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the agent to retrieve. + /// The version of the agent to retrieve. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual ClientResult GetAgentVersion(string agentName, string agentVersion, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + Argument.AssertNotNullOrEmpty(agentVersion, nameof(agentVersion)); + + using PipelineMessage message = CreateGetAgentVersionRequest(agentName, agentVersion, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Retrieves a specific version of an agent. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the agent to retrieve. + /// The version of the agent to retrieve. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual async Task GetAgentVersionAsync(string agentName, string agentVersion, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + Argument.AssertNotNullOrEmpty(agentVersion, nameof(agentVersion)); + + using PipelineMessage message = CreateGetAgentVersionRequest(agentName, agentVersion, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// + /// [Protocol Method] Deletes a specific version of an agent. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the agent to delete. + /// The version of the agent to delete. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual ClientResult DeleteAgentVersion(string agentName, string agentVersion, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + Argument.AssertNotNullOrEmpty(agentVersion, nameof(agentVersion)); + + using PipelineMessage message = CreateDeleteAgentVersionRequest(agentName, agentVersion, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Deletes a specific version of an agent. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the agent to delete. + /// The version of the agent to delete. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual async Task DeleteAgentVersionAsync(string agentName, string agentVersion, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + Argument.AssertNotNullOrEmpty(agentVersion, nameof(agentVersion)); + + using PipelineMessage message = CreateDeleteAgentVersionRequest(agentName, agentVersion, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/Agents/AIProjectAgentsOperations.cs b/sdk/ai/Azure.AI.Projects/src/Custom/Agents/AIProjectAgentsOperations.cs new file mode 100644 index 000000000000..3de8a6c0fd03 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Custom/Agents/AIProjectAgentsOperations.cs @@ -0,0 +1,349 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Azure.AI.Projects; +using Azure.AI.Projects.OpenAI; +using Azure.Core; +using OpenAI; + +namespace Azure.AI.Projects; + +[CodeGenType("AIProjectAgentsOperations")] +[CodeGenSuppress("CreateAgent", typeof(string), typeof(InternalAgentDefinition), typeof(IDictionary), typeof(string), typeof(CancellationToken))] +[CodeGenSuppress("CreateAgentAsync", typeof(string), typeof(InternalAgentDefinition), typeof(IDictionary), typeof(string), typeof(CancellationToken))] +[CodeGenSuppress("CreateAgentFromManifest", typeof(string), typeof(string), typeof(IDictionary), typeof(IDictionary), typeof(string), typeof(CancellationToken))] +[CodeGenSuppress("CreateAgentFromManifestAsync", typeof(string), typeof(string), typeof(IDictionary), typeof(IDictionary), typeof(string), typeof(CancellationToken))] +[CodeGenSuppress("CreateAgentVersionFromManifest", typeof(string), typeof(string), typeof(IDictionary), typeof(IDictionary), typeof(string), typeof(CancellationToken))] +[CodeGenSuppress("CreateAgentVersionFromManifestAsync", typeof(string), typeof(string), typeof(IDictionary), typeof(IDictionary), typeof(string), typeof(CancellationToken))] +[CodeGenSuppress("GetAgents", typeof(string), typeof(int?), typeof(string), typeof(string), typeof(string), typeof(RequestOptions))] +[CodeGenSuppress("GetAgentsAsync", typeof(string), typeof(int?), typeof(string), typeof(string), typeof(string), typeof(RequestOptions))] +[CodeGenSuppress("GetAgentVersions", typeof(string), typeof(int?), typeof(string), typeof(string), typeof(string), typeof(RequestOptions))] +[CodeGenSuppress("GetAgentVersionsAsync", typeof(string), typeof(int?), typeof(string), typeof(string), typeof(string), typeof(RequestOptions))] +[CodeGenSuppress("GetInternalAgentResponsesClient")] +[CodeGenSuppress("CreateAgentVersion", typeof(string), typeof(InternalAgentDefinition), typeof(IDictionary), typeof(string), typeof(CancellationToken))] +[CodeGenSuppress("CreateAgentVersionAsync", typeof(string), typeof(InternalAgentDefinition), typeof(IDictionary), typeof(string), typeof(CancellationToken))] +[CodeGenSuppress("UpdateAgent", typeof(string), typeof(InternalAgentDefinition), typeof(IDictionary), typeof(string), typeof(CancellationToken))] +[CodeGenSuppress("UpdateAgentAsync", typeof(string), typeof(InternalAgentDefinition), typeof(IDictionary), typeof(string), typeof(CancellationToken))] +[CodeGenSuppress("UpdateAgentFromManifest", typeof(string), typeof(string), typeof(IDictionary), typeof(IDictionary), typeof(string), typeof(CancellationToken))] +[CodeGenSuppress("UpdateAgentFromManifestAsync", typeof(string), typeof(string), typeof(IDictionary), typeof(IDictionary), typeof(string), typeof(CancellationToken))] +public partial class AIProjectAgentsOperations +{ + /// Retrieves the agent. + /// The name of the agent to retrieve. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult GetAgent(string agentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + + ClientResult result = GetAgent(agentName, cancellationToken.ToRequestOptions()); + return result.ToProjectOpenAIResult(); + } + + /// Retrieves the agent. + /// The name of the agent to retrieve. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> GetAgentAsync(string agentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + + ClientResult result = await GetAgentAsync(agentName, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return result.ToProjectOpenAIResult(); + } + + /// Create a new agent version. + /// The name of the agent for which a new version should be created. + /// Options, including the definition, for the new agent version to create. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult CreateAgentVersion(string agentName, AgentVersionCreationOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + Argument.AssertNotNull(options, nameof(options)); + + ClientResult result = CreateAgentVersion(agentName, BinaryContent.Create(ModelReaderWriter.Write(options, ModelSerializationExtensions.WireOptions, AzureAIProjectsContext.Default)), cancellationToken.ToRequestOptions()); + return result.ToProjectOpenAIResult(); + } + + /// Create a new agent version. + /// The name of the agent for which a new version should be created. + /// Options, including the definition, for the new agent version to create. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> CreateAgentVersionAsync(string agentName, AgentVersionCreationOptions options = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + Argument.AssertNotNull(options, nameof(options)); + + ClientResult result = await CreateAgentVersionAsync(agentName, BinaryContent.Create(ModelReaderWriter.Write(options, ModelSerializationExtensions.WireOptions, AzureAIProjectsContext.Default)), cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return result.ToProjectOpenAIResult(); + } + + public virtual ClientResult CreateAgentVersionFromManifest(string agentName, string manifestId, AgentManifestOptions options = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + Argument.AssertNotNullOrEmpty(manifestId, nameof(manifestId)); + Argument.AssertNotNull(options, nameof(options)); + + options ??= new(); + + ClientResult result = CreateAgentVersionFromManifest(agentName, options, cancellationToken.ToRequestOptions()); + return result.ToProjectOpenAIResult(); + } + + public virtual async Task> CreateAgentVersionFromManifestAsync(string agentName, string manifestId, AgentManifestOptions options = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + Argument.AssertNotNullOrEmpty(manifestId, nameof(manifestId)); + Argument.AssertNotNull(options, nameof(options)); + + ClientResult result = await CreateAgentVersionFromManifestAsync(agentName, options, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return result.ToProjectOpenAIResult(); + } + + /// Returns the list of all agents. + /// Filter agents by kind. If not provided, all agents are returned. + /// + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the + /// default is 20. + /// + /// + /// Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` + /// for descending order. + /// + /// + /// 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. + /// + /// + /// 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. + /// + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual CollectionResult GetAgents(AgentKind? kind = default, int? limit = default, AgentListOrder? order = default, string after = default, string before = default, CancellationToken cancellationToken = default) + { + return new InternalOpenAICollectionResultOfT( + Pipeline, + messageGenerator: (localCollectionOptions, localRequestOptions) + => CreateGetAgentsRequest( + localCollectionOptions.Filters.Count > 0 ? localCollectionOptions.Filters[0] : null, + localCollectionOptions.Limit, + localCollectionOptions.Order, + localCollectionOptions.AfterId, + localCollectionOptions.BeforeId, + localRequestOptions), + dataItemDeserializer: (e, o) => CustomSerializationHelpers.DeserializeProjectOpenAIType(e, o), + new InternalOpenAICollectionResultOptions(limit, order?.ToString(), after, before, filters: [kind?.ToString()]), + cancellationToken.ToRequestOptions()); + } + + /// Returns the list of all agents. + /// Filter agents by kind. If not provided, all agents are returned. + /// + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the + /// default is 20. + /// + /// + /// Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` + /// for descending order. + /// + /// + /// 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. + /// + /// + /// 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. + /// + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual AsyncCollectionResult GetAgentsAsync(AgentKind? kind = default, int? limit = default, AgentListOrder? order = default, string after = default, string before = default, CancellationToken cancellationToken = default) + { + return new InternalOpenAIAsyncCollectionResultOfT( + Pipeline, + messageGenerator: (localCollectionOptions, localRequestOptions) + => CreateGetAgentsRequest( + localCollectionOptions.Filters.Count > 0 ? localCollectionOptions.Filters[0] : null, + localCollectionOptions.Limit, + localCollectionOptions.Order, + localCollectionOptions.AfterId, + localCollectionOptions.BeforeId, + localRequestOptions), + dataItemDeserializer: (e, o) => CustomSerializationHelpers.DeserializeProjectOpenAIType(e, o), + new InternalOpenAICollectionResultOptions(limit, order?.ToString(), after, before, filters: [kind?.ToString()]), + cancellationToken.ToRequestOptions()); + } + + /// Returns the list of versions of an agent. + /// The name of the agent to retrieve versions for. + /// + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the + /// default is 20. + /// + /// + /// Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` + /// for descending order. + /// + /// + /// 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. + /// + /// + /// 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. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual CollectionResult GetAgentVersions(string agentName, int? limit = default, AgentListOrder? order = default, string after = default, string before = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + + return new InternalOpenAICollectionResultOfT( + Pipeline, + messageGenerator: (localCollectionOptions, localRequestOptions) + => CreateGetAgentVersionsRequest( + localCollectionOptions.ParentResourceId, + localCollectionOptions.Limit, + localCollectionOptions.Order, + localCollectionOptions.AfterId, + localCollectionOptions.BeforeId, + localRequestOptions), + dataItemDeserializer: (e, o) => CustomSerializationHelpers.DeserializeProjectOpenAIType(e, o), + new InternalOpenAICollectionResultOptions(limit, order?.ToString(), after, before) + { + ParentResourceId = agentName, + }, + cancellationToken.ToRequestOptions()); + } + + /// Returns the list of versions of an agent. + /// The name of the agent to retrieve versions for. + /// + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the + /// default is 20. + /// + /// + /// Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` + /// for descending order. + /// + /// + /// 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. + /// + /// + /// 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. + /// + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual AsyncCollectionResult GetAgentVersionsAsync(string agentName, int? limit = default, AgentListOrder? order = default, string after = default, string before = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + + return new InternalOpenAIAsyncCollectionResultOfT( + Pipeline, + messageGenerator: (localCollectionOptions, localRequestOptions) + => CreateGetAgentVersionsRequest( + localCollectionOptions.ParentResourceId, + localCollectionOptions.Limit, + localCollectionOptions.Order, + localCollectionOptions.AfterId, + localCollectionOptions.BeforeId, + localRequestOptions), + dataItemDeserializer: (e, o) => CustomSerializationHelpers.DeserializeProjectOpenAIType(e, o), + new InternalOpenAICollectionResultOptions(limit, order?.ToString(), after, before) + { + ParentResourceId = agentName, + }, + cancellationToken.ToRequestOptions()); + } + + /// Deletes an agent. + /// The name of the agent to delete. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult DeleteAgent(string agentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + + ClientResult result = DeleteAgent(agentName, cancellationToken.ToRequestOptions()); + return result; + } + + /// Deletes an agent. + /// The name of the agent to delete. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task DeleteAgentAsync(string agentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + + ClientResult result = await DeleteAgentAsync(agentName, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return result; + } + + /// Deletes a specific version of an agent. + /// The name of the agent to delete. + /// The version of the agent to delete. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult DeleteAgentVersion(string agentName, string agentVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + Argument.AssertNotNullOrEmpty(agentVersion, nameof(agentVersion)); + + ClientResult result = DeleteAgentVersion(agentName, agentVersion, cancellationToken.ToRequestOptions()); + return result; + } + + /// Deletes a specific version of an agent. + /// The name of the agent to delete. + /// The version of the agent to delete. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task DeleteAgentVersionAsync(string agentName, string agentVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(agentName, nameof(agentName)); + Argument.AssertNotNullOrEmpty(agentVersion, nameof(agentVersion)); + + ClientResult result = await DeleteAgentVersionAsync(agentName, agentVersion, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return result; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/Agents/AgentListOrder.cs b/sdk/ai/Azure.AI.Projects/src/Custom/Agents/AgentListOrder.cs new file mode 100644 index 000000000000..61368e85701f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Custom/Agents/AgentListOrder.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Azure.AI.Projects; + +[CodeGenType("ListAgentsRequestOrder")] +public readonly partial struct AgentListOrder +{ + [CodeGenMember("Asc")] + public static AgentListOrder Ascending { get; } = new AgentListOrder(AscValue); + + [CodeGenMember("Desc")] + public static AgentListOrder Descending { get; } = new AgentListOrder(DescValue); +} diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/Agents/AgentVersionCreationOptions.cs b/sdk/ai/Azure.AI.Projects/src/Custom/Agents/AgentVersionCreationOptions.cs new file mode 100644 index 000000000000..6a06b2feb944 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Custom/Agents/AgentVersionCreationOptions.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace Azure.AI.Projects; + +[CodeGenType("CreateAgentVersionRequest1")] +[CodeGenSuppress(nameof(AgentVersionCreationOptions), typeof(InternalAgentDefinition))] +[CodeGenSerialization(nameof(Definition), SerializationName = "definition", DeserializationValueHook = nameof(DeserializeDefinitionValue))] +public partial class AgentVersionCreationOptions +{ + /// A human-readable description of the agent. + [CodeGenMember("Description")] + public string Description { get; set; } + + [CodeGenMember("Definition")] + public global::Azure.AI.Projects.OpenAI.AgentDefinition Definition { get; set; } + + private static void DeserializeDefinitionValue(JsonProperty property, ref global::Azure.AI.Projects.OpenAI.AgentDefinition definition) + { + definition = CustomSerializationHelpers.DeserializeProjectOpenAIType(property.Value, ModelSerializationExtensions.WireOptions); + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/Agents/Internal/FoundryOpenAIError.cs b/sdk/ai/Azure.AI.Projects/src/Custom/Agents/Internal/FoundryOpenAIError.cs new file mode 100644 index 000000000000..0f0be5051a3e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Custom/Agents/Internal/FoundryOpenAIError.cs @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Linq; +using System.Text; +using System.Text.Json; + +namespace Azure.AI.Projects; + +/// The ApiError. +[CodeGenType("Error")] +internal partial class FoundryOpenAIError +{ + internal static FoundryOpenAIError TryCreateFromResponse(PipelineResponse response) + { + try + { + using JsonDocument errorDocument = JsonDocument.Parse(response.Content); + FoundryOpenAIError result = DeserializeFoundryOpenAIError(errorDocument.RootElement, ModelSerializationExtensions.WireOptions); + if (string.IsNullOrEmpty(result.Code) && string.IsNullOrEmpty(result.Param) && result.Details?.Count > 0 != true) + { + // Empty or uninteresting JSON documents should be treated like incomplete deserializations + return null; + } + return result; + } + catch (InvalidOperationException) + { + return null; + } + catch (JsonException) + { + return null; + } + catch (NullReferenceException) + { + return null; + } + } + + public string ToExceptionMessage(int httpStatus) + { + StringBuilder messageBuilder = new(); + messageBuilder.Append("HTTP ").Append(httpStatus).Append(" (").Append(Code).AppendLine(")"); + if (!string.IsNullOrEmpty(Param)) + { + messageBuilder.Append("Parameter: ").AppendLine(Param); + } + messageBuilder.AppendLine(); + messageBuilder.Append(Message); + if (Details?.Count > 0 == true) + { + messageBuilder.AppendLine().AppendLine(); + messageBuilder.Append(GetExceptionMessageRecursive()); + foreach (FoundryOpenAIError error in Details) + { + messageBuilder.AppendLine($"{error.Param ?? ""}:"); + messageBuilder.AppendLine().Append($" - {error.ToExceptionMessage(httpStatus)}"); + } + } + return messageBuilder.ToString(); + } + + private string GetExceptionMessageRecursive() + { + StringBuilder messageBuilder = new(); + foreach (FoundryOpenAIError error in Details) + { + messageBuilder.AppendLine($"{error.Param ?? ""}: {error.Message}"); + messageBuilder.AppendLine().Append($" - {error.GetExceptionMessageRecursive()}"); + } + return messageBuilder.ToString(); + } + + /// + /// Converts this instance payload into a formatted, equivalent response payload that conforms to the + /// expected schema in the OpenAI library. This will allow mechanisms like automatic exception message propagation to function as + /// intended. + /// + /// + public BinaryData ToOpenAIError() + { + StringBuilder messageBuilder = new(Message); + string parameterDetails = null; + if (Details?.Count > 0) + { + messageBuilder.Append(" ("); + foreach (FoundryOpenAIError error in Details) + { + messageBuilder.Append(error.GetExceptionMessageRecursive()); + messageBuilder.Append("; "); + } + messageBuilder.Remove(messageBuilder.Length - 2, 2); + messageBuilder.Append(')'); + parameterDetails = string.Join(";", Details.Select(x => x.Param)); + } + BinaryData newErrorBytes = BinaryData.FromString($$""" + { + "error": { + "message": "{{messageBuilder}}", + "type": "{{nameof(FoundryOpenAIError)}}", + "param": "{{(parameterDetails ?? string.Empty)}}", + "code": "{{(Code ?? string.Empty)}}" + } + } + """); + return newErrorBytes; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/Agents/Internal/InternalCreateAgentRequest.cs b/sdk/ai/Azure.AI.Projects/src/Custom/Agents/Internal/InternalCreateAgentRequest.cs new file mode 100644 index 000000000000..a530a09e3185 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Custom/Agents/Internal/InternalCreateAgentRequest.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace Azure.AI.Projects; + +[CodeGenType("CreateAgentRequest")] +[CodeGenSerialization(nameof(Definition), SerializationName = "definition", DeserializationValueHook = nameof(DeserializeDefinitionValue))] +internal partial class InternalCreateAgentRequest +{ + [CodeGenMember("Definition")] + public global::Azure.AI.Projects.OpenAI.AgentDefinition Definition { get; set; } + private static void DeserializeDefinitionValue(JsonProperty property, ref global::Azure.AI.Projects.OpenAI.AgentDefinition definition) + => CustomSerializationHelpers.DeserializeProjectOpenAIType(property.Value, ModelSerializationExtensions.WireOptions); +} diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/Agents/Internal/InternalUpdateAgentRequest.cs b/sdk/ai/Azure.AI.Projects/src/Custom/Agents/Internal/InternalUpdateAgentRequest.cs new file mode 100644 index 000000000000..bcb7dfe7f704 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Custom/Agents/Internal/InternalUpdateAgentRequest.cs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Text.Json; +using Azure.AI.Projects.OpenAI; + +namespace Azure.AI.Projects; + +[CodeGenType("UpdateAgentRequest")] +[CodeGenSerialization(nameof(Definition), SerializationName = "definition", DeserializationValueHook = nameof(DeserializeDefinitionValue))] +internal partial class InternalUpdateAgentRequest +{ + [CodeGenMember("Definition")] + public global::Azure.AI.Projects.OpenAI.AgentDefinition Definition { get; set; } + private static void DeserializeDefinitionValue(JsonProperty property, ref global::Azure.AI.Projects.OpenAI.AgentDefinition definition) + => CustomSerializationHelpers.DeserializeProjectOpenAIType(property.Value, ModelSerializationExtensions.WireOptions); +} diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/ClientConnectionCacheManager.cs b/sdk/ai/Azure.AI.Projects/src/Custom/ClientConnectionCacheManager.cs index ddb9a59a99f9..2f8bc410e023 100644 --- a/sdk/ai/Azure.AI.Projects/src/Custom/ClientConnectionCacheManager.cs +++ b/sdk/ai/Azure.AI.Projects/src/Custom/ClientConnectionCacheManager.cs @@ -14,13 +14,15 @@ namespace Azure.AI.Projects /// internal class ClientConnectionCacheManager { + private readonly ClientPipeline _pipeline; private readonly AuthenticationTokenProvider _tokenProvider; private readonly Uri _endpoint; private readonly ConcurrentDictionary _connectionCache = new(); private readonly ConcurrentDictionary _connections = new(); - public ClientConnectionCacheManager(Uri endpoint, AuthenticationTokenProvider tokenProvider) + public ClientConnectionCacheManager(Uri endpoint, ClientPipeline pipeline, AuthenticationTokenProvider tokenProvider) { + _pipeline = pipeline; _endpoint = endpoint; _tokenProvider = tokenProvider; } @@ -43,8 +45,18 @@ public ClientConnection GetConnection(string connectionId) throw new ArgumentException($"The AAD authentication target URI is missing or invalid for {connectionId}."); } - var newConnection = new ClientConnection(connectionId, _endpoint.AbsoluteUri, _tokenProvider, CredentialKind.TokenCredential); - return _connections.GetOrAdd(connectionId, newConnection); + ClientConnection? newConnection = null; + + if (connectionType == "DirectPipelinePassthrough") + { + newConnection = new(connectionId, _endpoint.AbsoluteUri.TrimEnd('/') + "/openai", _pipeline, CredentialKind.None); + } + else + { + newConnection = new(connectionId, _endpoint.AbsoluteUri, _tokenProvider, CredentialKind.TokenCredential); + } + + return _connections.GetOrAdd(connectionId, newConnection.Value); } /// @@ -78,6 +90,9 @@ private ConnectionType GetConnectionTypeFromId(string connectionId) case "Azure.AI.Inference.ImageEmbeddingsClient": return new ConnectionType("Inference"); + case "Internal.DirectPipelinePassthrough": + return new("DirectPipelinePassthrough"); + default: throw new ArgumentException($"Unknown connection type for ID: {connectionId}"); } diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/ClientPipelineExtensions.cs b/sdk/ai/Azure.AI.Projects/src/Custom/ClientPipelineExtensions.cs new file mode 100644 index 000000000000..f84b77f09de8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Custom/ClientPipelineExtensions.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace Azure.AI.Projects; + +internal static partial class ClientPipelineExtensions +{ + public static async ValueTask ProcessMessageAsync( + this ClientPipeline pipeline, + PipelineMessage message, + RequestOptions options) + { + await pipeline.SendAsync(message).ConfigureAwait(false); + + if (message.Response.IsError && (options?.ErrorOptions & ClientErrorBehaviors.NoThrow) != ClientErrorBehaviors.NoThrow) + { + throw await TryBufferResponseAndCreateErrorAsync(message).ConfigureAwait(false) switch + { + string errorMessage when !string.IsNullOrEmpty(errorMessage) + => new ClientResultException(errorMessage, message.Response), + _ => new ClientResultException(message.Response), + }; + } + + return message.BufferResponse ? + message.Response : + message.ExtractResponse(); + } + + public static PipelineResponse ProcessMessage( + this ClientPipeline pipeline, + PipelineMessage message, + RequestOptions options) + { + pipeline.Send(message); + + if (message.Response.IsError && (options?.ErrorOptions & ClientErrorBehaviors.NoThrow) != ClientErrorBehaviors.NoThrow) + { + throw TryBufferResponseAndCreateError(message) switch + { + string errorMessage when !string.IsNullOrEmpty(errorMessage) + => new ClientResultException(errorMessage, message.Response), + _ => new ClientResultException(message.Response), + }; + } + + return message.BufferResponse ? + message.Response : + message.ExtractResponse(); + } + + private static string TryBufferResponseAndCreateError(PipelineMessage message) + { + message.Response.BufferContent(); + return TryCreateErrorMessageFromResponse(message.Response); + } + + private static async Task TryBufferResponseAndCreateErrorAsync(PipelineMessage message) + { + await message.Response.BufferContentAsync().ConfigureAwait(false); + return TryCreateErrorMessageFromResponse(message.Response); + } + + private static string TryCreateErrorMessageFromResponse(PipelineResponse response) + => FoundryOpenAIError.TryCreateFromResponse(response)?.ToExceptionMessage(response.Status) + ?? GetFallbackExceptionMessageFromResponse(response); + + private static string GetFallbackExceptionMessageFromResponse(PipelineResponse response) + { + return new StringBuilder("An error was encountered while processing the request.") + .AppendLine() + .AppendLine($"HTTP {response.Status}: {((HttpStatusCode)response.Status)}") + .AppendLine() + .AppendLine(response.Content.ToString()) + .ToString(); + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/CodeGenStubs.OpenAI.cs b/sdk/ai/Azure.AI.Projects/src/Custom/CodeGenStubs.OpenAI.cs new file mode 100644 index 000000000000..73bdd666f621 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Custom/CodeGenStubs.OpenAI.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.AI.Projects; + +namespace OpenAI; + +// Internal types + +[CodeGenType("Annotation")] internal partial class InternalAnnotation { } +[CodeGenType("AnnotationFileCitation")] internal partial class InternalAnnotationFileCitation { } +[CodeGenType("AnnotationFilePath")] internal partial class InternalAnnotationFilePath { } +[CodeGenType("AnnotationUrlCitation")] internal partial class InternalAnnotationUrlCitation { } +[CodeGenType("ApproximateLocation")] internal partial class InternalApproximateLocation { } +[CodeGenType("CodeInterpreterOutput")] internal partial class InternalCodeInterpreterOutput { } +[CodeGenType("CodeInterpreterOutputImage")] internal partial class InternalCodeInterpreterOutputImage { } +[CodeGenType("CodeInterpreterOutputLogs")] internal partial class InternalCodeInterpreterOutputLogs { } +[CodeGenType("CodeInterpreterTool")] internal partial class InternalCodeInterpreterTool { } +[CodeGenType("CodeInterpreterToolAuto")] internal partial class InternalCodeInterpreterToolAuto { } +[CodeGenType("CodeInterpreterToolCallItemParam")] internal partial class InternalCodeInterpreterToolCallItemParam { } +[CodeGenType("CodeInterpreterToolCallItemResource")] internal partial class InternalCodeInterpreterToolCallItemResource { } +[CodeGenType("CodeInterpreterToolCallItemResourceStatus")] internal readonly partial struct CodeInterpreterToolCallItemResourceStatus { } +[CodeGenType("ComparisonFilter")] internal partial class InternalComparisonFilter { } +[CodeGenType("ComparisonFilterType")] internal readonly partial struct ComparisonFilterType { } +[CodeGenType("CompoundFilter")] internal partial class InternalCompoundFilter { } +[CodeGenType("CompoundFilterType")] internal readonly partial struct CompoundFilterType { } +[CodeGenType("ComputerAction")] internal partial class InternalComputerAction { } +[CodeGenType("ComputerActionClick")] internal partial class InternalComputerActionClick { } +[CodeGenType("ComputerActionClickButton")] internal readonly partial struct ComputerActionClickButton { } +[CodeGenType("ComputerActionDoubleClick")] internal partial class InternalComputerActionDoubleClick { } +[CodeGenType("ComputerActionDrag")] internal partial class InternalComputerActionDrag { } +[CodeGenType("ComputerActionKeyPress")] internal partial class InternalComputerActionKeyPress { } +[CodeGenType("ComputerActionMove")] internal partial class InternalComputerActionMove { } +[CodeGenType("ComputerActionScreenshot")] internal partial class InternalComputerActionScreenshot { } +[CodeGenType("ComputerActionScroll")] internal partial class InternalComputerActionScroll { } +[CodeGenType("ComputerActionTypeKeys")] internal partial class InternalComputerActionTypeKeys { } +[CodeGenType("ComputerActionWait")] internal partial class InternalComputerActionWait { } +[CodeGenType("ComputerToolCallItemParam")] internal partial class InternalComputerToolCallItemParam { } +[CodeGenType("ComputerToolCallItemResource")] internal partial class InternalComputerToolCallItemResource { } +[CodeGenType("ComputerToolCallItemResourceStatus")] internal readonly partial struct ComputerToolCallItemResourceStatus { } +[CodeGenType("ComputerToolCallOutputItemOutput")] internal partial class InternalComputerToolCallOutputItemOutput { } +[CodeGenType("ComputerToolCallOutputItemOutputComputerScreenshot")] internal partial class InternalComputerToolCallOutputItemOutputComputerScreenshot { } +[CodeGenType("ComputerToolCallOutputItemParam")] internal partial class InternalComputerToolCallOutputItemParam { } +[CodeGenType("ComputerToolCallOutputItemResource")] internal partial class InternalComputerToolCallOutputItemResource { } +[CodeGenType("ComputerToolCallOutputItemResourceStatus")] internal readonly partial struct ComputerToolCallOutputItemResourceStatus { } +[CodeGenType("ComputerToolCallSafetyCheck")] internal partial class InternalComputerToolCallSafetyCheck { } +[CodeGenType("ComputerUsePreviewTool")] internal partial class InternalComputerUsePreviewTool { } +[CodeGenType("ComputerUsePreviewToolEnvironment")] internal readonly partial struct ComputerUsePreviewToolEnvironment { } +[CodeGenType("Coordinate")] internal partial class InternalCoordinate { } +[CodeGenType("EasyInputMessage")] internal partial class InternalEasyInputMessage { } +[CodeGenType("FileSearchTool")] internal partial class InternalFileSearchTool { } +[CodeGenType("FileSearchToolCallItemParam")] internal partial class InternalFileSearchToolCallItemParam { } +[CodeGenType("FileSearchToolCallItemParamResult")] internal partial class InternalFileSearchToolCallItemParamResult { } +[CodeGenType("FileSearchToolCallItemResource")] internal partial class InternalFileSearchToolCallItemResource { } +[CodeGenType("FileSearchToolCallItemResourceStatus")] internal readonly partial struct FileSearchToolCallItemResourceStatus { } +[CodeGenType("FunctionTool")] internal partial class InternalFunctionTool { } +[CodeGenType("FunctionToolCallItemParam")] internal partial class InternalFunctionToolCallItemParam { } +[CodeGenType("FunctionToolCallItemResource")] internal partial class InternalFunctionToolCallItemResource { } +[CodeGenType("FunctionToolCallItemResourceStatus")] internal readonly partial struct FunctionToolCallItemResourceStatus { } +[CodeGenType("FunctionToolCallOutputItemParam")] internal partial class InternalFunctionToolCallOutputItemParam { } +[CodeGenType("FunctionToolCallOutputItemResource")] internal partial class InternalFunctionToolCallOutputItemResource { } +[CodeGenType("FunctionToolCallOutputItemResourceStatus")] internal readonly partial struct FunctionToolCallOutputItemResourceStatus { } +[CodeGenType("ImageGenTool")] internal partial class InternalImageGenTool { } +[CodeGenType("ImageGenToolBackground")] internal readonly partial struct ImageGenToolBackground { } +[CodeGenType("ImageGenToolCallItemParam")] internal partial class InternalImageGenToolCallItemParam { } +[CodeGenType("ImageGenToolCallItemResource")] internal partial class InternalImageGenToolCallItemResource { } +[CodeGenType("ImageGenToolCallItemResourceStatus")] internal readonly partial struct ImageGenToolCallItemResourceStatus { } +[CodeGenType("ImageGenToolInputImageMask")] internal partial class InternalImageGenToolInputImageMask { } +[CodeGenType("ImageGenToolModeration")] internal readonly partial struct ImageGenToolModeration { } +[CodeGenType("ImageGenToolOutputFormat")] internal readonly partial struct ImageGenToolOutputFormat { } +[CodeGenType("ImageGenToolQuality")] internal readonly partial struct ImageGenToolQuality { } +[CodeGenType("ImageGenToolSize")] internal readonly partial struct ImageGenToolSize { } +[CodeGenType("ImplicitUserMessage")] internal partial class InternalImplicitUserMessage { } +[CodeGenType("ItemContent")] internal partial class InternalItemContent { } +[CodeGenType("ItemContentInputAudio")] internal partial class InternalItemContentInputAudio { } +[CodeGenType("ItemContentInputAudioFormat")] internal readonly partial struct ItemContentInputAudioFormat { } +[CodeGenType("ItemContentInputFile")] internal partial class InternalItemContentInputFile { } +[CodeGenType("ItemContentInputImage")] internal partial class InternalItemContentInputImage { } +[CodeGenType("ItemContentInputImageDetail")] internal readonly partial struct ItemContentInputImageDetail { } +[CodeGenType("ItemContentInputText")] internal partial class InternalItemContentInputText { } +[CodeGenType("ItemContentOutputAudio")] internal partial class InternalItemContentOutputAudio { } +[CodeGenType("ItemContentOutputText")] internal partial class InternalItemContentOutputText { } +[CodeGenType("ItemContentRefusal")] internal partial class InternalItemContentRefusal { } +[CodeGenType("ItemParam")] internal partial class InternalItemParam { } +[CodeGenType("ItemReferenceItemParam")] internal partial class InternalItemReferenceItemParam { } +[CodeGenType("LocalShellExecAction")] internal partial class InternalLocalShellExecAction { } +[CodeGenType("LocalShellTool")] internal partial class InternalLocalShellTool { } +[CodeGenType("LocalShellToolCallItemParam")] internal partial class InternalLocalShellToolCallItemParam { } +[CodeGenType("LocalShellToolCallItemResource")] internal partial class InternalLocalShellToolCallItemResource { } +[CodeGenType("LocalShellToolCallItemResourceStatus")] internal readonly partial struct LocalShellToolCallItemResourceStatus { } +[CodeGenType("LocalShellToolCallOutputItemParam")] internal partial class InternalLocalShellToolCallOutputItemParam { } +[CodeGenType("LocalShellToolCallOutputItemResource")] internal partial class InternalLocalShellToolCallOutputItemResource { } +[CodeGenType("LocalShellToolCallOutputItemResourceStatus")] internal readonly partial struct LocalShellToolCallOutputItemResourceStatus { } +[CodeGenType("Location")] internal partial class InternalLocation { } +[CodeGenType("LogProb")] internal partial class InternalLogProb { } +[CodeGenType("MCPApprovalRequestItemParam")] internal partial class InternalMCPApprovalRequestItemParam { } +[CodeGenType("MCPApprovalRequestItemResource")] internal partial class InternalMCPApprovalRequestItemResource { } +[CodeGenType("MCPApprovalResponseItemParam")] internal partial class InternalMCPApprovalResponseItemParam { } +[CodeGenType("MCPApprovalResponseItemResource")] internal partial class InternalMCPApprovalResponseItemResource { } +[CodeGenType("MCPCallItemParam")] internal partial class InternalMCPCallItemParam { } +[CodeGenType("MCPCallItemResource")] internal partial class InternalMCPCallItemResource { } +[CodeGenType("MCPListToolsItemParam")] internal partial class InternalMCPListToolsItemParam { } +[CodeGenType("MCPListToolsItemResource")] internal partial class InternalMCPListToolsItemResource { } +[CodeGenType("MCPListToolsTool")] internal partial class InternalMCPListToolsTool { } +[CodeGenType("MCPTool")] internal partial class InternalMCPTool { } +[CodeGenType("MCPToolAllowedTools1")] internal partial class InternalMCPToolAllowedTools1 { } +[CodeGenType("MCPToolRequireApproval1")] internal partial class InternalMCPToolRequireApproval1 { } +[CodeGenType("MCPToolRequireApprovalAlways")] internal partial class InternalMCPToolRequireApprovalAlways { } +[CodeGenType("MCPToolRequireApprovalNever")] internal partial class InternalMCPToolRequireApprovalNever { } +[CodeGenType("RankingOptions")] internal partial class InternalRankingOptions { } +[CodeGenType("RankingOptionsRanker")] internal readonly partial struct RankingOptionsRanker { } +[CodeGenType("Reasoning")] internal partial class InternalReasoning { } +[CodeGenType("ReasoningEffort")] internal readonly partial struct ReasoningEffort { } +[CodeGenType("ReasoningGenerateSummary")] internal readonly partial struct ReasoningGenerateSummary { } +[CodeGenType("ReasoningItemParam")] internal partial class InternalReasoningItemParam { } +[CodeGenType("ReasoningItemResource")] internal partial class InternalReasoningItemResource { } +[CodeGenType("ReasoningItemSummaryPart")] internal partial class InternalReasoningItemSummaryPart { } +[CodeGenType("ReasoningItemSummaryTextPart")] internal partial class InternalReasoningItemSummaryTextPart { } +[CodeGenType("ReasoningSummary")] internal readonly partial struct ReasoningSummary { } +[CodeGenType("Response")] internal partial class InternalAgentResponse { } +[CodeGenType("ResponseError")] internal partial class InternalAgentResponseError { } +[CodeGenType("ResponseFormatJsonSchemaSchema")] internal partial class InternalResponseFormatJsonSchemaSchema { } +[CodeGenType("ResponsesAssistantMessageItemParam")] internal partial class InternalResponsesAssistantMessageItemParam { } +[CodeGenType("ResponsesAssistantMessageItemResource")] internal partial class InternalResponsesAssistantMessageItemResource { } +[CodeGenType("ResponsesDeveloperMessageItemParam")] internal partial class InternalResponsesDeveloperMessageItemParam { } +[CodeGenType("ResponsesDeveloperMessageItemResource")] internal partial class InternalResponsesDeveloperMessageItemResource { } +[CodeGenType("ResponsesMessageItemParam")] internal partial class InternalResponsesMessageItemParam { } +[CodeGenType("ResponsesMessageItemResource")] internal partial class InternalResponsesMessageItemResource { } +[CodeGenType("ResponsesMessageItemResourceStatus")] internal readonly partial struct ResponsesMessageItemResourceStatus { } +[CodeGenType("ResponsesMessageRole")] internal readonly partial struct ResponsesMessageRole { } +[CodeGenType("ResponsesSystemMessageItemParam")] internal partial class InternalResponsesSystemMessageItemParam { } +[CodeGenType("ResponsesSystemMessageItemResource")] internal partial class InternalResponsesSystemMessageItemResource { } +[CodeGenType("ResponseStatus")] internal readonly partial struct InternalAgentResponseStatus { } +[CodeGenType("ResponsesUserMessageItemParam")] internal partial class InternalResponsesUserMessageItemParam { } +[CodeGenType("ResponsesUserMessageItemResource")] internal partial class InternalResponsesUserMessageItemResource { } +[CodeGenType("ResponseTextFormatConfiguration")] internal partial class InternalResponseTextFormatConfiguration { } +[CodeGenType("ResponseTextFormatConfigurationJsonObject")] internal partial class InternalResponseTextFormatConfigurationJsonObject { } +[CodeGenType("ResponseTextFormatConfigurationJsonSchema")] internal partial class InternalResponseTextFormatConfigurationJsonSchema { } +[CodeGenType("ResponseTextFormatConfigurationText")] internal partial class InternalResponseTextFormatConfigurationText { } +[CodeGenType("ToolChoiceObject")] internal partial class InternalToolChoiceObject { } +[CodeGenType("ToolChoiceObjectCodeInterpreter")] internal partial class InternalToolChoiceObjectCodeInterpreter { } +[CodeGenType("ToolChoiceObjectComputer")] internal partial class InternalToolChoiceObjectComputer { } +[CodeGenType("ToolChoiceObjectFileSearch")] internal partial class InternalToolChoiceObjectFileSearch { } +[CodeGenType("ToolChoiceObjectFunction")] internal partial class InternalToolChoiceObjectFunction { } +[CodeGenType("ToolChoiceObjectImageGen")] internal partial class InternalToolChoiceObjectImageGen { } +[CodeGenType("ToolChoiceObjectMCP")] internal partial class InternalToolChoiceObjectMCP { } +[CodeGenType("ToolChoiceObjectWebSearch")] internal partial class InternalToolChoiceObjectWebSearch { } +[CodeGenType("ToolChoiceOptions")] internal readonly partial struct ToolChoiceOptions { } +[CodeGenType("TopLogProb")] internal partial class InternalTopLogProb { } +[CodeGenType("VectorStoreFileAttributes")] internal partial class InternalVectorStoreFileAttributes { } +[CodeGenType("WebSearchAction")] internal partial class InternalWebSearchAction { } +[CodeGenType("WebSearchActionFind")] internal partial class InternalWebSearchActionFind { } +[CodeGenType("WebSearchActionOpenPage")] internal partial class InternalWebSearchActionOpenPage { } +[CodeGenType("WebSearchActionSearch")] internal partial class InternalWebSearchActionSearch { } +[CodeGenType("WebSearchPreviewTool")] internal partial class InternalWebSearchPreviewTool { } +[CodeGenType("WebSearchPreviewToolSearchContextSize")] internal readonly partial struct WebSearchPreviewToolSearchContextSize { } +[CodeGenType("WebSearchToolCallItemParam")] internal partial class InternalWebSearchToolCallItemParam { } +[CodeGenType("WebSearchToolCallItemResource")] internal partial class InternalWebSearchToolCallItemResource { } +[CodeGenType("WebSearchToolCallItemResourceStatus")] internal readonly partial struct WebSearchToolCallItemResourceStatus { } diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/CodeGenStubs.cs b/sdk/ai/Azure.AI.Projects/src/Custom/CodeGenStubs.cs new file mode 100644 index 000000000000..36ec708592fb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Custom/CodeGenStubs.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Azure.AI.Projects; + +// Public type renames + +[CodeGenType("CreateAgentVersionFromManifestRequest1")] public partial class AgentManifestOptions { } +[CodeGenType("MemorySearchOptions")] public partial class MemorySearchResultOptions { } +[CodeGenType("MemoryStoreOperationUsageInputTokensDetails")] public partial class MemoryStoreOperationUsageInputTokensDetails { } +[CodeGenType("MemoryStoreOperationUsageOutputTokensDetails")] public partial class MemoryStoreOperationUsageOutputTokensDetails { } +[CodeGenType("MemoryStoreUpdateCompletedResult")] public partial class MemoryUpdateResultDetails { } + +// Internal types + +[CodeGenType("AgentDefinition")] internal partial class InternalAgentDefinition { } +[CodeGenType("AgentObject")] internal partial class InternalAgentObject { } +[CodeGenType("AgentProtocol")] internal readonly partial struct InternalAgentProtocol { } +[CodeGenType("AgentVersionObject")] internal partial class InternalAgentVersionObject { } +[CodeGenType("CreateMemoryStoreRequest")] internal partial class InternalCreateMemoryStoreRequest { } +[CodeGenType("PromptAgentDefinition")] internal partial class InternalPromptAgentDefinition { } +[CodeGenType("SearchMemoriesRequest")] internal partial class InternalMemorySearchOptions { } +[CodeGenType("Tool")] internal partial class InternalTool { } +[CodeGenType("UpdateMemoriesRequest")] internal partial class InternalMemoryUpdateOptions { } diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/Connections/AIProjectConnectionsOperations.cs b/sdk/ai/Azure.AI.Projects/src/Custom/Connections/AIProjectConnectionsOperations.cs index 42baaec64f0a..660f45318fde 100644 --- a/sdk/ai/Azure.AI.Projects/src/Custom/Connections/AIProjectConnectionsOperations.cs +++ b/sdk/ai/Azure.AI.Projects/src/Custom/Connections/AIProjectConnectionsOperations.cs @@ -2,8 +2,6 @@ // Licensed under the MIT License. using System; -using System.ClientModel; -using System.ComponentModel; using System.Threading; using System.Threading.Tasks; diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/Datasets/AIProjectDatasetsOperations.cs b/sdk/ai/Azure.AI.Projects/src/Custom/Datasets/AIProjectDatasetsOperations.cs index 739b8173c39f..30c87c2624c2 100644 --- a/sdk/ai/Azure.AI.Projects/src/Custom/Datasets/AIProjectDatasetsOperations.cs +++ b/sdk/ai/Azure.AI.Projects/src/Custom/Datasets/AIProjectDatasetsOperations.cs @@ -5,12 +5,10 @@ using System; using System.IO; +using System.Text.RegularExpressions; using System.Threading.Tasks; -using Azure.Storage.Blobs; using Azure.Core; -using System.Text.RegularExpressions; -using System.ClientModel; -using System.ClientModel.Primitives; +using Azure.Storage.Blobs; namespace Azure.AI.Projects { diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/MemoryStores/AIProjectMemoryStoresOperations.cs b/sdk/ai/Azure.AI.Projects/src/Custom/MemoryStores/AIProjectMemoryStoresOperations.cs new file mode 100644 index 000000000000..0356368782d4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Custom/MemoryStores/AIProjectMemoryStoresOperations.cs @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using OpenAI; + +namespace Azure.AI.Projects; + +[CodeGenSuppress("SearchMemories", typeof(string), typeof(string), typeof(IEnumerable), typeof(string), typeof(MemorySearchResultOptions), typeof(CancellationToken))] +[CodeGenSuppress("SearchMemoriesAsync", typeof(string), typeof(string), typeof(IEnumerable), typeof(string), typeof(MemorySearchResultOptions), typeof(CancellationToken))] +[CodeGenSuppress("UpdateMemories", typeof(string), typeof(string), typeof(IEnumerable), typeof(string), typeof(int?), typeof(CancellationToken))] +[CodeGenSuppress("UpdateMemoriesAsync", typeof(string), typeof(string), typeof(IEnumerable), typeof(string), typeof(int?), typeof(CancellationToken))] +[CodeGenSuppress("GetMemoryStores", typeof(int?), typeof(string), typeof(string), typeof(string), typeof(RequestOptions))] +[CodeGenSuppress("GetMemoryStoresAsync", typeof(int?), typeof(string), typeof(string), typeof(string), typeof(RequestOptions))] +[CodeGenType("MemoryStores")] +public partial class AIProjectMemoryStoresOperations +{ + /// Search for relevant memories from a memory store based on conversation context. + /// The ID of the memory store to search. + /// Memory search options. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult SearchMemories(string memoryStoreName, MemorySearchOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(memoryStoreName, nameof(memoryStoreName)); + Argument.AssertNotNull(options, nameof(options)); + + ClientResult result = SearchMemories(memoryStoreName, BinaryContent.Create(ModelReaderWriter.Write(options, ModelSerializationExtensions.WireOptions, AzureAIProjectsContext.Default)), cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((MemoryStoreSearchResponse)result, result.GetRawResponse()); + } + + /// Search for relevant memories from a memory store based on conversation context. + /// The ID of the memory store to search. + /// Memory search options. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> SearchMemoriesAsync(string memoryStoreName, MemorySearchOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(memoryStoreName, nameof(memoryStoreName)); + Argument.AssertNotNull(options, nameof(options)); + + ClientResult result = await SearchMemoriesAsync(memoryStoreName, BinaryContent.Create(ModelReaderWriter.Write(options, ModelSerializationExtensions.WireOptions, AzureAIProjectsContext.Default)), cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null).ConfigureAwait(false); + return ClientResult.FromValue((MemoryStoreSearchResponse)result, result.GetRawResponse()); + } + + /// List all memory stores. + /// + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the + /// default is 20. + /// + /// + /// Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` + /// for descending order. + /// + /// + /// 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. + /// + /// + /// 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. + /// + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual CollectionResult GetMemoryStores(int? limit = default, AgentListOrder? order = default, string after = default, string before = default, CancellationToken cancellationToken = default) + { + return new InternalOpenAICollectionResultOfT( + Pipeline, + messageGenerator: (localCollectionOptions, localRequestOptions) + => CreateGetMemoryStoresRequest( + localCollectionOptions.Limit, + localCollectionOptions.Order, + localCollectionOptions.AfterId, + localCollectionOptions.BeforeId, + localRequestOptions), + dataItemDeserializer: MemoryStore.DeserializeMemoryStore, + new InternalOpenAICollectionResultOptions(limit, order?.ToString(), after, before), + cancellationToken.ToRequestOptions()); + } + + /// List all memory stores. + /// + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the + /// default is 20. + /// + /// + /// Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` + /// for descending order. + /// + /// + /// 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. + /// + /// + /// 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. + /// + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual AsyncCollectionResult GetMemoryStoresAsync(int? limit = default, AgentListOrder? order = default, string after = default, string before = default, CancellationToken cancellationToken = default) + { + return new InternalOpenAIAsyncCollectionResultOfT( + Pipeline, + messageGenerator: (localCollectionOptions, localRequestOptions) + => CreateGetMemoryStoresRequest( + localCollectionOptions.Limit, + localCollectionOptions.Order, + localCollectionOptions.AfterId, + localCollectionOptions.BeforeId, + localRequestOptions), + dataItemDeserializer: MemoryStore.DeserializeMemoryStore, + new InternalOpenAICollectionResultOptions(limit, order?.ToString(), after, before), + cancellationToken.ToRequestOptions()); + } + + public virtual async Task> UpdateMemoriesAsync(string memoryStoreName, MemoryUpdateOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(memoryStoreName, nameof(memoryStoreName)); + Argument.AssertNotNull(options, nameof(options)); + + ClientResult protocolResult = await UpdateMemoriesAsync(memoryStoreName, BinaryContent.Create(ModelReaderWriter.Write(options, ModelSerializationExtensions.WireOptions, AzureAIProjectsContext.Default)), cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((MemoryUpdateResult)protocolResult, protocolResult.GetRawResponse()); + } + + public virtual ClientResult UpdateMemories(string memoryStoreName, MemoryUpdateOptions options, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(memoryStoreName, nameof(memoryStoreName)); + Argument.AssertNotNull(options, nameof(options)); + + ClientResult protocolResult = UpdateMemories(memoryStoreName, BinaryContent.Create(ModelReaderWriter.Write(options, ModelSerializationExtensions.WireOptions, AzureAIProjectsContext.Default)), cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((MemoryUpdateResult)protocolResult, protocolResult.GetRawResponse()); + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/MemoryStores/InternalCreateMemoryStoreRequest.cs b/sdk/ai/Azure.AI.Projects/src/Custom/MemoryStores/InternalCreateMemoryStoreRequest.cs new file mode 100644 index 000000000000..26631f0cf604 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Custom/MemoryStores/InternalCreateMemoryStoreRequest.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects; + +internal partial class InternalCreateMemoryStoreRequest +{ + /// Initializes a new instance of . + /// The name of the memory store. + /// A human-readable description of the memory store. + /// Arbitrary key-value metadata to associate with the memory store. + /// The memory store definition. + /// Keeps track of any properties unknown to the library. + internal InternalCreateMemoryStoreRequest(string name, string description, IDictionary metadata, MemoryStoreDefinition definition, IDictionary additionalBinaryDataProperties) + { + Name = name; + Description = description; + Metadata = metadata ?? new ChangeTrackingDictionary(); + Definition = definition; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/MemoryStores/MemorySearchOptions.cs b/sdk/ai/Azure.AI.Projects/src/Custom/MemoryStores/MemorySearchOptions.cs new file mode 100644 index 000000000000..f3ee289c5d3a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Custom/MemoryStores/MemorySearchOptions.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; +using OpenAI.Responses; + +namespace Azure.AI.Projects; + +public partial class MemorySearchOptions : IJsonModel +{ + /* + * Public wrapper type temporarily needed to mitigate code generation limitation with suffix/prefix + * collision of Azure.AI.Projects.OpenAI and OpenAI.Responses + */ + + public IList Items { get; private set; } + public string Scope { get; } + public string PreviousSearchId { get; set; } + public MemorySearchResultOptions ResultOptions { get; set; } + + public MemorySearchOptions(string scope) + { + Scope = scope; + Items = new ChangeTrackingList(); + } + + private InternalMemorySearchOptions GetInternalCopy() + { + return new InternalMemorySearchOptions(Scope, ResponseItemHelpers.ConvertItemsTo(Items), PreviousSearchId, ResultOptions, additionalBinaryDataProperties: null); + } + + private static MemorySearchOptions CreateFromInternalOptions(InternalMemorySearchOptions internalOptions) + { + return new(internalOptions.Scope) + { + PreviousSearchId = internalOptions.PreviousSearchId, + Items = ResponseItemHelpers.ConvertItemsTo(internalOptions.Items), + ResultOptions = internalOptions.Options, + }; + } + + MemorySearchOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + InternalMemorySearchOptions internalOptions = ((IJsonModel)new InternalMemorySearchOptions()).Create(ref reader, options); + return CreateFromInternalOptions(internalOptions); + } + + MemorySearchOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + InternalMemorySearchOptions internalOptions = ((IPersistableModel)new InternalMemorySearchOptions()).Create(data, options); + return CreateFromInternalOptions(internalOptions); + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) + => options.Format ?? ModelSerializationExtensions.WireOptions.Format; + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + ((IJsonModel)GetInternalCopy()).Write(writer, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + return ((IPersistableModel)GetInternalCopy()).Write(options); + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/MemoryStores/MemoryStore.cs b/sdk/ai/Azure.AI.Projects/src/Custom/MemoryStores/MemoryStore.cs new file mode 100644 index 000000000000..ab942d49f948 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Custom/MemoryStores/MemoryStore.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Azure.AI.Projects; + +[CodeGenType("MemoryStoreObject")] +public partial class MemoryStore +{ + /// The object type, which is always 'agent.version'. + [CodeGenMember("Object")] + internal string Object { get; } = "memory_store"; +} diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/MemoryStores/MemoryUpdateOptions.cs b/sdk/ai/Azure.AI.Projects/src/Custom/MemoryStores/MemoryUpdateOptions.cs new file mode 100644 index 000000000000..6ec865c3d869 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Custom/MemoryStores/MemoryUpdateOptions.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; +using OpenAI.Responses; + +namespace Azure.AI.Projects; + +public partial class MemoryUpdateOptions : IJsonModel +{ + public IList Items { get; private set; } + public string Scope { get; } + public string PreviousUpdateId { get; set; } + public int? UpdateDelay { get; set; } + + public MemoryUpdateOptions(string scope) + { + Scope = scope; + Items = new ChangeTrackingList(); + } + + private InternalMemoryUpdateOptions GetInternalCopy() + { + return new InternalMemoryUpdateOptions(Scope, ResponseItemHelpers.ConvertItemsTo(Items), PreviousUpdateId, UpdateDelay, additionalBinaryDataProperties: null); + } + + private static MemoryUpdateOptions CreateFromInternalOptions(InternalMemoryUpdateOptions internalOptions) + { + return new(internalOptions.Scope) + { + PreviousUpdateId = internalOptions.PreviousUpdateId, + UpdateDelay = internalOptions.UpdateDelay, + Items = ResponseItemHelpers.ConvertItemsTo(internalOptions.Items), + }; + } + + MemoryUpdateOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + InternalMemoryUpdateOptions internalOptions = ((IJsonModel)new InternalMemoryUpdateOptions()).Create(ref reader, options); + return CreateFromInternalOptions(internalOptions); + } + + MemoryUpdateOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + InternalMemoryUpdateOptions internalOptions = ((IPersistableModel)new InternalMemoryUpdateOptions()).Create(data, options); + return CreateFromInternalOptions(internalOptions); + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) + => options.Format ?? ModelSerializationExtensions.WireOptions.Format; + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + ((IJsonModel)GetInternalCopy()).Write(writer, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + return ((IPersistableModel)GetInternalCopy()).Write(options); + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/MemoryStores/MemoryUpdateResult.cs b/sdk/ai/Azure.AI.Projects/src/Custom/MemoryStores/MemoryUpdateResult.cs new file mode 100644 index 000000000000..9237bd4348f3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Custom/MemoryStores/MemoryUpdateResult.cs @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Azure.AI.Projects; + +[CodeGenType("MemoryStoreUpdateResponse")] +public partial class MemoryUpdateResult +{ + [CodeGenMember("Result")] + public MemoryUpdateResultDetails Details { get; } + + [CodeGenMember("Error")] + internal FoundryOpenAIError InternalError { get; } + + public string ErrorDetails => InternalError?.ToExceptionMessage(0); +} diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/MemoryStores/UpdateMemoryStoreRequest.cs b/sdk/ai/Azure.AI.Projects/src/Custom/MemoryStores/UpdateMemoryStoreRequest.cs new file mode 100644 index 000000000000..acbc6c4a50cd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Custom/MemoryStores/UpdateMemoryStoreRequest.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects; + +internal partial class UpdateMemoryStoreRequest +{ + /// Initializes a new instance of . + /// A human-readable description of the memory store. + /// Arbitrary key-value metadata to associate with the memory store. + /// Keeps track of any properties unknown to the library. + internal UpdateMemoryStoreRequest(string description, IDictionary metadata, IDictionary additionalBinaryDataProperties) + { + Description = description; + Metadata = metadata ?? new ChangeTrackingDictionary(); + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/Telemetry/OpenTelemetryConstants.cs b/sdk/ai/Azure.AI.Projects/src/Custom/Telemetry/OpenTelemetryConstants.cs new file mode 100644 index 000000000000..7e071a25861f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Custom/Telemetry/OpenTelemetryConstants.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Azure.AI.Projects.Telemetry +{ + internal class OpenTelemetryConstants + { + // follow OpenTelemetry GenAI semantic conventions: + // https://github.com/open-telemetry/semantic-conventions/tree/v1.27.0/docs/gen-ai + + public const string ErrorTypeKey = "error.type"; + public const string ErrorMessageKey = "error.message"; + + public const string AzNamespaceKey = "az.namespace"; + public const string ServerAddressKey = "server.address"; + public const string ServerPortKey = "server.port"; + + public const string GenAiClientOperationDurationMetricName = "gen_ai.client.operation.duration"; + public const string GenAiClientTokenUsageMetricName = "gen_ai.client.token.usage"; + + public const string GenAiOperationNameKey = "gen_ai.operation.name"; + + public const string GenAiRequestMaxTokensKey = "gen_ai.request.max_tokens"; + public const string GenAiRequestModelKey = "gen_ai.request.model"; + public const string GenAiAgentNameKey = "gen_ai.agent.name"; + public const string GenAiRequestTemperatureKey = "gen_ai.request.temperature"; + public const string GenAiRequestTopPKey = "gen_ai.request.top_p"; + + public const string GenAiResponseModelKey = "gen_ai.response.model"; + public const string GenAiResponseVersionKey = "gen_ai.agent.version"; + + public const string GenAiSystemKey = "gen_ai.system"; + public const string GenAiSystemValue = "az.ai.agents"; + public const string GenAiProviderKey = "gen_ai.provider"; + public const string GenAiProviderValue = "azure.ai.agents"; + + public const string GenAiTokenTypeKey = "gen_ai.token.type"; + + public const string GenAiUsageInputTokensKey = "gen_ai.usage.input_tokens"; + public const string GenAiUsageOutputTokensKey = "gen_ai.usage.output_tokens"; + public const string GenAiAgentIdKey = "gen_ai.agent.id"; + public const string GenAiThreadIdKey = "gen_ai.thread.id"; + public const string GenAiMessageIdKey = "gen_ai.message.id"; + public const string GenAiMessageStatusKey = "gen_ai.message.status"; + public const string GenAiRunIdKey = "gen_ai.thread.run.id"; + public const string GenAiRunStatusKey = "gen_ai.thread.run.status"; + public const string GenAiRunStepStatusKey = "gen_ai.run_step.status"; + public const string GenAiRunStepStartTimestampKey = "gen_ai.run_step.start.timestamp"; + public const string GenAiRunStepEndTimestampKey = "gen_ai.run_step.end.timestamp"; + + public const string GenAiEventContent = "gen_ai.event.content"; + public const string GenAiChoice = "gen_ai.choice"; + + public const string AzureRpNamespaceValue = "Microsoft.CognitiveServices"; + + public const string OperationNameValueCreateAgent = "create_agent"; + public const string OperationNameValueCreateThread = "create_thread"; + public const string OperationNameValueCreateMessage = "create_message"; + public const string OperationNameValueStartThreadRun = "start_thread_run"; + public const string OperationNameValueGetThreadRun = "get_thread_run"; + public const string OperationNameValueExecuteTool = "execute_tool"; + public const string OperationNameValueListMessage = "list_messages"; + public const string OperationNameValueListRunSteps = "list_run_steps"; + public const string OperationNameValueSubmitToolOutputs = "submit_tool_outputs"; + public const string OperationNameValueProcessThreadRun = "process_thread_run"; + + public const string EventNameSystemMessage = "gen_ai.system.message"; + public const string EventNameUserMessage = "gen_ai.user.message"; + public const string EventNameAssistantMessage = "gen_ai.assistant.message"; + + public const string ClientName = "Azure.AI.Agents.AgentClient"; + public const string EnableOpenTelemetrySwitch = "Azure.Experimental.EnableActivitySource"; + public const string TraceContentsSwitch = "Azure.Experimental.TraceGenAIMessageContent"; + public const string TraceContentsEnvironmentVariable = "OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT"; + public const string EnableOpenTelemetryEnvironmentVariable = "AZURE_EXPERIMENTAL_ENABLE_ACTIVITY_SOURCE"; + + public const string GenAiRequestReasoningEffort = "gen_ai.request.reasoning.effort"; + public const string GenAiRequestReasoningSummary = "gen_ai.request.reasoning.summary"; + public const string GenAiRequestStructuredInputs = "gen_ai.request.structured_inputs"; + public const string GenAiAgentVersion = "gen_ai.agent.version"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/Telemetry/OpenTelemetryScope.cs b/sdk/ai/Azure.AI.Projects/src/Custom/Telemetry/OpenTelemetryScope.cs new file mode 100644 index 000000000000..0c60a093188d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Custom/Telemetry/OpenTelemetryScope.cs @@ -0,0 +1,475 @@ +// 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.Diagnostics; +using System.Diagnostics.Metrics; +using System.IO; +using System.Text; +using System.Text.Encodings.Web; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Threading; +using System.Threading.Tasks; +using Azure.AI.Projects; +using Azure.AI.Projects.OpenAI; +using Azure.Core; +using static Azure.AI.Projects.Telemetry.OpenTelemetryConstants; + +namespace Azure.AI.Projects.Telemetry +{ + internal class OpenTelemetryScope : IDisposable + { + internal enum OpenTelemetryScopeType + { + Unknown, + CreateAgent, + CreateThread, + CreateMessage, + CreateRun, + ListMessages, + SubmitToolOutputs, + ListRunSteps + } + + /// + /// Activity source is used to save events and log the tags. + /// On the ApplicationInsights events are logged to traces table. + /// The tags are not logged, but are shown in the console. + /// + private static readonly ActivitySource s_agentSource = new(ClientName); + /// + /// Add histograms to log metrics. + /// On the ApplicationInsights metrics are logged to customMetrics table. + /// + private static readonly Meter s_meter = new Meter(ClientName); + private static readonly Histogram s_duration = s_meter.CreateHistogram( + GenAiClientOperationDurationMetricName, "s", "Measures GenAI operation duration."); + private static readonly Histogram s_tokens = s_meter.CreateHistogram( + GenAiClientTokenUsageMetricName, "{token}", "Measures the number of input and output token used."); + private static readonly JsonSerializerOptions s_jsonOptions = new JsonSerializerOptions + { + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping // Allow non-ASCII characters + }; + + private readonly Activity _activity; + private readonly Stopwatch _duration; + private readonly TagList _commonTags; + private static bool s_traceContent = AppContextSwitchHelper.GetConfigValue( + TraceContentsSwitch, + TraceContentsEnvironmentVariable); + private static bool s_enableTelemetry = AppContextSwitchHelper.GetConfigValue( + EnableOpenTelemetrySwitch, + EnableOpenTelemetryEnvironmentVariable); + private RecordedResponse _response; + private string _errorType; + private Exception _exception; + + private int _hasEnded = 0; + private readonly OpenTelemetryScopeType _scopeType; + private static void ReinitializeConfiguration() + { + s_traceContent = AppContextSwitchHelper.GetConfigValue( + TraceContentsSwitch, + TraceContentsEnvironmentVariable); + + s_enableTelemetry = AppContextSwitchHelper.GetConfigValue( + EnableOpenTelemetrySwitch, + EnableOpenTelemetryEnvironmentVariable); + } + + /// + /// Create the instance of OpenTelemetryScope for agent creation. + /// This constructor logs request and starts the execution timer. + /// + /// The endpoint being called. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public static OpenTelemetryScope StartCreateAgent(Uri endpoint, BinaryContent content, RequestOptions options = null) + { + if (!s_enableTelemetry || !(s_agentSource.HasListeners() || s_duration.Enabled)) + { + return null; + } + + // Convert BinaryContent back to AgentVersionCreationOptions + using var memoryStream = new MemoryStream(); + content.WriteTo(memoryStream, CancellationToken.None); + memoryStream.Position = 0; + + BinaryData binaryData = BinaryData.FromStream(memoryStream); + InternalCreateAgentRequest creationOptions = ModelReaderWriter.Read( + binaryData, + ModelSerializationExtensions.WireOptions, + AzureAIProjectsContext.Default + ); + string operationName = OperationNameValueCreateAgent + " " + creationOptions.Name; + var scope = new OpenTelemetryScope(operationName, endpoint, OperationNameValueCreateAgent); + if (scope._activity?.IsAllDataRequested != true && !s_duration.Enabled) + { + return null; + } + + SetAgentDefinitionTelemetryTags(scope, creationOptions.Definition, creationOptions.Name); + + return scope; + } + + /// + /// Create the instance of OpenTelemetryScope for agent update. + /// This constructor logs request and starts the execution timer. + /// + /// The endpoint being called. + /// The name of the agent to create/modify. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public static OpenTelemetryScope StartUpdateAgent(Uri endpoint, string agentName, BinaryContent content, RequestOptions options = null) + { + if (!s_enableTelemetry || !(s_agentSource.HasListeners() || s_duration.Enabled)) + { + return null; + } + + // Convert BinaryContent back to AgentVersionCreationOptions + using var memoryStream = new MemoryStream(); + content.WriteTo(memoryStream, CancellationToken.None); + memoryStream.Position = 0; + BinaryData binaryData = BinaryData.FromStream(memoryStream); + AgentVersionCreationOptions updateOptions = ModelReaderWriter.Read( + binaryData, + ModelSerializationExtensions.WireOptions, + AzureAIProjectsContext.Default + ); + + string operationName = OperationNameValueCreateAgent + " " + agentName; + var scope = new OpenTelemetryScope(operationName, endpoint, OperationNameValueCreateAgent); + if (scope._activity?.IsAllDataRequested != true && !s_duration.Enabled) + { + return null; + } + + SetAgentDefinitionTelemetryTags(scope, updateOptions.Definition, agentName); + + return scope; + } + + /// + /// Create the instance of OpenTelemetryScope for agent creation. + /// This constructor logs request and starts the execution timer. + /// + /// The endpoint being called. + /// The name of the agent to create/modify. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public static OpenTelemetryScope StartCreateAgentVersion(Uri endpoint, string agentName, BinaryContent content, RequestOptions options = null) + { + if (!s_enableTelemetry || !(s_agentSource.HasListeners() || s_duration.Enabled)) + { + return null; + } + + // Convert BinaryContent back to AgentVersionCreationOptions + using var memoryStream = new MemoryStream(); + content.WriteTo(memoryStream, CancellationToken.None); + memoryStream.Position = 0; + BinaryData binaryData = BinaryData.FromStream(memoryStream); + AgentVersionCreationOptions creationOptions = ModelReaderWriter.Read( + binaryData, + ModelSerializationExtensions.WireOptions, + AzureAIProjectsContext.Default + ); + + string operationName = OperationNameValueCreateAgent + " " + agentName; + var scope = new OpenTelemetryScope(operationName, endpoint, OperationNameValueCreateAgent); + if (scope._activity?.IsAllDataRequested != true && !s_duration.Enabled) + { + return null; + } + + SetAgentDefinitionTelemetryTags(scope, creationOptions.Definition, agentName); + + return scope; + } + + /// + /// Sets telemetry tags and events for agent definition, handling both PromptAgentDefinition and other types. + /// + /// The OpenTelemetryScope instance to set tags on. + /// The agent definition to process. + /// The name of the agent. + private static void SetAgentDefinitionTelemetryTags(OpenTelemetryScope scope, AgentDefinition agentDefinition, string agentName) + { + if (agentDefinition is PromptAgentDefinition promptAgentDefinition) + { + scope.SetTagMaybe(GenAiRequestModelKey, promptAgentDefinition.Model); + scope.SetTagMaybe(GenAiAgentNameKey, agentName); + scope.SetTagMaybe(GenAiRequestTemperatureKey, promptAgentDefinition.Temperature); + scope.SetTagMaybe(GenAiRequestTopPKey, promptAgentDefinition.TopP); + + var reasoningOptions = promptAgentDefinition.ReasoningOptions; + if (reasoningOptions != null) + { + scope.SetTagMaybe(GenAiRequestReasoningEffort, reasoningOptions.ReasoningEffortLevel); + scope.SetTagMaybe(GenAiRequestReasoningSummary, reasoningOptions.ReasoningSummaryVerbosity); + } + + // TODO: check if structured outputs should be events and follow content recording flag + //var structuredInputs = promptAgentDefinition.StructuredInputs; + + string traceEvent = s_traceContent ? JsonSerializer.Serialize( + new EventContent (promptAgentDefinition.Instructions), + EventsContext.Default.EventContent + ) : JsonSerializer.Serialize("", EventsContext.Default.String); + + ActivityTagsCollection messageTags = new() { + { GenAiSystemKey, GenAiSystemValue}, + { GenAiEventContent, traceEvent } + }; + + scope._activity?.AddEvent( + new ActivityEvent(EventNameSystemMessage, tags: messageTags) + ); + } + else + { + // Handle other agent definition types or set default values + scope.SetTagMaybe(GenAiRequestModelKey, "unknown"); + scope.SetTagMaybe(GenAiAgentNameKey, agentName); + scope.SetTagMaybe(GenAiRequestTemperatureKey, null); + scope.SetTagMaybe(GenAiRequestTopPKey, null); + } + } + + private OpenTelemetryScope(string activityName, Uri endpoint, string operationName=null) + { + _scopeType = activityName switch + { + var n when n == OperationNameValueCreateAgent => OpenTelemetryScopeType.CreateAgent, + var n when n == OperationNameValueCreateThread => OpenTelemetryScopeType.CreateThread, + var n when n == OperationNameValueCreateMessage => OpenTelemetryScopeType.CreateMessage, + var n when n == OperationNameValueStartThreadRun => OpenTelemetryScopeType.CreateRun, + var n when n == OperationNameValueListMessage => OpenTelemetryScopeType.ListMessages, + var n when n == OperationNameValueSubmitToolOutputs => OpenTelemetryScopeType.SubmitToolOutputs, + var n when n == OperationNameValueListRunSteps => OpenTelemetryScopeType.ListRunSteps, + _ => OpenTelemetryScopeType.Unknown + }; + + if (operationName == null) + { + operationName = activityName; + } + + _activity = s_agentSource.StartActivity(activityName, ActivityKind.Client); + + // suppress nested client activities from generated code. + _activity?.SetCustomProperty("az.sdk.scope", bool.TrueString); + + // Record the request to telemetry. + _commonTags = new TagList() + { + { GenAiSystemKey, GenAiSystemValue}, + { GenAiOperationNameKey, operationName}, + { ServerAddressKey, endpoint.Host } + }; + // Only record port if it is different from 443. + if (endpoint.Port != 443) + { + _commonTags.Add(ServerPortKey, endpoint.Port); + } + + // Set tags for reporting them to console. + foreach (KeyValuePair kv in _commonTags) + { + _activity?.SetTag(kv.Key, kv.Value); + } + _activity?.SetTag(AzNamespaceKey, AzureRpNamespaceValue); + _duration = Stopwatch.StartNew(); + } + + public void RecordCreateAgentResponse(ClientResult response) + { + if (s_enableTelemetry) + { + AgentRecord agentClientResult = response.ToProjectOpenAIResult(); + _response = new RecordedResponse(s_traceContent); + //var agentResponse = Response.FromValue(PersistentAgent.FromResponse(response), response); + _response.AgentId = agentClientResult.Id; + } + } + + public void RecordUpdateAgentResponse(ClientResult response) + { + if (s_enableTelemetry) + { + AgentRecord agentClientResult = response.ToProjectOpenAIResult(); + _response = new RecordedResponse(s_traceContent); + //var agentResponse = Response.FromValue(PersistentAgent.FromResponse(response), response); + _response.AgentId = agentClientResult.Id; + _response.Version = agentClientResult.Versions.Latest.Version; + } + } + + public void RecordCreateAgentVersionResponse(ClientResult response) + { + if (s_enableTelemetry) + { + AgentVersion agentVersion = response.ToProjectOpenAIResult(); + _response = new RecordedResponse(s_traceContent); + //var agentResponse = Response.FromValue(PersistentAgent.FromResponse(response), response); + _response.AgentId = agentVersion.Id; + _response.Version = agentVersion.Version; + } + } + /// + /// Log the error. + /// + /// Exception thrown by completion call. + public void RecordError(Exception e) + { + if (s_enableTelemetry) + { + if (e is RequestFailedException requestFailed && requestFailed.Status != 0) + { + _errorType = requestFailed.Status.ToString(); + } + else + { + _errorType = e?.GetType()?.FullName ?? "error"; + } + _exception = e; + } + } + + /// + /// Record the task cancellation event. + /// + public void RecordCancellation() + { + if (s_enableTelemetry) + { + _errorType = typeof(TaskCanceledException).FullName; + _exception = null; + } + } + + /// + /// Record the events and metrics associated with the response. + /// + private void End() + { + TagList finalTags = _commonTags; + + if (_errorType == null && !IsResponseValid(_response)) + { + // If there is no response and no error, it is an unexpected error. + _errorType = "error"; + } + + if (_errorType != null) + { + finalTags.Add(ErrorTypeKey, _errorType); + _activity?.SetTag(ErrorTypeKey, _errorType); + _activity?.SetStatus(ActivityStatusCode.Error, _exception?.Message); + } + + if (_response == null) + { + s_duration.Record(_duration.Elapsed.TotalSeconds, finalTags); + return; + } + + if (!string.IsNullOrEmpty(_response.Model)) + { + finalTags.Add(GenAiResponseModelKey, _response.Model); + _activity?.SetTag(GenAiResponseModelKey, _response.Model); + } + + if (!string.IsNullOrEmpty(_response.Version)) + { + finalTags.Add(GenAiAgentVersion, _response.Version); + _activity?.SetTag(GenAiAgentVersion, _response.Version); + } + + if (_response.PromptTokens.HasValue) + { + finalTags.Add(GenAiUsageInputTokensKey, _response.PromptTokens); + _activity?.SetTag(GenAiUsageInputTokensKey, _response.PromptTokens); + } + + if (_response.CompletionTokens.HasValue) + { + finalTags.Add(GenAiUsageOutputTokensKey, _response.CompletionTokens); + _activity?.SetTag(GenAiUsageOutputTokensKey, _response.CompletionTokens); + } + + SetTagMaybe(GenAiAgentIdKey, _response.AgentId); + SetTagMaybe(GenAiThreadIdKey, _response.ThreadId); + SetTagMaybe(GenAiMessageIdKey, _response.MessageId); + SetTagMaybe(GenAiRunIdKey, _response.RunId); + SetTagMaybe(GenAiRunStatusKey, _response.RunStatus); + + // Record input tokens + if (_response.PromptTokens.HasValue) + { + TagList input_tags = finalTags; + input_tags.Add(GenAiUsageInputTokensKey, "input"); + s_tokens.Record(_response.PromptTokens.Value, input_tags); + } + // Record output tokens + if (_response.CompletionTokens.HasValue) + { + TagList output_tags = finalTags; + output_tags.Add(GenAiUsageOutputTokensKey, "output"); + s_tokens.Record(_response.CompletionTokens.Value, output_tags); + } + } + + public void Dispose() + { + // check if the scope has already ended + if (s_enableTelemetry && Interlocked.Exchange(ref _hasEnded, 1) == 0) + { + //_response ??= _buffer?.ToResponse(); + End(); + _activity?.Dispose(); + } + } + + private static bool IsResponseValid(RecordedResponse response) + { + return response != null;// && response.Id != null && response.FinishReasons != null; + } + + /// + /// Set the tag on the activity, if the tag is present. + /// + /// + /// The name of tag to set. + /// Nullable value to be set. + private void SetTagMaybe(string name, T? value) where T : struct + { + if (value.HasValue) + { + _activity?.SetTag(name, value.Value); + } + } + + private void SetTagMaybe(string name, string value) + { + if (!string.IsNullOrEmpty(value)) + { + _activity?.SetTag(name, value); + } + } + + internal static void ResetEnvironmentForTests() + { + s_traceContent = AppContextSwitchHelper.GetConfigValue(TraceContentsSwitch, TraceContentsEnvironmentVariable); + s_enableTelemetry = AppContextSwitchHelper.GetConfigValue(EnableOpenTelemetrySwitch, EnableOpenTelemetryEnvironmentVariable); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/Telemetry/RecordedResponse.cs b/sdk/ai/Azure.AI.Projects/src/Custom/Telemetry/RecordedResponse.cs new file mode 100644 index 000000000000..19cfdfe3f94c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Custom/Telemetry/RecordedResponse.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Collections.Generic; + +namespace Azure.AI.Projects.Telemetry +{ +#nullable enable + internal class RecordedResponse + { + public string? AgentId { get; set; } + public string? ThreadId { get; set; } + public string? MessageId { get; set; } + public string? RunId { get; set; } + + public bool Stream { get; set; } + public string? Model { get; set; } + public string? RunStatus { get; set; } + public string? Id { get; set; } + public string? Version { get; set; } + public string?[]? FinishReasons { get; set; } + public long? CompletionTokens { get; set; } + public long? PromptTokens { get; set; } + public object[]? Choices { get; set; } + //public List? Messages { get; set; } + //public List? RunSteps { get; set; } + + //public ThreadRun? LastRun { get; set; } + //public PersistentThreadMessage? LastMessage { get; set; } + + //public List? StreamingMessages { get; set; } = null; + + private bool _recordContent = false; + + public RecordedResponse(bool recordContent) + { + _recordContent = recordContent; + Stream = false; + } + + //internal void AddStreamingMessage(StreamingMessage message) + //{ + // if (StreamingMessages == null) + // { + // StreamingMessages = new List(); + // } + // if (message != null) + // { + // StreamingMessages.Add(message); + // // Optionally: emit/log/trace here + // } + //} + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Custom/Telemetry/TelemetryObjectSerialization.cs b/sdk/ai/Azure.AI.Projects/src/Custom/Telemetry/TelemetryObjectSerialization.cs new file mode 100644 index 000000000000..77b650c5b7bd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Custom/Telemetry/TelemetryObjectSerialization.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Collections.Generic; +using System.Text.Encodings.Web; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Azure.AI.Projects; + +// The set of helper classes to serialize the event object. + +internal class EventContent +{ + public string content { get; set; } + public EventContent(string content) { this.content = content; } +} + +internal class EventRole +{ + public string role { get; set; } + public EventRole(string role) { this.role = role; } +} + +internal class EventContentRole +{ + public string content { get; set; } + public string role { get; set; } + public EventContentRole(string content, string role) + { + this.content = content; + this.role = role; + } +} + +internal class EventContentId +{ + public string content { get; set; } + public string id { get; set; } + public EventContentId(string content, string id) + { + this.content = content; + this.id = id; + } +} + +[JsonSerializable(typeof(EventContentId))] +[JsonSerializable(typeof(EventContentRole))] +[JsonSerializable(typeof(EventRole))] +[JsonSerializable(typeof(EventContent))] +[JsonSerializable(typeof(Dictionary))] +internal partial class EventsContext : JsonSerializerContext +{ + private JsonSerializerOptions _options; + + public new JsonSerializerOptions Options + { + get + { + JsonSerializerOptions options = _options; + + if (options is null) + { + options = new JsonSerializerOptions + { + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, // Allow non-ASCII characters + TypeInfoResolver = this + }; + options.MakeReadOnly(); + _options = options; + } + + return options; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/A2ATool.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/A2ATool.Serialization.cs new file mode 100644 index 000000000000..c1ee644290fd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/A2ATool.Serialization.cs @@ -0,0 +1,156 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// An agent implementing the A2A protocol. + internal partial class A2ATool : InternalTool, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(A2ATool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(BaseUrl)) + { + writer.WritePropertyName("base_url"u8); + writer.WriteStringValue(BaseUrl.AbsoluteUri); + } + if (Optional.IsDefined(AgentCardPath)) + { + writer.WritePropertyName("agent_card_path"u8); + writer.WriteStringValue(AgentCardPath); + } + if (Optional.IsDefined(ProjectConnectionId)) + { + writer.WritePropertyName("project_connection_id"u8); + writer.WriteStringValue(ProjectConnectionId); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + A2ATool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (A2ATool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(A2ATool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeA2ATool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static A2ATool DeserializeA2ATool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + Uri baseUrl = default; + string agentCardPath = default; + string projectConnectionId = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("base_url"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + baseUrl = new Uri(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("agent_card_path"u8)) + { + agentCardPath = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("project_connection_id"u8)) + { + projectConnectionId = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new A2ATool(@type, additionalBinaryDataProperties, baseUrl, agentCardPath, projectConnectionId); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(A2ATool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + A2ATool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (A2ATool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeA2ATool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(A2ATool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/A2ATool.cs b/sdk/ai/Azure.AI.Projects/src/Generated/A2ATool.cs new file mode 100644 index 000000000000..452e3cb8623e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/A2ATool.cs @@ -0,0 +1,53 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// An agent implementing the A2A protocol. + internal partial class A2ATool : InternalTool + { + /// Initializes a new instance of . + public A2ATool() : base(ToolType.A2aPreview) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// Base URL of the agent. + /// + /// The path to the agent card relative to the `base_url`. + /// If not provided, defaults to `/.well-known/agent-card.json` + /// + /// + /// The connection ID in the project for the A2A server. + /// The connection stores authentication and other connection details needed to connect to the A2A server. + /// + internal A2ATool(ToolType @type, IDictionary additionalBinaryDataProperties, Uri baseUrl, string agentCardPath, string projectConnectionId) : base(@type, additionalBinaryDataProperties) + { + BaseUrl = baseUrl; + AgentCardPath = agentCardPath; + ProjectConnectionId = projectConnectionId; + } + + /// Base URL of the agent. + public Uri BaseUrl { get; set; } + + /// + /// The path to the agent card relative to the `base_url`. + /// If not provided, defaults to `/.well-known/agent-card.json` + /// + public string AgentCardPath { get; set; } + + /// + /// The connection ID in the project for the A2A server. + /// The connection stores authentication and other connection details needed to connect to the A2A server. + /// + public string ProjectConnectionId { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectAgentsOperations.RestClient.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectAgentsOperations.RestClient.cs new file mode 100644 index 000000000000..7da86de13924 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectAgentsOperations.RestClient.cs @@ -0,0 +1,238 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace Azure.AI.Projects +{ + /// + public partial class AIProjectAgentsOperations + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + internal PipelineMessage CreateGetAgentRequest(string agentName, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/agents/", false); + uri.AppendPath(agentName, true); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateCreateAgentRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/agents", false); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Headers.Set("Accept", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal PipelineMessage CreateUpdateAgentRequest(string agentName, BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/agents/", false); + uri.AppendPath(agentName, true); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Headers.Set("Accept", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal PipelineMessage CreateCreateAgentFromManifestRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/agents:import", false); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Headers.Set("Accept", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal PipelineMessage CreateUpdateAgentFromManifestRequest(string agentName, BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/agents/", false); + uri.AppendPath(agentName, true); + uri.AppendPath("/import", false); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Headers.Set("Accept", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal PipelineMessage CreateDeleteAgentRequest(string agentName, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/agents/", false); + uri.AppendPath(agentName, true); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "DELETE", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateGetAgentsRequest(string kind, int? limit, string order, string after, string before, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/agents", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (kind != null) + { + uri.AppendQuery("kind", kind, true); + } + if (limit != null) + { + uri.AppendQuery("limit", TypeFormatters.ConvertToString(limit), true); + } + if (order != null) + { + uri.AppendQuery("order", order, true); + } + if (after != null) + { + uri.AppendQuery("after", after, true); + } + if (before != null) + { + uri.AppendQuery("before", before, true); + } + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateCreateAgentVersionRequest(string agentName, BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/agents/", false); + uri.AppendPath(agentName, true); + uri.AppendPath("/versions", false); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Headers.Set("Accept", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal PipelineMessage CreateCreateAgentVersionFromManifestRequest(string agentName, BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/agents/", false); + uri.AppendPath(agentName, true); + uri.AppendPath("/versions:import", false); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Headers.Set("Accept", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal PipelineMessage CreateGetAgentVersionRequest(string agentName, string agentVersion, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/agents/", false); + uri.AppendPath(agentName, true); + uri.AppendPath("/versions/", false); + uri.AppendPath(agentVersion, true); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateDeleteAgentVersionRequest(string agentName, string agentVersion, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/agents/", false); + uri.AppendPath(agentName, true); + uri.AppendPath("/versions/", false); + uri.AppendPath(agentVersion, true); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "DELETE", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateGetAgentVersionsRequest(string agentName, int? limit, string order, string after, string before, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/agents/", false); + uri.AppendPath(agentName, true); + uri.AppendPath("/versions", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (limit != null) + { + uri.AppendQuery("limit", TypeFormatters.ConvertToString(limit), true); + } + if (order != null) + { + uri.AppendQuery("order", order, true); + } + if (after != null) + { + uri.AppendQuery("after", after, true); + } + if (before != null) + { + uri.AppendQuery("before", before, true); + } + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectAgentsOperations.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectAgentsOperations.cs new file mode 100644 index 000000000000..72a8eb58cb7b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectAgentsOperations.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; + +namespace Azure.AI.Projects +{ + /// The AIProjectAgentsOperations sub-client. + public partial class AIProjectAgentsOperations + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of AIProjectAgentsOperations for mocking. + protected AIProjectAgentsOperations() + { + } + + /// Initializes a new instance of AIProjectAgentsOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal AIProjectAgentsOperations(ClientPipeline pipeline, Uri endpoint, string apiVersion) + { + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectBlobReference.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectBlobReference.cs index 13e8b792b4a7..d99887a14ce7 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectBlobReference.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectBlobReference.cs @@ -14,7 +14,7 @@ public partial class AIProjectBlobReference private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . - /// Blob URI path for client to upload data. Example: https://blob.windows.core.net/Container/Path. + /// Blob URI path for client to upload data. Example: `https://blob.windows.core.net/Container/Path`. /// ARM ID of the storage account to use. /// Credential info to access the storage account. internal AIProjectBlobReference(Uri blobUri, string storageAccountArmId, BlobReferenceSasCredential credential) @@ -25,7 +25,7 @@ internal AIProjectBlobReference(Uri blobUri, string storageAccountArmId, BlobRef } /// Initializes a new instance of . - /// Blob URI path for client to upload data. Example: https://blob.windows.core.net/Container/Path. + /// Blob URI path for client to upload data. Example: `https://blob.windows.core.net/Container/Path`. /// ARM ID of the storage account to use. /// Credential info to access the storage account. /// Keeps track of any properties unknown to the library. diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectClient.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectClient.cs index 24419d98279f..b709fa2d9411 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectClient.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectClient.cs @@ -29,6 +29,14 @@ public partial class AIProjectClient : ClientConnectionProvider private AIProjectDatasetsOperations _cachedAIProjectDatasetsOperations; private AIProjectIndexesOperations _cachedAIProjectIndexesOperations; private AIProjectDeploymentsOperations _cachedAIProjectDeploymentsOperations; + private RedTeams _cachedRedTeams; + private EvaluationRules _cachedEvaluationRules; + private EvaluationTaxonomies _cachedEvaluationTaxonomies; + private Evaluators _cachedEvaluators; + private Insights _cachedInsights; + private Schedules _cachedSchedules; + private AIProjectAgentsOperations _cachedAIProjectAgentsOperations; + private AIProjectMemoryStoresOperations _cachedAIProjectMemoryStoresOperations; /// The HTTP pipeline for sending and receiving REST requests and responses. public ClientPipeline Pipeline { get; } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectClientOptions.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectClientOptions.cs index ec4b39123e26..678f0b831ed6 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectClientOptions.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectClientOptions.cs @@ -10,7 +10,7 @@ namespace Azure.AI.Projects /// Client options for . public partial class AIProjectClientOptions : ClientPipelineOptions { - private const ServiceVersion LatestVersion = ServiceVersion.V1; + private const ServiceVersion LatestVersion = ServiceVersion.V2025_11_15_Preview; /// Initializes a new instance of AIProjectClientOptions. /// The service version. @@ -20,6 +20,8 @@ public AIProjectClientOptions(ServiceVersion version = LatestVersion) { ServiceVersion.V2025_05_01 => "2025-05-01", ServiceVersion.V1 => "v1", + ServiceVersion.V2025_05_15_Preview => "2025-05-15-preview", + ServiceVersion.V2025_11_15_Preview => "2025-11-15-preview", _ => throw new NotSupportedException() }; } @@ -33,7 +35,11 @@ public enum ServiceVersion /// Azure AI API version 2025-05-01. V2025_05_01 = 1, /// Azure AI API version v1. - V1 = 2 + V1 = 2, + /// Azure AI API version 2025-05-15-preview. + V2025_05_15_Preview = 3, + /// Azure AI API version 2025-11-15-preview. + V2025_11_15_Preview = 4 } } } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectConnectionBaseCredential.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectConnectionBaseCredential.Serialization.cs index 5ca543a7f04c..8ad42ed08e9e 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectConnectionBaseCredential.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectConnectionBaseCredential.Serialization.cs @@ -10,7 +10,7 @@ namespace Azure.AI.Projects { /// /// A base class for connection credentials - /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , , and . + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , , , and . /// [PersistableModelProxy(typeof(UnknownAIProjectConnectionBaseCredential))] public abstract partial class AIProjectConnectionBaseCredential : IJsonModel @@ -94,6 +94,8 @@ internal static AIProjectConnectionBaseCredential DeserializeAIProjectConnection return AIProjectConnectionSasCredential.DeserializeAIProjectConnectionSasCredential(element, options); case "None": return NoAuthenticationCredentials.DeserializeNoAuthenticationCredentials(element, options); + case "AgenticIdentityToken": + return AgenticIdentityCredentials.DeserializeAgenticIdentityCredentials(element, options); } } return UnknownAIProjectConnectionBaseCredential.DeserializeUnknownAIProjectConnectionBaseCredential(element, options); diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectConnectionBaseCredential.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectConnectionBaseCredential.cs index dfe6f4852d14..32c8e239519c 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectConnectionBaseCredential.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectConnectionBaseCredential.cs @@ -9,7 +9,7 @@ namespace Azure.AI.Projects { /// /// A base class for connection credentials - /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , , and . + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , , , and . /// public abstract partial class AIProjectConnectionBaseCredential { diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectDataset.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectDataset.cs index dc6f81de9374..1f48b7f81366 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectDataset.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectDataset.cs @@ -17,7 +17,7 @@ public abstract partial class AIProjectDataset private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . - /// URI of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// URI of the data ([example](https://go.microsoft.com/fwlink/?linkid=2202330)). /// Dataset type. private protected AIProjectDataset(Uri dataUri, DatasetType @type) { @@ -27,7 +27,7 @@ private protected AIProjectDataset(Uri dataUri, DatasetType @type) } /// Initializes a new instance of . - /// URI of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// URI of the data ([example](https://go.microsoft.com/fwlink/?linkid=2202330)). /// Dataset type. /// Indicates if the dataset holds a reference to the storage, or the dataset manages storage itself. If true, the underlying data will not be deleted when the dataset version is deleted. /// The Azure Storage Account connection name. Required if startPendingUploadVersion was not called before creating the Dataset. diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectMemoryStoresOperations.RestClient.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectMemoryStoresOperations.RestClient.cs new file mode 100644 index 000000000000..0e9ea4793b2f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectMemoryStoresOperations.RestClient.cs @@ -0,0 +1,175 @@ +// + +#nullable disable + +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace Azure.AI.Projects +{ + /// + public partial class AIProjectMemoryStoresOperations + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier202; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier202 => _pipelineMessageClassifier202 = PipelineMessageClassifier.Create(stackalloc ushort[] { 202 }); + + internal PipelineMessage CreateCreateMemoryStoreRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/memory_stores", false); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Headers.Set("Accept", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal PipelineMessage CreateUpdateMemoryStoreRequest(string name, BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/memory_stores/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Headers.Set("Accept", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal PipelineMessage CreateGetMemoryStoreRequest(string name, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/memory_stores/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateGetMemoryStoresRequest(int? limit, string order, string after, string before, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/memory_stores", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (limit != null) + { + uri.AppendQuery("limit", TypeFormatters.ConvertToString(limit), true); + } + if (order != null) + { + uri.AppendQuery("order", order, true); + } + if (after != null) + { + uri.AppendQuery("after", after, true); + } + if (before != null) + { + uri.AppendQuery("before", before, true); + } + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateDeleteMemoryStoreRequest(string name, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/memory_stores/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "DELETE", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateSearchMemoriesRequest(string name, BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/memory_stores/", false); + uri.AppendPath(name, true); + uri.AppendPath(":search_memories", false); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Headers.Set("Accept", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal PipelineMessage CreateUpdateMemoriesRequest(string name, BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/memory_stores/", false); + uri.AppendPath(name, true); + uri.AppendPath(":update_memories", false); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier202); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Headers.Set("Accept", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal PipelineMessage CreateGetUpdateResultRequest(string name, string updateId, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/memory_stores/", false); + uri.AppendPath(name, true); + uri.AppendPath("/updates/", false); + uri.AppendPath(updateId, true); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateDeleteScopeRequest(string name, BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/memory_stores/", false); + uri.AppendPath(name, true); + uri.AppendPath(":delete_scope", false); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Headers.Set("Accept", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectMemoryStoresOperations.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectMemoryStoresOperations.cs new file mode 100644 index 000000000000..c1efad65e893 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectMemoryStoresOperations.cs @@ -0,0 +1,603 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace Azure.AI.Projects +{ + /// The AIProjectMemoryStoresOperations sub-client. + public partial class AIProjectMemoryStoresOperations + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of AIProjectMemoryStoresOperations for mocking. + protected AIProjectMemoryStoresOperations() + { + } + + /// Initializes a new instance of AIProjectMemoryStoresOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal AIProjectMemoryStoresOperations(ClientPipeline pipeline, Uri endpoint, string apiVersion) + { + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } + + /// + /// [Protocol Method] Create a memory store. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult CreateMemoryStore(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateCreateMemoryStoreRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Create a memory store. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task CreateMemoryStoreAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateCreateMemoryStoreRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Create a memory store. + /// The name of the memory store. + /// The memory store definition. + /// A human-readable description of the memory store. + /// Arbitrary key-value metadata to associate with the memory store. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult CreateMemoryStore(string name, MemoryStoreDefinition definition, string description = default, IDictionary metadata = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(definition, nameof(definition)); + + InternalCreateMemoryStoreRequest spreadModel = new InternalCreateMemoryStoreRequest(name, description, metadata, definition, default); + ClientResult result = CreateMemoryStore(spreadModel, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((MemoryStore)result, result.GetRawResponse()); + } + + /// Create a memory store. + /// The name of the memory store. + /// The memory store definition. + /// A human-readable description of the memory store. + /// Arbitrary key-value metadata to associate with the memory store. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> CreateMemoryStoreAsync(string name, MemoryStoreDefinition definition, string description = default, IDictionary metadata = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(definition, nameof(definition)); + + InternalCreateMemoryStoreRequest spreadModel = new InternalCreateMemoryStoreRequest(name, description, metadata, definition, default); + ClientResult result = await CreateMemoryStoreAsync(spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((MemoryStore)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] Update a memory store. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the memory store to update. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult UpdateMemoryStore(string name, BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateUpdateMemoryStoreRequest(name, content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Update a memory store. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the memory store to update. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task UpdateMemoryStoreAsync(string name, BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateUpdateMemoryStoreRequest(name, content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Update a memory store. + /// The name of the memory store to update. + /// A human-readable description of the memory store. + /// Arbitrary key-value metadata to associate with the memory store. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult UpdateMemoryStore(string name, string description = default, IDictionary metadata = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + UpdateMemoryStoreRequest spreadModel = new UpdateMemoryStoreRequest(description, metadata, default); + ClientResult result = UpdateMemoryStore(name, spreadModel, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((MemoryStore)result, result.GetRawResponse()); + } + + /// Update a memory store. + /// The name of the memory store to update. + /// A human-readable description of the memory store. + /// Arbitrary key-value metadata to associate with the memory store. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> UpdateMemoryStoreAsync(string name, string description = default, IDictionary metadata = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + UpdateMemoryStoreRequest spreadModel = new UpdateMemoryStoreRequest(description, metadata, default); + ClientResult result = await UpdateMemoryStoreAsync(name, spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((MemoryStore)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] Retrieve a memory store. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the memory store to retrieve. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult GetMemoryStore(string name, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using PipelineMessage message = CreateGetMemoryStoreRequest(name, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Retrieve a memory store. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the memory store to retrieve. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetMemoryStoreAsync(string name, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using PipelineMessage message = CreateGetMemoryStoreRequest(name, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Retrieve a memory store. + /// The name of the memory store to retrieve. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult GetMemoryStore(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + ClientResult result = GetMemoryStore(name, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((MemoryStore)result, result.GetRawResponse()); + } + + /// Retrieve a memory store. + /// The name of the memory store to retrieve. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> GetMemoryStoreAsync(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + ClientResult result = await GetMemoryStoreAsync(name, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((MemoryStore)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] Delete a memory store. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the memory store to delete. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult DeleteMemoryStore(string name, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using PipelineMessage message = CreateDeleteMemoryStoreRequest(name, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Delete a memory store. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the memory store to delete. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task DeleteMemoryStoreAsync(string name, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using PipelineMessage message = CreateDeleteMemoryStoreRequest(name, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Delete a memory store. + /// The name of the memory store to delete. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult DeleteMemoryStore(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + ClientResult result = DeleteMemoryStore(name, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((DeleteMemoryStoreResponse)result, result.GetRawResponse()); + } + + /// Delete a memory store. + /// The name of the memory store to delete. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> DeleteMemoryStoreAsync(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + ClientResult result = await DeleteMemoryStoreAsync(name, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((DeleteMemoryStoreResponse)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] Search for relevant memories from a memory store based on conversation context. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the memory store to search. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult SearchMemories(string name, BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateSearchMemoriesRequest(name, content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Search for relevant memories from a memory store based on conversation context. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the memory store to search. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task SearchMemoriesAsync(string name, BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateSearchMemoriesRequest(name, content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// + /// [Protocol Method] Update memory store with conversation memories. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the memory store to update. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult UpdateMemories(string name, BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateUpdateMemoriesRequest(name, content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Update memory store with conversation memories. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the memory store to update. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task UpdateMemoriesAsync(string name, BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateUpdateMemoriesRequest(name, content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// + /// [Protocol Method] Get memory store update result. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the memory store. + /// The ID of the memory update operation. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult GetUpdateResult(string name, string updateId, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(updateId, nameof(updateId)); + + using PipelineMessage message = CreateGetUpdateResultRequest(name, updateId, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Get memory store update result. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the memory store. + /// The ID of the memory update operation. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetUpdateResultAsync(string name, string updateId, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(updateId, nameof(updateId)); + + using PipelineMessage message = CreateGetUpdateResultRequest(name, updateId, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Get memory store update result. + /// The name of the memory store. + /// The ID of the memory update operation. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult GetUpdateResult(string name, string updateId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(updateId, nameof(updateId)); + + ClientResult result = GetUpdateResult(name, updateId, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((MemoryUpdateResult)result, result.GetRawResponse()); + } + + /// Get memory store update result. + /// The name of the memory store. + /// The ID of the memory update operation. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> GetUpdateResultAsync(string name, string updateId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(updateId, nameof(updateId)); + + ClientResult result = await GetUpdateResultAsync(name, updateId, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((MemoryUpdateResult)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] Delete all memories associated with a specific scope from a memory store. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the memory store. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult DeleteScope(string name, BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateDeleteScopeRequest(name, content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Delete all memories associated with a specific scope from a memory store. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the memory store. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task DeleteScopeAsync(string name, BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateDeleteScopeRequest(name, content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Delete all memories associated with a specific scope from a memory store. + /// The name of the memory store. + /// The namespace that logically groups and isolates memories to delete, such as a user ID. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult DeleteScope(string name, string scope, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(scope, nameof(scope)); + + DeleteScopeRequest spreadModel = new DeleteScopeRequest(scope, default); + ClientResult result = DeleteScope(name, spreadModel, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((MemoryStoreDeleteScopeResponse)result, result.GetRawResponse()); + } + + /// Delete all memories associated with a specific scope from a memory store. + /// The name of the memory store. + /// The namespace that logically groups and isolates memories to delete, such as a user ID. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> DeleteScopeAsync(string name, string scope, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(scope, nameof(scope)); + + DeleteScopeRequest spreadModel = new DeleteScopeRequest(scope, default); + ClientResult result = await DeleteScopeAsync(name, spreadModel, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((MemoryStoreDeleteScopeResponse)result, result.GetRawResponse()); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AISearchIndexResource.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AISearchIndexResource.Serialization.cs new file mode 100644 index 000000000000..b985498d2d16 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AISearchIndexResource.Serialization.cs @@ -0,0 +1,207 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// A AI Search Index resource. + internal partial class AISearchIndexResource : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AISearchIndexResource)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(ProjectConnectionId)) + { + writer.WritePropertyName("project_connection_id"u8); + writer.WriteStringValue(ProjectConnectionId); + } + if (Optional.IsDefined(IndexName)) + { + writer.WritePropertyName("index_name"u8); + writer.WriteStringValue(IndexName); + } + if (Optional.IsDefined(QueryType)) + { + writer.WritePropertyName("query_type"u8); + writer.WriteStringValue(QueryType.Value.ToString()); + } + if (Optional.IsDefined(TopK)) + { + writer.WritePropertyName("top_k"u8); + writer.WriteNumberValue(TopK.Value); + } + if (Optional.IsDefined(Filter)) + { + writer.WritePropertyName("filter"u8); + writer.WriteStringValue(Filter); + } + if (Optional.IsDefined(IndexAssetId)) + { + writer.WritePropertyName("index_asset_id"u8); + writer.WriteStringValue(IndexAssetId); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AISearchIndexResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AISearchIndexResource JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AISearchIndexResource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAISearchIndexResource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AISearchIndexResource DeserializeAISearchIndexResource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string projectConnectionId = default; + string indexName = default; + AzureAISearchQueryType? queryType = default; + int? topK = default; + string filter = default; + string indexAssetId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("project_connection_id"u8)) + { + projectConnectionId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("index_name"u8)) + { + indexName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("query_type"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + queryType = new AzureAISearchQueryType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("top_k"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + topK = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("filter"u8)) + { + filter = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("index_asset_id"u8)) + { + indexAssetId = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AISearchIndexResource( + projectConnectionId, + indexName, + queryType, + topK, + filter, + indexAssetId, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(AISearchIndexResource)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AISearchIndexResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AISearchIndexResource PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAISearchIndexResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AISearchIndexResource)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AISearchIndexResource.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AISearchIndexResource.cs new file mode 100644 index 000000000000..0ee15d8e885c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AISearchIndexResource.cs @@ -0,0 +1,58 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// A AI Search Index resource. + internal partial class AISearchIndexResource + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public AISearchIndexResource() + { + } + + /// Initializes a new instance of . + /// An index connection ID in an IndexResource attached to this agent. + /// The name of an index in an IndexResource attached to this agent. + /// Type of query in an AIIndexResource attached to this agent. + /// Number of documents to retrieve from search and present to the model. + /// filter string for search resource. [Learn more here](https://learn.microsoft.com/azure/search/search-filters). + /// Index asset id for search resource. + /// Keeps track of any properties unknown to the library. + internal AISearchIndexResource(string projectConnectionId, string indexName, AzureAISearchQueryType? queryType, int? topK, string filter, string indexAssetId, IDictionary additionalBinaryDataProperties) + { + ProjectConnectionId = projectConnectionId; + IndexName = indexName; + QueryType = queryType; + TopK = topK; + Filter = filter; + IndexAssetId = indexAssetId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// An index connection ID in an IndexResource attached to this agent. + public string ProjectConnectionId { get; set; } + + /// The name of an index in an IndexResource attached to this agent. + public string IndexName { get; set; } + + /// Type of query in an AIIndexResource attached to this agent. + public AzureAISearchQueryType? QueryType { get; set; } + + /// Number of documents to retrieve from search and present to the model. + public int? TopK { get; set; } + + /// filter string for search resource. [Learn more here](https://learn.microsoft.com/azure/search/search-filters). + public string Filter { get; set; } + + /// Index asset id for search resource. + public string IndexAssetId { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentClusterInsightResult.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentClusterInsightResult.Serialization.cs new file mode 100644 index 000000000000..a16334d3db1c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentClusterInsightResult.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Insights from the agent cluster analysis. + public partial class AgentClusterInsightResult : InsightResult, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AgentClusterInsightResult() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentClusterInsightResult)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("clusterInsight"u8); + writer.WriteObjectValue(ClusterInsight, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentClusterInsightResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AgentClusterInsightResult)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InsightResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentClusterInsightResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentClusterInsightResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AgentClusterInsightResult DeserializeAgentClusterInsightResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InsightType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ClusterInsightResult clusterInsight = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InsightType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("clusterInsight"u8)) + { + clusterInsight = ClusterInsightResult.DeserializeClusterInsightResult(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AgentClusterInsightResult(@type, additionalBinaryDataProperties, clusterInsight); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(AgentClusterInsightResult)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AgentClusterInsightResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AgentClusterInsightResult)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InsightResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentClusterInsightResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentClusterInsightResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentClusterInsightResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentClusterInsightResult.cs new file mode 100644 index 000000000000..6b82ffc3f2cb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentClusterInsightResult.cs @@ -0,0 +1,32 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Insights from the agent cluster analysis. + public partial class AgentClusterInsightResult : InsightResult + { + /// Initializes a new instance of . + /// + internal AgentClusterInsightResult(ClusterInsightResult clusterInsight) : base(InsightType.AgentClusterInsight) + { + ClusterInsight = clusterInsight; + } + + /// Initializes a new instance of . + /// The type of insights result. + /// Keeps track of any properties unknown to the library. + /// + internal AgentClusterInsightResult(InsightType @type, IDictionary additionalBinaryDataProperties, ClusterInsightResult clusterInsight) : base(@type, additionalBinaryDataProperties) + { + ClusterInsight = clusterInsight; + } + + /// Gets the ClusterInsight. + public ClusterInsightResult ClusterInsight { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentClusterInsightsRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentClusterInsightsRequest.Serialization.cs new file mode 100644 index 000000000000..3fa3c3c24cbd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentClusterInsightsRequest.Serialization.cs @@ -0,0 +1,146 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Insights on set of Agent Evaluation Results. + public partial class AgentClusterInsightsRequest : InsightRequest, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AgentClusterInsightsRequest() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentClusterInsightsRequest)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("agentName"u8); + writer.WriteStringValue(AgentName); + if (Optional.IsDefined(ModelConfiguration)) + { + writer.WritePropertyName("modelConfiguration"u8); + writer.WriteObjectValue(ModelConfiguration, options); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentClusterInsightsRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AgentClusterInsightsRequest)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InsightRequest JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentClusterInsightsRequest)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentClusterInsightsRequest(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AgentClusterInsightsRequest DeserializeAgentClusterInsightsRequest(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InsightType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string agentName = default; + InsightModelConfiguration modelConfiguration = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InsightType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("agentName"u8)) + { + agentName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("modelConfiguration"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + modelConfiguration = InsightModelConfiguration.DeserializeInsightModelConfiguration(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AgentClusterInsightsRequest(@type, additionalBinaryDataProperties, agentName, modelConfiguration); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(AgentClusterInsightsRequest)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AgentClusterInsightsRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AgentClusterInsightsRequest)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InsightRequest PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentClusterInsightsRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentClusterInsightsRequest)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentClusterInsightsRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentClusterInsightsRequest.cs new file mode 100644 index 000000000000..5b06e62bef30 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentClusterInsightsRequest.cs @@ -0,0 +1,40 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Insights on set of Agent Evaluation Results. + public partial class AgentClusterInsightsRequest : InsightRequest + { + /// Initializes a new instance of . + /// Identifier for the agent. + /// is null. + public AgentClusterInsightsRequest(string agentName) : base(InsightType.AgentClusterInsight) + { + Argument.AssertNotNull(agentName, nameof(agentName)); + + AgentName = agentName; + } + + /// Initializes a new instance of . + /// The type of request. + /// Keeps track of any properties unknown to the library. + /// Identifier for the agent. + /// Configuration of the model used in the insight generation. + internal AgentClusterInsightsRequest(InsightType @type, IDictionary additionalBinaryDataProperties, string agentName, InsightModelConfiguration modelConfiguration) : base(@type, additionalBinaryDataProperties) + { + AgentName = agentName; + ModelConfiguration = modelConfiguration; + } + + /// Identifier for the agent. + public string AgentName { get; set; } + + /// Configuration of the model used in the insight generation. + public InsightModelConfiguration ModelConfiguration { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentKind.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentKind.cs new file mode 100644 index 000000000000..b3cbe258f83b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentKind.cs @@ -0,0 +1,73 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// + public readonly partial struct AgentKind : IEquatable + { + private readonly string _value; + private const string PromptValue = "prompt"; + private const string HostedValue = "hosted"; + private const string ContainerAppValue = "container_app"; + private const string WorkflowValue = "workflow"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public AgentKind(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Prompt. + public static AgentKind Prompt { get; } = new AgentKind(PromptValue); + + /// Gets the Hosted. + public static AgentKind Hosted { get; } = new AgentKind(HostedValue); + + /// Gets the ContainerApp. + public static AgentKind ContainerApp { get; } = new AgentKind(ContainerAppValue); + + /// Gets the Workflow. + public static AgentKind Workflow { get; } = new AgentKind(WorkflowValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(AgentKind left, AgentKind right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(AgentKind left, AgentKind right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator AgentKind(string value) => new AgentKind(value); + + /// Converts a string to a . + /// The value. + public static implicit operator AgentKind?(string value) => value == null ? null : new AgentKind(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AgentKind other && Equals(other); + + /// + public bool Equals(AgentKind other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentListOrder.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentListOrder.cs new file mode 100644 index 000000000000..d06c4c7d6f0c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentListOrder.cs @@ -0,0 +1,59 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// + public readonly partial struct AgentListOrder : IEquatable + { + private readonly string _value; + private const string AscValue = "asc"; + private const string DescValue = "desc"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public AgentListOrder(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(AgentListOrder left, AgentListOrder right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(AgentListOrder left, AgentListOrder right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator AgentListOrder(string value) => new AgentListOrder(value); + + /// Converts a string to a . + /// The value. + public static implicit operator AgentListOrder?(string value) => value == null ? null : new AgentListOrder(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AgentListOrder other && Equals(other); + + /// + public bool Equals(AgentListOrder other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentManifestOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentManifestOptions.Serialization.cs new file mode 100644 index 000000000000..23ff7b795ed8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentManifestOptions.Serialization.cs @@ -0,0 +1,237 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The AgentManifestOptions. + public partial class AgentManifestOptions : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AgentManifestOptions() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentManifestOptions)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("manifest_id"u8); + writer.WriteStringValue(ManifestId); + writer.WritePropertyName("parameter_values"u8); + writer.WriteStartObject(); + foreach (var item in ParameterValues) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#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(); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentManifestOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AgentManifestOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentManifestOptions)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentManifestOptions(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AgentManifestOptions DeserializeAgentManifestOptions(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary metadata = default; + string description = default; + string manifestId = default; + IDictionary parameterValues = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("metadata"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + metadata = dictionary; + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("manifest_id"u8)) + { + manifestId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("parameter_values"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + parameterValues = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AgentManifestOptions(metadata ?? new ChangeTrackingDictionary(), description, manifestId, parameterValues, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(AgentManifestOptions)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AgentManifestOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AgentManifestOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentManifestOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentManifestOptions)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(AgentManifestOptions agentManifestOptions) + { + if (agentManifestOptions == null) + { + return null; + } + return BinaryContent.Create(agentManifestOptions, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentManifestOptions.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentManifestOptions.cs new file mode 100644 index 000000000000..a6ac9ff90035 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentManifestOptions.cs @@ -0,0 +1,93 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The AgentManifestOptions. + public partial class AgentManifestOptions + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The manifest ID to import the agent version from. + /// The inputs to the manifest that will result in a fully materialized Agent. + internal AgentManifestOptions(string manifestId, IDictionary parameterValues) + { + Metadata = new ChangeTrackingDictionary(); + ManifestId = manifestId; + ParameterValues = parameterValues; + } + + /// Initializes a new instance of . + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + /// A human-readable description of the agent. + /// The manifest ID to import the agent version from. + /// The inputs to the manifest that will result in a fully materialized Agent. + /// Keeps track of any properties unknown to the library. + internal AgentManifestOptions(IDictionary metadata, string description, string manifestId, IDictionary parameterValues, IDictionary additionalBinaryDataProperties) + { + Metadata = metadata; + Description = description; + ManifestId = manifestId; + ParameterValues = parameterValues; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + public IDictionary Metadata { get; } + + /// A human-readable description of the agent. + public string Description { get; } + + /// The manifest ID to import the agent version from. + public string ManifestId { get; } + + /// + /// The inputs to the manifest that will result in a fully materialized Agent. + /// 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" }. + /// + /// + /// + /// + public IDictionary ParameterValues { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentObjectVersions.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentObjectVersions.Serialization.cs new file mode 100644 index 000000000000..84458581c27a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentObjectVersions.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The AgentObjectVersions. + internal partial class AgentObjectVersions : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AgentObjectVersions() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentObjectVersions)} does not support writing '{format}' format."); + } + writer.WritePropertyName("latest"u8); + writer.WriteObjectValue(Latest, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentObjectVersions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AgentObjectVersions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentObjectVersions)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentObjectVersions(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AgentObjectVersions DeserializeAgentObjectVersions(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalAgentVersionObject latest = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("latest"u8)) + { + latest = InternalAgentVersionObject.DeserializeInternalAgentVersionObject(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AgentObjectVersions(latest, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(AgentObjectVersions)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AgentObjectVersions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AgentObjectVersions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentObjectVersions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentObjectVersions)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentObjectVersions.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentObjectVersions.cs new file mode 100644 index 000000000000..ca196da2fc41 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentObjectVersions.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// The AgentObjectVersions. + internal partial class AgentObjectVersions + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + internal AgentObjectVersions(InternalAgentVersionObject latest) + { + Latest = latest; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal AgentObjectVersions(InternalAgentVersionObject latest, IDictionary additionalBinaryDataProperties) + { + Latest = latest; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Latest. + public InternalAgentVersionObject Latest { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentTaxonomyInput.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentTaxonomyInput.Serialization.cs new file mode 100644 index 000000000000..50d09ccc1cde --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentTaxonomyInput.Serialization.cs @@ -0,0 +1,149 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Input configuration for the evaluation taxonomy when the input type is agent. + public partial class AgentTaxonomyInput : EvaluationTaxonomyInput, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AgentTaxonomyInput() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentTaxonomyInput)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("target"u8); + writer.WriteObjectValue(Target, options); + writer.WritePropertyName("riskCategories"u8); + writer.WriteStartArray(); + foreach (RiskCategory item in RiskCategories) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentTaxonomyInput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AgentTaxonomyInput)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override EvaluationTaxonomyInput JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentTaxonomyInput)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentTaxonomyInput(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AgentTaxonomyInput DeserializeAgentTaxonomyInput(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + EvaluationTaxonomyInputType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + AzureAIAgentTarget target = default; + IList riskCategories = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new EvaluationTaxonomyInputType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("target"u8)) + { + target = AzureAIAgentTarget.DeserializeAzureAIAgentTarget(prop.Value, options); + continue; + } + if (prop.NameEquals("riskCategories"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(new RiskCategory(item.GetString())); + } + riskCategories = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AgentTaxonomyInput(@type, additionalBinaryDataProperties, target, riskCategories); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(AgentTaxonomyInput)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AgentTaxonomyInput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AgentTaxonomyInput)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override EvaluationTaxonomyInput PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentTaxonomyInput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentTaxonomyInput)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentTaxonomyInput.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentTaxonomyInput.cs new file mode 100644 index 000000000000..d96fa80fc5c7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentTaxonomyInput.cs @@ -0,0 +1,44 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects +{ + /// Input configuration for the evaluation taxonomy when the input type is agent. + public partial class AgentTaxonomyInput : EvaluationTaxonomyInput + { + /// Initializes a new instance of . + /// Target configuration for the agent. + /// List of risk categories to evaluate against. + /// or is null. + public AgentTaxonomyInput(AzureAIAgentTarget target, IEnumerable riskCategories) : base(EvaluationTaxonomyInputType.Agent) + { + Argument.AssertNotNull(target, nameof(target)); + Argument.AssertNotNull(riskCategories, nameof(riskCategories)); + + Target = target; + RiskCategories = riskCategories.ToList(); + } + + /// Initializes a new instance of . + /// Input type of the evaluation taxonomy. + /// Keeps track of any properties unknown to the library. + /// Target configuration for the agent. + /// List of risk categories to evaluate against. + internal AgentTaxonomyInput(EvaluationTaxonomyInputType @type, IDictionary additionalBinaryDataProperties, AzureAIAgentTarget target, IList riskCategories) : base(@type, additionalBinaryDataProperties) + { + Target = target; + RiskCategories = riskCategories; + } + + /// Target configuration for the agent. + public AzureAIAgentTarget Target { get; set; } + + /// List of risk categories to evaluate against. + public IList RiskCategories { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentVersionCreationOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentVersionCreationOptions.Serialization.cs new file mode 100644 index 000000000000..58721aafaca7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentVersionCreationOptions.Serialization.cs @@ -0,0 +1,188 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The AgentVersionCreationOptions. + public partial class AgentVersionCreationOptions : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AgentVersionCreationOptions() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentVersionCreationOptions)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("definition"u8); + writer.WriteObjectValue(Definition, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgentVersionCreationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AgentVersionCreationOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgentVersionCreationOptions)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgentVersionCreationOptions(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AgentVersionCreationOptions DeserializeAgentVersionCreationOptions(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary metadata = default; + string description = default; + Projects.OpenAI.AgentDefinition definition = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("metadata"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + metadata = dictionary; + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("definition"u8)) + { + DeserializeDefinitionValue(prop, ref definition); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AgentVersionCreationOptions(metadata ?? new ChangeTrackingDictionary(), description, definition, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(AgentVersionCreationOptions)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AgentVersionCreationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AgentVersionCreationOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgentVersionCreationOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgentVersionCreationOptions)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentVersionCreationOptions.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentVersionCreationOptions.cs new file mode 100644 index 000000000000..e338f46efa84 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentVersionCreationOptions.cs @@ -0,0 +1,57 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// The AgentVersionCreationOptions. + public partial class AgentVersionCreationOptions + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The agent definition. This can be a workflow, hosted agent, or a simple agent definition. + /// is null. + public AgentVersionCreationOptions(Projects.OpenAI.AgentDefinition definition) + { + Argument.AssertNotNull(definition, nameof(definition)); + + Metadata = new ChangeTrackingDictionary(); + Definition = definition; + } + + /// Initializes a new instance of . + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + /// A human-readable description of the agent. + /// The agent definition. This can be a workflow, hosted agent, or a simple agent definition. + /// Keeps track of any properties unknown to the library. + internal AgentVersionCreationOptions(IDictionary metadata, string description, Projects.OpenAI.AgentDefinition definition, IDictionary additionalBinaryDataProperties) + { + Metadata = metadata; + Description = description; + Definition = definition; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + public IDictionary Metadata { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgenticIdentityCredentials.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgenticIdentityCredentials.Serialization.cs new file mode 100644 index 000000000000..25e9ef9915a2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgenticIdentityCredentials.Serialization.cs @@ -0,0 +1,118 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Agentic identity credential definition. + public partial class AgenticIdentityCredentials : AIProjectConnectionBaseCredential, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgenticIdentityCredentials)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + AgenticIdentityCredentials IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AgenticIdentityCredentials)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override AIProjectConnectionBaseCredential JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AgenticIdentityCredentials)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAgenticIdentityCredentials(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AgenticIdentityCredentials DeserializeAgenticIdentityCredentials(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CredentialType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new CredentialType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AgenticIdentityCredentials(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(AgenticIdentityCredentials)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AgenticIdentityCredentials IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AgenticIdentityCredentials)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override AIProjectConnectionBaseCredential PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAgenticIdentityCredentials(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AgenticIdentityCredentials)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgenticIdentityCredentials.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgenticIdentityCredentials.cs new file mode 100644 index 000000000000..158701dbdce3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgenticIdentityCredentials.cs @@ -0,0 +1,25 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Agentic identity credential definition. + public partial class AgenticIdentityCredentials : AIProjectConnectionBaseCredential + { + /// Initializes a new instance of . + internal AgenticIdentityCredentials() + { + } + + /// Initializes a new instance of . + /// The type of credential used by the connection. + /// Keeps track of any properties unknown to the library. + internal AgenticIdentityCredentials(CredentialType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AnnotationType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AnnotationType.cs new file mode 100644 index 000000000000..30ac37107fb5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AnnotationType.cs @@ -0,0 +1,74 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects; + +namespace OpenAI +{ + /// + internal readonly partial struct AnnotationType : IEquatable + { + private readonly string _value; + private const string FileCitationValue = "file_citation"; + private const string UrlCitationValue = "url_citation"; + private const string FilePathValue = "file_path"; + private const string ContainerFileCitationValue = "container_file_citation"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public AnnotationType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the FileCitation. + public static AnnotationType FileCitation { get; } = new AnnotationType(FileCitationValue); + + /// Gets the UrlCitation. + public static AnnotationType UrlCitation { get; } = new AnnotationType(UrlCitationValue); + + /// Gets the FilePath. + public static AnnotationType FilePath { get; } = new AnnotationType(FilePathValue); + + /// Gets the ContainerFileCitation. + public static AnnotationType ContainerFileCitation { get; } = new AnnotationType(ContainerFileCitationValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(AnnotationType left, AnnotationType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(AnnotationType left, AnnotationType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator AnnotationType(string value) => new AnnotationType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator AnnotationType?(string value) => value == null ? null : new AnnotationType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AnnotationType other && Equals(other); + + /// + public bool Equals(AnnotationType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AttackStrategy.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AttackStrategy.cs new file mode 100644 index 000000000000..9060e4b0d011 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AttackStrategy.cs @@ -0,0 +1,197 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// Strategies for attacks. + public readonly partial struct AttackStrategy : IEquatable + { + private readonly string _value; + /// Represents a default set of easy complexity attacks. Easy complexity attacks require less effort, such as translation of a prompt into some encoding, and does not require any Large Language Model to convert or orchestrate. + private const string EasyValue = "easy"; + /// Represents a default set of moderate complexity attacks. Moderate complexity attacks require having access to resources such as another generative AI model. + private const string ModerateValue = "moderate"; + /// Represents a default set of difficult complexity attacks. Difficult complexity attacks include attacks that require access to significant resources and effort to execute an attack such as knowledge of search-based algorithms in addition to a generative AI model. + private const string DifficultValue = "difficult"; + /// Generates visual art using ASCII characters, often used for creative or obfuscation purposes. + private const string AsciiArtValue = "ascii_art"; + /// Conceals data within ASCII characters, making it harder to detect. + private const string AsciiSmugglerValue = "ascii_smuggler"; + /// Implements the Atbash cipher, a simple substitution cipher where each letter is mapped to its reverse. + private const string AtbashValue = "atbash"; + /// Encodes binary data into a text format using Base64, commonly used for data transmission. + private const string Base64Value = "base64"; + /// Converts text into binary code, representing data in a series of 0s and 1s. + private const string BinaryValue = "binary"; + /// Applies the Caesar cipher, a substitution cipher that shifts characters by a fixed number of positions. + private const string CaesarValue = "caesar"; + /// Alters text by adding spaces between characters, often used for obfuscation. + private const string CharacterSpaceValue = "character_space"; + /// Injects specially crafted prompts to bypass AI safeguards, known as User Injected Prompt Attacks (UPIA). + private const string JailbreakValue = "jailbreak"; + /// Utilizes ANSI escape sequences to manipulate text appearance and behavior. + private const string AnsiiAttackValue = "ansii_attack"; + /// Swaps characters within text to create variations or obfuscate the original content. + private const string CharacterSwapValue = "character_swap"; + /// Appends an adversarial suffix to the prompt. + private const string SuffixAppendValue = "suffix_append"; + /// Joins multiple strings together, often used for concatenation or obfuscation. + private const string StringJoinValue = "string_join"; + /// Uses Unicode characters that look similar to standard characters, creating visual confusion. + private const string UnicodeConfusableValue = "unicode_confusable"; + /// Substitutes standard characters with Unicode equivalents, often for obfuscation. + private const string UnicodeSubstitutionValue = "unicode_substitution"; + /// Adds diacritical marks to characters, changing their appearance and sometimes their meaning. + private const string DiacriticValue = "diacritic"; + /// Flips characters from front to back, creating a mirrored effect. + private const string FlipValue = "flip"; + /// Transforms text into Leetspeak, a form of encoding that replaces letters with similar-looking numbers or symbols. + private const string LeetspeakValue = "leetspeak"; + /// Applies the ROT13 cipher, a simple substitution cipher that shifts characters by 13 positions. + private const string ROT13Value = "rot13"; + /// Encodes text into Morse code, using dots and dashes to represent characters. + private const string MorseValue = "morse"; + /// Encodes text into URL format. + private const string UrlValue = "url"; + /// Represents the baseline direct adversarial probing, which is used by attack strategies as the attack objective. + private const string BaselineValue = "baseline"; + /// Represents indirect jailbreak attacks that use complex methods to bypass AI safeguards. + private const string IndirectJailbreakValue = "indirect_jailbreak"; + /// Alters the tense of the text, changing its temporal context. + private const string TenseValue = "tense"; + /// Creates multi-turn conversations to simulate extended interactions. + private const string MultiTurnValue = "multi_turn"; + /// Gradually increases the intensity or complexity of the attack over time. + private const string CrescendoValue = "crescendo"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public AttackStrategy(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Represents a default set of easy complexity attacks. Easy complexity attacks require less effort, such as translation of a prompt into some encoding, and does not require any Large Language Model to convert or orchestrate. + public static AttackStrategy Easy { get; } = new AttackStrategy(EasyValue); + + /// Represents a default set of moderate complexity attacks. Moderate complexity attacks require having access to resources such as another generative AI model. + public static AttackStrategy Moderate { get; } = new AttackStrategy(ModerateValue); + + /// Represents a default set of difficult complexity attacks. Difficult complexity attacks include attacks that require access to significant resources and effort to execute an attack such as knowledge of search-based algorithms in addition to a generative AI model. + public static AttackStrategy Difficult { get; } = new AttackStrategy(DifficultValue); + + /// Generates visual art using ASCII characters, often used for creative or obfuscation purposes. + public static AttackStrategy AsciiArt { get; } = new AttackStrategy(AsciiArtValue); + + /// Conceals data within ASCII characters, making it harder to detect. + public static AttackStrategy AsciiSmuggler { get; } = new AttackStrategy(AsciiSmugglerValue); + + /// Implements the Atbash cipher, a simple substitution cipher where each letter is mapped to its reverse. + public static AttackStrategy Atbash { get; } = new AttackStrategy(AtbashValue); + + /// Encodes binary data into a text format using Base64, commonly used for data transmission. + public static AttackStrategy Base64 { get; } = new AttackStrategy(Base64Value); + + /// Converts text into binary code, representing data in a series of 0s and 1s. + public static AttackStrategy Binary { get; } = new AttackStrategy(BinaryValue); + + /// Applies the Caesar cipher, a substitution cipher that shifts characters by a fixed number of positions. + public static AttackStrategy Caesar { get; } = new AttackStrategy(CaesarValue); + + /// Alters text by adding spaces between characters, often used for obfuscation. + public static AttackStrategy CharacterSpace { get; } = new AttackStrategy(CharacterSpaceValue); + + /// Injects specially crafted prompts to bypass AI safeguards, known as User Injected Prompt Attacks (UPIA). + public static AttackStrategy Jailbreak { get; } = new AttackStrategy(JailbreakValue); + + /// Utilizes ANSI escape sequences to manipulate text appearance and behavior. + public static AttackStrategy AnsiiAttack { get; } = new AttackStrategy(AnsiiAttackValue); + + /// Swaps characters within text to create variations or obfuscate the original content. + public static AttackStrategy CharacterSwap { get; } = new AttackStrategy(CharacterSwapValue); + + /// Appends an adversarial suffix to the prompt. + public static AttackStrategy SuffixAppend { get; } = new AttackStrategy(SuffixAppendValue); + + /// Joins multiple strings together, often used for concatenation or obfuscation. + public static AttackStrategy StringJoin { get; } = new AttackStrategy(StringJoinValue); + + /// Uses Unicode characters that look similar to standard characters, creating visual confusion. + public static AttackStrategy UnicodeConfusable { get; } = new AttackStrategy(UnicodeConfusableValue); + + /// Substitutes standard characters with Unicode equivalents, often for obfuscation. + public static AttackStrategy UnicodeSubstitution { get; } = new AttackStrategy(UnicodeSubstitutionValue); + + /// Adds diacritical marks to characters, changing their appearance and sometimes their meaning. + public static AttackStrategy Diacritic { get; } = new AttackStrategy(DiacriticValue); + + /// Flips characters from front to back, creating a mirrored effect. + public static AttackStrategy Flip { get; } = new AttackStrategy(FlipValue); + + /// Transforms text into Leetspeak, a form of encoding that replaces letters with similar-looking numbers or symbols. + public static AttackStrategy Leetspeak { get; } = new AttackStrategy(LeetspeakValue); + + /// Applies the ROT13 cipher, a simple substitution cipher that shifts characters by 13 positions. + public static AttackStrategy ROT13 { get; } = new AttackStrategy(ROT13Value); + + /// Encodes text into Morse code, using dots and dashes to represent characters. + public static AttackStrategy Morse { get; } = new AttackStrategy(MorseValue); + + /// Encodes text into URL format. + public static AttackStrategy Url { get; } = new AttackStrategy(UrlValue); + + /// Represents the baseline direct adversarial probing, which is used by attack strategies as the attack objective. + public static AttackStrategy Baseline { get; } = new AttackStrategy(BaselineValue); + + /// Represents indirect jailbreak attacks that use complex methods to bypass AI safeguards. + public static AttackStrategy IndirectJailbreak { get; } = new AttackStrategy(IndirectJailbreakValue); + + /// Alters the tense of the text, changing its temporal context. + public static AttackStrategy Tense { get; } = new AttackStrategy(TenseValue); + + /// Creates multi-turn conversations to simulate extended interactions. + public static AttackStrategy MultiTurn { get; } = new AttackStrategy(MultiTurnValue); + + /// Gradually increases the intensity or complexity of the attack over time. + public static AttackStrategy Crescendo { get; } = new AttackStrategy(CrescendoValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(AttackStrategy left, AttackStrategy right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(AttackStrategy left, AttackStrategy right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator AttackStrategy(string value) => new AttackStrategy(value); + + /// Converts a string to a . + /// The value. + public static implicit operator AttackStrategy?(string value) => value == null ? null : new AttackStrategy(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AttackStrategy other && Equals(other); + + /// + public bool Equals(AttackStrategy other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureAIAgentTarget.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAIAgentTarget.Serialization.cs new file mode 100644 index 000000000000..5f4a27bacd97 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAIAgentTarget.Serialization.cs @@ -0,0 +1,167 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Represents a target specifying an Azure AI agent. + public partial class AzureAIAgentTarget : Target, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AzureAIAgentTarget() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureAIAgentTarget)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsDefined(Version)) + { + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + } + if (Optional.IsCollectionDefined(ToolDescriptions)) + { + writer.WritePropertyName("tool_descriptions"u8); + writer.WriteStartArray(); + foreach (ToolDescription item in ToolDescriptions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AzureAIAgentTarget IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AzureAIAgentTarget)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override Target JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureAIAgentTarget)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureAIAgentTarget(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureAIAgentTarget DeserializeAzureAIAgentTarget(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = "azure_ai_agent"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string name = default; + string version = default; + IList toolDescriptions = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("version"u8)) + { + version = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("tool_descriptions"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ToolDescription.DeserializeToolDescription(item, options)); + } + toolDescriptions = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureAIAgentTarget(@type, additionalBinaryDataProperties, name, version, toolDescriptions ?? new ChangeTrackingList()); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(AzureAIAgentTarget)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AzureAIAgentTarget IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AzureAIAgentTarget)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override Target PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAzureAIAgentTarget(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureAIAgentTarget)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureAIAgentTarget.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAIAgentTarget.cs new file mode 100644 index 000000000000..1f82b9d01ab5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAIAgentTarget.cs @@ -0,0 +1,46 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Represents a target specifying an Azure AI agent. + public partial class AzureAIAgentTarget : Target + { + /// Initializes a new instance of . + /// The unique identifier of the Azure AI agent. + /// is null. + public AzureAIAgentTarget(string name) : base("azure_ai_agent") + { + Argument.AssertNotNull(name, nameof(name)); + + Name = name; + ToolDescriptions = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The type of target. + /// Keeps track of any properties unknown to the library. + /// The unique identifier of the Azure AI agent. + /// The version of the Azure AI agent. + /// The parameters used to control the sampling behavior of the agent during text generation. + internal AzureAIAgentTarget(string @type, IDictionary additionalBinaryDataProperties, string name, string version, IList toolDescriptions) : base(@type, additionalBinaryDataProperties) + { + Name = name; + Version = version; + ToolDescriptions = toolDescriptions; + } + + /// The unique identifier of the Azure AI agent. + public string Name { get; set; } + + /// The version of the Azure AI agent. + public string Version { get; set; } + + /// The parameters used to control the sampling behavior of the agent during text generation. + public IList ToolDescriptions { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureAIAssistantTarget.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAIAssistantTarget.Serialization.cs new file mode 100644 index 000000000000..c6789eea6c54 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAIAssistantTarget.Serialization.cs @@ -0,0 +1,152 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Represents a target specifying an Azure AI Assistant (Agent V1) endpoint, including its id. + public partial class AzureAIAssistantTarget : Target, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AzureAIAssistantTarget() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureAIAssistantTarget)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + writer.WritePropertyName("tool_descriptions"u8); + writer.WriteStartArray(); + foreach (ToolDescription item in ToolDescriptions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + + /// The JSON reader. + /// The client options for reading and writing models. + AzureAIAssistantTarget IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AzureAIAssistantTarget)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override Target JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureAIAssistantTarget)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureAIAssistantTarget(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureAIAssistantTarget DeserializeAzureAIAssistantTarget(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = "azure_ai_assistant"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string id = default; + IList toolDescriptions = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("tool_descriptions"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ToolDescription.DeserializeToolDescription(item, options)); + } + toolDescriptions = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureAIAssistantTarget(@type, additionalBinaryDataProperties, id, toolDescriptions); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(AzureAIAssistantTarget)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AzureAIAssistantTarget IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AzureAIAssistantTarget)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override Target PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAzureAIAssistantTarget(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureAIAssistantTarget)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureAIAssistantTarget.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAIAssistantTarget.cs new file mode 100644 index 000000000000..549b5beef909 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAIAssistantTarget.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects +{ + /// Represents a target specifying an Azure AI Assistant (Agent V1) endpoint, including its id. + public partial class AzureAIAssistantTarget : Target + { + /// Initializes a new instance of . + /// The descriptions of tools available to the assistant. + internal AzureAIAssistantTarget(IEnumerable toolDescriptions) : base("azure_ai_assistant") + { + ToolDescriptions = toolDescriptions.ToList(); + } + + /// Initializes a new instance of . + /// The type of target. + /// Keeps track of any properties unknown to the library. + /// The unique identifier of the Azure AI Assistant. + /// The descriptions of tools available to the assistant. + internal AzureAIAssistantTarget(string @type, IDictionary additionalBinaryDataProperties, string id, IList toolDescriptions) : base(@type, additionalBinaryDataProperties) + { + Id = id; + ToolDescriptions = toolDescriptions; + } + + /// The unique identifier of the Azure AI Assistant. + public string Id { get; } + + /// The descriptions of tools available to the assistant. + public IList ToolDescriptions { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureAIModelTarget.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAIModelTarget.Serialization.cs new file mode 100644 index 000000000000..10f00628c9a3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAIModelTarget.Serialization.cs @@ -0,0 +1,144 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Represents a target specifying an Azure AI model for operations requiring model selection. + public partial class AzureAIModelTarget : Target, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureAIModelTarget)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Model)) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model); + } + if (Optional.IsDefined(SamplingParams)) + { + writer.WritePropertyName("sampling_params"u8); + writer.WriteObjectValue(SamplingParams, options); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AzureAIModelTarget IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AzureAIModelTarget)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override Target JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureAIModelTarget)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureAIModelTarget(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureAIModelTarget DeserializeAzureAIModelTarget(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = "azure_ai_model"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string model = default; + ModelSamplingParams samplingParams = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("model"u8)) + { + model = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("sampling_params"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + samplingParams = ModelSamplingParams.DeserializeModelSamplingParams(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureAIModelTarget(@type, additionalBinaryDataProperties, model, samplingParams); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(AzureAIModelTarget)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AzureAIModelTarget IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AzureAIModelTarget)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override Target PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAzureAIModelTarget(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureAIModelTarget)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureAIModelTarget.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAIModelTarget.cs new file mode 100644 index 000000000000..189be36278c8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAIModelTarget.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Represents a target specifying an Azure AI model for operations requiring model selection. + public partial class AzureAIModelTarget : Target + { + /// Initializes a new instance of . + internal AzureAIModelTarget() : base("azure_ai_model") + { + } + + /// Initializes a new instance of . + /// The type of target. + /// Keeps track of any properties unknown to the library. + /// The unique identifier of the Azure AI model. + /// The parameters used to control the sampling behavior of the model during text generation. + internal AzureAIModelTarget(string @type, IDictionary additionalBinaryDataProperties, string model, ModelSamplingParams samplingParams) : base(@type, additionalBinaryDataProperties) + { + Model = model; + SamplingParams = samplingParams; + } + + /// The unique identifier of the Azure AI model. + public string Model { get; } + + /// The parameters used to control the sampling behavior of the model during text generation. + public ModelSamplingParams SamplingParams { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureAIProjectsModelFactory.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAIProjectsModelFactory.cs index fc5213e81782..bd6a6dd25164 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AzureAIProjectsModelFactory.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAIProjectsModelFactory.cs @@ -8,6 +8,7 @@ using System.Linq; using Azure.Core; using Azure.Core.Foundations; +using OpenAI; namespace Azure.AI.Projects { @@ -40,7 +41,7 @@ public static AIProjectConnection AIProjectConnection(string name = default, str /// /// A base class for connection credentials - /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , , and . + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , , , and . /// /// The type of credential used by the connection. /// A new instance for mocking. @@ -89,11 +90,18 @@ public static NoAuthenticationCredentials NoAuthenticationCredentials() return new NoAuthenticationCredentials(CredentialType.None, additionalBinaryDataProperties: null); } + /// Agentic identity credential definition. + /// A new instance for mocking. + public static AgenticIdentityCredentials AgenticIdentityCredentials() + { + return new AgenticIdentityCredentials(CredentialType.AgenticIdentity, additionalBinaryDataProperties: null); + } + /// /// DatasetVersion Definition /// Please note this is the abstract base class. The derived classes available for instantiation are: and . /// - /// URI of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// URI of the data ([example](https://go.microsoft.com/fwlink/?linkid=2202330)). /// Dataset type. /// Indicates if the dataset holds a reference to the storage, or the dataset manages storage itself. If true, the underlying data will not be deleted when the dataset version is deleted. /// The Azure Storage Account connection name. Required if startPendingUploadVersion was not called before creating the Dataset. @@ -121,7 +129,7 @@ public static AIProjectDataset AIProjectDataset(Uri dataUri = default, string @t } /// FileDatasetVersion Definition. - /// URI of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// URI of the data ([example](https://go.microsoft.com/fwlink/?linkid=2202330)). /// Indicates if the dataset holds a reference to the storage, or the dataset manages storage itself. If true, the underlying data will not be deleted when the dataset version is deleted. /// The Azure Storage Account connection name. Required if startPendingUploadVersion was not called before creating the Dataset. /// Asset ID, a unique identifier for the asset. @@ -148,7 +156,7 @@ public static FileDataset FileDataset(Uri dataUri = default, bool? isReference = } /// FileDatasetVersion Definition. - /// URI of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// URI of the data ([example](https://go.microsoft.com/fwlink/?linkid=2202330)). /// Indicates if the dataset holds a reference to the storage, or the dataset manages storage itself. If true, the underlying data will not be deleted when the dataset version is deleted. /// The Azure Storage Account connection name. Required if startPendingUploadVersion was not called before creating the Dataset. /// Asset ID, a unique identifier for the asset. @@ -194,7 +202,7 @@ public static PendingUploadResult PendingUploadResult(AIProjectBlobReference blo } /// Blob reference details. - /// Blob URI path for client to upload data. Example: https://blob.windows.core.net/Container/Path. + /// Blob URI path for client to upload data. Example: `https://blob.windows.core.net/Container/Path`. /// ARM ID of the storage account to use. /// Credential info to access the storage account. /// A new instance for mocking. @@ -413,6 +421,1162 @@ public static ModelDeploymentSku ModelDeploymentSku(long capacity = default, str additionalBinaryDataProperties: null); } + /// Red team details. + /// Identifier of the red team run. + /// Name of the red-team run. + /// Number of simulation rounds. + /// List of attack strategies or nested lists of attack strategies. + /// Simulation-only or Simulation + Evaluation. Default false, if true the scan outputs conversation not evaluation result. + /// List of risk categories to generate attack objectives for. + /// Application scenario for the red team operation, to generate scenario specific attacks. + /// Red team's tags. Unlike properties, tags are fully mutable. + /// Red team's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. + /// Status of the red-team. It is set by service and is read-only. + /// Target configuration for the red-team run. + /// A new instance for mocking. + public static RedTeam RedTeam(string name = default, string displayName = default, int? numTurns = default, IEnumerable attackStrategies = default, bool? simulationOnly = default, IEnumerable riskCategories = default, string applicationScenario = default, IDictionary tags = default, IDictionary properties = default, string status = default, TargetConfig target = default) + { + attackStrategies ??= new ChangeTrackingList(); + riskCategories ??= new ChangeTrackingList(); + tags ??= new ChangeTrackingDictionary(); + properties ??= new ChangeTrackingDictionary(); + + return new RedTeam( + name, + displayName, + numTurns, + attackStrategies.ToList(), + simulationOnly, + riskCategories.ToList(), + applicationScenario, + tags, + properties, + status, + target, + additionalBinaryDataProperties: null); + } + + /// + /// Abstract class for target configuration. + /// Please note this is the abstract base class. The derived classes available for instantiation are: . + /// + /// Type of the model configuration. + /// A new instance for mocking. + public static TargetConfig TargetConfig(string @type = default) + { + return new UnknownTargetConfig(@type, additionalBinaryDataProperties: null); + } + + /// Azure OpenAI model configuration. The API version would be selected by the service for querying the model. + /// Deployment name for AOAI model. Example: gpt-4o if in AIServices or connection based `connection_name/deployment_name` (e.g. `my-aoai-connection/gpt-4o`). + /// A new instance for mocking. + public static AzureOpenAIModelConfiguration AzureOpenAIModelConfiguration(string modelDeploymentName = default) + { + return new AzureOpenAIModelConfiguration("AzureOpenAIModel", additionalBinaryDataProperties: null, modelDeploymentName); + } + + /// Evaluation rule model. + /// Unique identifier for the evaluation rule. + /// Display Name for the evaluation rule. + /// Description for the evaluation rule. + /// Definition of the evaluation rule action. + /// Filter condition of the evaluation rule. + /// Event type that the evaluation rule applies to. + /// Indicates whether the evaluation rule is enabled. Default is true. + /// System metadata for the evaluation rule. + /// A new instance for mocking. + public static EvaluationRule EvaluationRule(string id = default, string displayName = default, string description = default, EvaluationRuleAction action = default, EvaluationRuleFilter filter = default, EvaluationRuleEventType eventType = default, bool enabled = default, IReadOnlyDictionary systemData = default) + { + systemData ??= new ChangeTrackingDictionary(); + + return new EvaluationRule( + id, + displayName, + description, + action, + filter, + eventType, + enabled, + systemData, + additionalBinaryDataProperties: null); + } + + /// + /// Evaluation action model. + /// Please note this is the abstract base class. The derived classes available for instantiation are: and . + /// + /// Type of the evaluation action. + /// A new instance for mocking. + public static EvaluationRuleAction EvaluationRuleAction(string @type = default) + { + return new UnknownEvaluationRuleAction(new EvaluationRuleActionType(@type), additionalBinaryDataProperties: null); + } + + /// Evaluation rule action for continuous evaluation. + /// Eval Id to add continuous evaluation runs to. + /// Maximum number of evaluation runs allowed per hour. + /// A new instance for mocking. + public static ContinuousEvaluationRuleAction ContinuousEvaluationRuleAction(string evalId = default, int? maxHourlyRuns = default) + { + return new ContinuousEvaluationRuleAction(EvaluationRuleActionType.ContinuousEvaluation, additionalBinaryDataProperties: null, evalId, maxHourlyRuns); + } + + /// Evaluation rule action for human evaluation. + /// Human evaluation template Id. + /// A new instance for mocking. + public static HumanEvaluationRuleAction HumanEvaluationRuleAction(string templateId = default) + { + return new HumanEvaluationRuleAction(EvaluationRuleActionType.HumanEvaluation, additionalBinaryDataProperties: null, templateId); + } + + /// Evaluation filter model. + /// Filter by agent name. + /// A new instance for mocking. + public static EvaluationRuleFilter EvaluationRuleFilter(string agentName = default) + { + return new EvaluationRuleFilter(agentName, additionalBinaryDataProperties: null); + } + + /// Evaluation Taxonomy Definition. + /// Asset ID, a unique identifier for the asset. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Input configuration for the evaluation taxonomy. + /// List of taxonomy categories. + /// Additional properties for the evaluation taxonomy. + /// A new instance for mocking. + public static EvaluationTaxonomy EvaluationTaxonomy(string id = default, string name = default, string version = default, string description = default, IDictionary tags = default, EvaluationTaxonomyInput taxonomyInput = default, IEnumerable taxonomyCategories = default, IDictionary properties = default) + { + tags ??= new ChangeTrackingDictionary(); + taxonomyCategories ??= new ChangeTrackingList(); + properties ??= new ChangeTrackingDictionary(); + + return new EvaluationTaxonomy( + id, + name, + version, + description, + tags, + taxonomyInput, + taxonomyCategories.ToList(), + properties, + additionalBinaryDataProperties: null); + } + + /// + /// Input configuration for the evaluation taxonomy. + /// Please note this is the abstract base class. The derived classes available for instantiation are: . + /// + /// Input type of the evaluation taxonomy. + /// A new instance for mocking. + public static EvaluationTaxonomyInput EvaluationTaxonomyInput(string @type = default) + { + return new UnknownEvaluationTaxonomyInput(new EvaluationTaxonomyInputType(@type), additionalBinaryDataProperties: null); + } + + /// Input configuration for the evaluation taxonomy when the input type is agent. + /// Target configuration for the agent. + /// List of risk categories to evaluate against. + /// A new instance for mocking. + public static AgentTaxonomyInput AgentTaxonomyInput(AzureAIAgentTarget target = default, IEnumerable riskCategories = default) + { + riskCategories ??= new ChangeTrackingList(); + + return new AgentTaxonomyInput(EvaluationTaxonomyInputType.Agent, additionalBinaryDataProperties: null, target, riskCategories.ToList()); + } + + /// Represents a target specifying an Azure AI agent. + /// The unique identifier of the Azure AI agent. + /// The version of the Azure AI agent. + /// The parameters used to control the sampling behavior of the agent during text generation. + /// A new instance for mocking. + public static AzureAIAgentTarget AzureAIAgentTarget(string name = default, string version = default, IEnumerable toolDescriptions = default) + { + toolDescriptions ??= new ChangeTrackingList(); + + return new AzureAIAgentTarget("azure_ai_agent", additionalBinaryDataProperties: null, name, version, toolDescriptions.ToList()); + } + + /// Description of a tool that can be used by an agent. + /// The name of the tool. + /// A brief description of the tool's purpose. + /// A new instance for mocking. + public static ToolDescription ToolDescription(string name = default, string description = default) + { + return new ToolDescription(name, description, additionalBinaryDataProperties: null); + } + + /// + /// Base class for targets with discriminator support. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// + /// The type of target. + /// A new instance for mocking. + public static Target Target(string @type = default) + { + return new UnknownTarget(@type, additionalBinaryDataProperties: null); + } + + /// Represents a target specifying an Azure AI model for operations requiring model selection. + /// The unique identifier of the Azure AI model. + /// The parameters used to control the sampling behavior of the model during text generation. + /// A new instance for mocking. + public static AzureAIModelTarget AzureAIModelTarget(string model = default, ModelSamplingParams samplingParams = default) + { + return new AzureAIModelTarget("azure_ai_model", additionalBinaryDataProperties: null, model, samplingParams); + } + + /// Represents a set of parameters used to control the sampling behavior of a language model during text generation. + /// The temperature parameter for sampling. + /// The top-p parameter for nucleus sampling. + /// The random seed for reproducibility. + /// The maximum number of tokens allowed in the completion. + /// A new instance for mocking. + public static ModelSamplingParams ModelSamplingParams(float temperature = default, float topP = default, int seed = default, int maxCompletionTokens = default) + { + return new ModelSamplingParams(temperature, topP, seed, maxCompletionTokens, additionalBinaryDataProperties: null); + } + + /// Represents a target specifying an Azure AI Assistant (Agent V1) endpoint, including its id. + /// The unique identifier of the Azure AI Assistant. + /// The descriptions of tools available to the assistant. + /// A new instance for mocking. + public static AzureAIAssistantTarget AzureAIAssistantTarget(string id = default, IEnumerable toolDescriptions = default) + { + toolDescriptions ??= new ChangeTrackingList(); + + return new AzureAIAssistantTarget("azure_ai_assistant", additionalBinaryDataProperties: null, id, toolDescriptions.ToList()); + } + + /// Taxonomy category definition. + /// Unique identifier of the taxonomy category. + /// Name of the taxonomy category. + /// Description of the taxonomy category. + /// Risk category associated with this taxonomy category. + /// List of taxonomy sub categories. + /// Additional properties for the taxonomy category. + /// A new instance for mocking. + public static TaxonomyCategory TaxonomyCategory(string id = default, string name = default, string description = default, RiskCategory riskCategory = default, IEnumerable subCategories = default, IDictionary properties = default) + { + subCategories ??= new ChangeTrackingList(); + properties ??= new ChangeTrackingDictionary(); + + return new TaxonomyCategory( + id, + name, + description, + riskCategory, + subCategories.ToList(), + properties, + additionalBinaryDataProperties: null); + } + + /// Taxonomy sub-category definition. + /// Unique identifier of the taxonomy sub-category. + /// Name of the taxonomy sub-category. + /// Description of the taxonomy sub-category. + /// List of taxonomy items under this sub-category. + /// Additional properties for the taxonomy sub-category. + /// A new instance for mocking. + public static TaxonomySubCategory TaxonomySubCategory(string id = default, string name = default, string description = default, bool enabled = default, IDictionary properties = default) + { + properties ??= new ChangeTrackingDictionary(); + + return new TaxonomySubCategory( + id, + name, + description, + enabled, + properties, + additionalBinaryDataProperties: null); + } + + /// Evaluator Definition. + /// Display Name for evaluator. It helps to find the evaluator easily in AI Foundry. It does not need to be unique. + /// Metadata about the evaluator. + /// The type of the evaluator. + /// The categories of the evaluator. + /// Definition of the evaluator. + /// Creator of the evaluator. + /// Creation date/time of the evaluator. + /// Last modified date/time of the evaluator. + /// Asset ID, a unique identifier for the asset. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// A new instance for mocking. + public static EvaluatorVersion EvaluatorVersion(string displayName = default, IDictionary metadata = default, EvaluatorType evaluatorType = default, IEnumerable categories = default, EvaluatorDefinition definition = default, string createdBy = default, long createdAt = default, long modifiedAt = default, string id = default, string name = default, string version = default, string description = default, IDictionary tags = default) + { + metadata ??= new ChangeTrackingDictionary(); + categories ??= new ChangeTrackingList(); + tags ??= new ChangeTrackingDictionary(); + + return new EvaluatorVersion( + displayName, + metadata, + evaluatorType, + categories.ToList(), + definition, + createdBy, + createdAt, + modifiedAt, + id, + name, + version, + description, + tags, + additionalBinaryDataProperties: null); + } + + /// + /// Base evaluator configuration with discriminator + /// Please note this is the abstract base class. The derived classes available for instantiation are: and . + /// + /// The type of evaluator definition. + /// The JSON schema (Draft 2020-12) for the evaluator's input parameters. This includes parameters like type, properties, required. + /// The JSON schema (Draft 2020-12) for the evaluator's input data. This includes parameters like type, properties, required. + /// List of output metrics produced by this evaluator. + /// A new instance for mocking. + public static EvaluatorDefinition EvaluatorDefinition(string @type = default, BinaryData initParameters = default, BinaryData dataSchema = default, IDictionary metrics = default) + { + metrics ??= new ChangeTrackingDictionary(); + + return new UnknownEvaluatorDefinition(new EvaluatorDefinitionType(@type), initParameters, dataSchema, metrics, additionalBinaryDataProperties: null); + } + + /// Evaluator Metric. + /// Type of the metric. + /// It indicates whether a higher value is better or a lower value is better for this metric. + /// Minimum value for the metric. + /// Maximum value for the metric. If not specified, it is assumed to be unbounded. + /// Indicates if this metric is primary when there are multiple metrics. + /// A new instance for mocking. + public static EvaluatorMetric EvaluatorMetric(EvaluatorMetricType? @type = default, EvaluatorMetricDirection? desirableDirection = default, float? minValue = default, float? maxValue = default, bool? isPrimary = default) + { + return new EvaluatorMetric( + @type, + desirableDirection, + minValue, + maxValue, + isPrimary, + additionalBinaryDataProperties: null); + } + + /// Code-based evaluator definition using python code. + /// The JSON schema (Draft 2020-12) for the evaluator's input parameters. This includes parameters like type, properties, required. + /// The JSON schema (Draft 2020-12) for the evaluator's input data. This includes parameters like type, properties, required. + /// List of output metrics produced by this evaluator. + /// Inline code text for the evaluator. + /// A new instance for mocking. + public static CodeBasedEvaluatorDefinition CodeBasedEvaluatorDefinition(BinaryData initParameters = default, BinaryData dataSchema = default, IDictionary metrics = default, string codeText = default) + { + metrics ??= new ChangeTrackingDictionary(); + + return new CodeBasedEvaluatorDefinition( + EvaluatorDefinitionType.Code, + initParameters, + dataSchema, + metrics, + additionalBinaryDataProperties: null, + codeText); + } + + /// Prompt-based evaluator. + /// The JSON schema (Draft 2020-12) for the evaluator's input parameters. This includes parameters like type, properties, required. + /// The JSON schema (Draft 2020-12) for the evaluator's input data. This includes parameters like type, properties, required. + /// List of output metrics produced by this evaluator. + /// The prompt text used for evaluation. + /// A new instance for mocking. + public static PromptBasedEvaluatorDefinition PromptBasedEvaluatorDefinition(BinaryData initParameters = default, BinaryData dataSchema = default, IDictionary metrics = default, string promptText = default) + { + metrics ??= new ChangeTrackingDictionary(); + + return new PromptBasedEvaluatorDefinition( + EvaluatorDefinitionType.Prompt, + initParameters, + dataSchema, + metrics, + additionalBinaryDataProperties: null, + promptText); + } + + /// The response body for cluster insights. + /// The unique identifier for the insights report. + /// Metadata about the insights report. + /// The current state of the insights. + /// User friendly display name for the insight. + /// Request for the insights analysis. + /// The result of the insights report. + /// A new instance for mocking. + public static Insight Insight(string id = default, InsightsMetadata metadata = default, OperationStatus state = default, string displayName = default, InsightRequest request = default, InsightResult result = default) + { + return new Insight( + id, + metadata, + state, + displayName, + request, + result, + additionalBinaryDataProperties: null); + } + + /// Metadata about the insights. + /// The timestamp when the insights were created. + /// The timestamp when the insights were completed. + /// A new instance for mocking. + public static InsightsMetadata InsightsMetadata(DateTimeOffset createdAt = default, DateTimeOffset? completedAt = default) + { + return new InsightsMetadata(createdAt, completedAt, additionalBinaryDataProperties: null); + } + + /// + /// The request of the insights report. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// + /// The type of request. + /// A new instance for mocking. + public static InsightRequest InsightRequest(string @type = default) + { + return new UnknownInsightRequest(new InsightType(@type), additionalBinaryDataProperties: null); + } + + /// Insights on set of Evaluation Results. + /// Evaluation Id for the insights. + /// List of evaluation run IDs for the insights. + /// Configuration of the model used in the insight generation. + /// A new instance for mocking. + public static EvaluationRunClusterInsightsRequest EvaluationRunClusterInsightsRequest(string evalId = default, IEnumerable runIds = default, InsightModelConfiguration modelConfiguration = default) + { + runIds ??= new ChangeTrackingList(); + + return new EvaluationRunClusterInsightsRequest(InsightType.EvaluationRunClusterInsight, additionalBinaryDataProperties: null, evalId, runIds.ToList(), modelConfiguration); + } + + /// Configuration of the model used in the insight generation. + /// The model deployment to be evaluated. Accepts either the deployment name alone or with the connection name as '{connectionName}/<modelDeploymentName>'. + /// A new instance for mocking. + public static InsightModelConfiguration InsightModelConfiguration(string modelDeploymentName = default) + { + return new InsightModelConfiguration(modelDeploymentName, additionalBinaryDataProperties: null); + } + + /// Insights on set of Agent Evaluation Results. + /// Identifier for the agent. + /// Configuration of the model used in the insight generation. + /// A new instance for mocking. + public static AgentClusterInsightsRequest AgentClusterInsightsRequest(string agentName = default, InsightModelConfiguration modelConfiguration = default) + { + return new AgentClusterInsightsRequest(InsightType.AgentClusterInsight, additionalBinaryDataProperties: null, agentName, modelConfiguration); + } + + /// Evaluation Comparison Request. + /// Identifier for the evaluation. + /// The baseline run ID for comparison. + /// List of treatment run IDs for comparison. + /// A new instance for mocking. + public static EvaluationComparisonRequest EvaluationComparisonRequest(string evalId = default, string baselineRunId = default, IEnumerable treatmentRunIds = default) + { + treatmentRunIds ??= new ChangeTrackingList(); + + return new EvaluationComparisonRequest(InsightType.EvaluationComparison, additionalBinaryDataProperties: null, evalId, baselineRunId, treatmentRunIds.ToList()); + } + + /// + /// The result of the insights. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// + /// The type of insights result. + /// A new instance for mocking. + public static InsightResult InsightResult(string @type = default) + { + return new UnknownInsightResult(new InsightType(@type), additionalBinaryDataProperties: null); + } + + /// Insights from the evaluation comparison. + /// Comparison results for each treatment run against the baseline. + /// The statistical method used for comparison. + /// A new instance for mocking. + public static EvalCompareReport EvalCompareReport(IEnumerable comparisons = default, string @method = default) + { + comparisons ??= new ChangeTrackingList(); + + return new EvalCompareReport(InsightType.EvaluationComparison, additionalBinaryDataProperties: null, comparisons.ToList(), @method); + } + + /// Comparison results for treatment runs against the baseline. + /// Name of the testing criteria. + /// Metric being evaluated. + /// Name of the evaluator for this testing criteria. + /// Summary statistics of the baseline run. + /// List of comparison results for each treatment run. + /// A new instance for mocking. + public static EvalRunResultComparison EvalRunResultComparison(string testingCriteria = default, string metric = default, string evaluator = default, EvalRunResultSummary baselineRunSummary = default, IEnumerable compareItems = default) + { + compareItems ??= new ChangeTrackingList(); + + return new EvalRunResultComparison( + testingCriteria, + metric, + evaluator, + baselineRunSummary, + compareItems.ToList(), + additionalBinaryDataProperties: null); + } + + /// Summary statistics of a metric in an evaluation run. + /// The evaluation run ID. + /// Number of samples in the evaluation run. + /// Average value of the metric in the evaluation run. + /// Standard deviation of the metric in the evaluation run. + /// A new instance for mocking. + public static EvalRunResultSummary EvalRunResultSummary(string runId = default, int sampleCount = default, float average = default, float standardDeviation = default) + { + return new EvalRunResultSummary(runId, sampleCount, average, standardDeviation, additionalBinaryDataProperties: null); + } + + /// Metric comparison for a treatment against the baseline. + /// The treatment run ID. + /// Summary statistics of the treatment run. + /// Estimated difference between treatment and baseline. + /// P-value for the treatment effect. + /// Type of treatment effect. + /// A new instance for mocking. + public static EvalRunResultCompareItem EvalRunResultCompareItem(string treatmentRunId = default, EvalRunResultSummary treatmentRunSummary = default, float deltaEstimate = default, float pValue = default, TreatmentEffectType treatmentEffect = default) + { + return new EvalRunResultCompareItem( + treatmentRunId, + treatmentRunSummary, + deltaEstimate, + pValue, + treatmentEffect, + additionalBinaryDataProperties: null); + } + + /// Insights from the evaluation run cluster analysis. + /// + /// A new instance for mocking. + public static EvaluationRunClusterInsightResult EvaluationRunClusterInsightResult(ClusterInsightResult clusterInsight = default) + { + return new EvaluationRunClusterInsightResult(InsightType.EvaluationRunClusterInsight, additionalBinaryDataProperties: null, clusterInsight); + } + + /// Insights from the cluster analysis. + /// Summary of the insights report. + /// List of clusters identified in the insights. + /// + /// Optional mapping of IDs to 2D coordinates used by the UX for visualization. + /// + /// The map keys are string identifiers (for example, a cluster id or a sample id) + /// and the values are the coordinates and visual size for rendering on a 2D chart. + /// + /// This property is omitted unless the client requests coordinates (for example, + /// by passing `includeCoordinates=true` as a query parameter). + /// + /// Example: + /// ``` + /// { + /// "cluster-1": { "x": 12, "y": 34, "size": 8 }, + /// "sample-123": { "x": 18, "y": 22, "size": 4 } + /// } + /// ``` + /// + /// Coordinates are intended only for client-side visualization and do not + /// modify the canonical insights results. + /// + /// A new instance for mocking. + public static ClusterInsightResult ClusterInsightResult(InsightSummary summary = default, IEnumerable clusters = default, IDictionary coordinates = default) + { + clusters ??= new ChangeTrackingList(); + coordinates ??= new ChangeTrackingDictionary(); + + return new ClusterInsightResult(summary, clusters.ToList(), coordinates, additionalBinaryDataProperties: null); + } + + /// Summary of the error cluster analysis. + /// Total number of samples analyzed. + /// Total number of unique subcluster labels. + /// Total number of unique clusters. + /// Method used for clustering. + /// Token usage while performing clustering analysis. + /// A new instance for mocking. + public static InsightSummary InsightSummary(int sampleCount = default, int uniqueSubclusterCount = default, int uniqueClusterCount = default, string @method = default, ClusterTokenUsage usage = default) + { + return new InsightSummary( + sampleCount, + uniqueSubclusterCount, + uniqueClusterCount, + @method, + usage, + additionalBinaryDataProperties: null); + } + + /// Token usage for cluster analysis. + /// input token usage. + /// output token usage. + /// total token usage. + /// A new instance for mocking. + public static ClusterTokenUsage ClusterTokenUsage(int inputTokenUsage = default, int outputTokenUsage = default, int totalTokenUsage = default) + { + return new ClusterTokenUsage(inputTokenUsage, outputTokenUsage, totalTokenUsage, additionalBinaryDataProperties: null); + } + + /// A cluster of analysis samples. + /// The id of the analysis cluster. + /// Label for the cluster. + /// Suggestion for the cluster. + /// The title of the suggestion for the cluster. + /// Description of the analysis cluster. + /// The weight of the analysis cluster. This indicate number of samples in the cluster. + /// List of subclusters within this cluster. Empty if no subclusters exist. + /// List of samples that belong to this cluster. Empty if samples are part of subclusters. + /// A new instance for mocking. + public static InsightCluster InsightCluster(string id = default, string label = default, string suggestion = default, string suggestionTitle = default, string description = default, int weight = default, IEnumerable subClusters = default, IEnumerable samples = default) + { + subClusters ??= new ChangeTrackingList(); + samples ??= new ChangeTrackingList(); + + return new InsightCluster( + id, + label, + suggestion, + suggestionTitle, + description, + weight, + subClusters.ToList(), + samples.ToList(), + additionalBinaryDataProperties: null); + } + + /// + /// A sample from the analysis. + /// Please note this is the abstract base class. The derived classes available for instantiation are: . + /// + /// The unique identifier for the analysis sample. + /// Sample type. + /// Features to help with additional filtering of data in UX. + /// Info about the correlation for the analysis sample. + /// A new instance for mocking. + public static InsightSample InsightSample(string id = default, string @type = default, IDictionary features = default, IDictionary correlationInfo = default) + { + features ??= new ChangeTrackingDictionary(); + correlationInfo ??= new ChangeTrackingDictionary(); + + return new UnknownInsightSample(id, new SampleType(@type), features, correlationInfo, additionalBinaryDataProperties: null); + } + + /// A sample from the evaluation result. + /// The unique identifier for the analysis sample. + /// Features to help with additional filtering of data in UX. + /// Info about the correlation for the analysis sample. + /// Evaluation result for the analysis sample. + /// A new instance for mocking. + public static EvaluationResultSample EvaluationResultSample(string id = default, IDictionary features = default, IDictionary correlationInfo = default, EvalResult evaluationResult = default) + { + features ??= new ChangeTrackingDictionary(); + correlationInfo ??= new ChangeTrackingDictionary(); + + return new EvaluationResultSample( + id, + SampleType.EvaluationResultSample, + features, + correlationInfo, + additionalBinaryDataProperties: null, + evaluationResult); + } + + /// Result of the evaluation. + /// name of the check. + /// type of the check. + /// score. + /// indicates if the check passed or failed. + /// A new instance for mocking. + public static EvalResult EvalResult(string name = default, string @type = default, float score = default, bool passed = default) + { + return new EvalResult(name, @type, score, passed, additionalBinaryDataProperties: null); + } + + /// Coordinates for the analysis chart. + /// X-axis coordinate. + /// Y-axis coordinate. + /// Size of the chart element. + /// A new instance for mocking. + public static ChartCoordinate ChartCoordinate(int x = default, int y = default, int size = default) + { + return new ChartCoordinate(x, y, size, additionalBinaryDataProperties: null); + } + + /// Insights from the agent cluster analysis. + /// + /// A new instance for mocking. + public static AgentClusterInsightResult AgentClusterInsightResult(ClusterInsightResult clusterInsight = default) + { + return new AgentClusterInsightResult(InsightType.AgentClusterInsight, additionalBinaryDataProperties: null, clusterInsight); + } + + /// Schedule model. + /// Identifier of the schedule. + /// Name of the schedule. + /// Description of the schedule. + /// Enabled status of the schedule. + /// Provisioning status of the schedule. + /// Trigger for the schedule. + /// Task for the schedule. + /// Schedule's tags. Unlike properties, tags are fully mutable. + /// Schedule's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. + /// System metadata for the resource. + /// A new instance for mocking. + public static Schedule Schedule(string id = default, string displayName = default, string description = default, bool enabled = default, ScheduleProvisioningStatus? provisioningStatus = default, Trigger trigger = default, ScheduleTask task = default, IDictionary tags = default, IDictionary properties = default, IReadOnlyDictionary systemData = default) + { + tags ??= new ChangeTrackingDictionary(); + properties ??= new ChangeTrackingDictionary(); + systemData ??= new ChangeTrackingDictionary(); + + return new Schedule( + id, + displayName, + description, + enabled, + provisioningStatus, + trigger, + task, + tags, + properties, + systemData, + additionalBinaryDataProperties: null); + } + + /// + /// Base model for Trigger of the schedule. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// + /// Type of the trigger. + /// A new instance for mocking. + public static Trigger Trigger(string @type = default) + { + return new UnknownTrigger(new TriggerType(@type), additionalBinaryDataProperties: null); + } + + /// Cron based trigger. + /// Cron expression that defines the schedule frequency. + /// Time zone for the cron schedule. + /// Start time for the cron schedule in ISO 8601 format. + /// End time for the cron schedule in ISO 8601 format. + /// A new instance for mocking. + public static CronTrigger CronTrigger(string expression = default, string timeZone = default, string startTime = default, string endTime = default) + { + return new CronTrigger( + TriggerType.Cron, + additionalBinaryDataProperties: null, + expression, + timeZone, + startTime, + endTime); + } + + /// Recurrence based trigger. + /// Start time for the recurrence schedule in ISO 8601 format. + /// End time for the recurrence schedule in ISO 8601 format. + /// Time zone for the recurrence schedule. + /// Interval for the recurrence schedule. + /// Recurrence schedule for the recurrence trigger. + /// A new instance for mocking. + public static RecurrenceTrigger RecurrenceTrigger(string startTime = default, string endTime = default, string timeZone = default, int interval = default, RecurrenceSchedule schedule = default) + { + return new RecurrenceTrigger( + TriggerType.Recurrence, + additionalBinaryDataProperties: null, + startTime, + endTime, + timeZone, + interval, + schedule); + } + + /// + /// Recurrence schedule model. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , and . + /// + /// Recurrence type for the recurrence schedule. + /// A new instance for mocking. + public static RecurrenceSchedule RecurrenceSchedule(string @type = default) + { + return new UnknownRecurrenceSchedule(new RecurrenceType(@type), additionalBinaryDataProperties: null); + } + + /// Hourly recurrence schedule. + /// A new instance for mocking. + public static HourlyRecurrenceSchedule HourlyRecurrenceSchedule() + { + return new HourlyRecurrenceSchedule(RecurrenceType.Hourly, additionalBinaryDataProperties: null); + } + + /// Daily recurrence schedule. + /// Hours for the recurrence schedule. + /// A new instance for mocking. + public static DailyRecurrenceSchedule DailyRecurrenceSchedule(IEnumerable hours = default) + { + hours ??= new ChangeTrackingList(); + + return new DailyRecurrenceSchedule(RecurrenceType.Daily, additionalBinaryDataProperties: null, hours.ToList()); + } + + /// Weekly recurrence schedule. + /// Days of the week for the recurrence schedule. + /// A new instance for mocking. + public static WeeklyRecurrenceSchedule WeeklyRecurrenceSchedule(IEnumerable daysOfWeek = default) + { + daysOfWeek ??= new ChangeTrackingList(); + + return new WeeklyRecurrenceSchedule(RecurrenceType.Weekly, additionalBinaryDataProperties: null, daysOfWeek.ToList()); + } + + /// Monthly recurrence schedule. + /// Days of the month for the recurrence schedule. + /// A new instance for mocking. + public static MonthlyRecurrenceSchedule MonthlyRecurrenceSchedule(IEnumerable daysOfMonth = default) + { + daysOfMonth ??= new ChangeTrackingList(); + + return new MonthlyRecurrenceSchedule(RecurrenceType.Monthly, additionalBinaryDataProperties: null, daysOfMonth.ToList()); + } + + /// One-time trigger. + /// Date and time for the one-time trigger in ISO 8601 format. + /// Time zone for the one-time trigger. + /// A new instance for mocking. + public static OneTimeTrigger OneTimeTrigger(string triggerAt = default, string timeZone = default) + { + return new OneTimeTrigger(TriggerType.OneTime, additionalBinaryDataProperties: null, triggerAt, timeZone); + } + + /// + /// Schedule task model. + /// Please note this is the abstract base class. The derived classes available for instantiation are: and . + /// + /// Type of the task. + /// Configuration for the task. + /// A new instance for mocking. + public static ScheduleTask ScheduleTask(string @type = default, IDictionary configuration = default) + { + configuration ??= new ChangeTrackingDictionary(); + + return new UnknownScheduleTask(new ScheduleTaskType(@type), configuration, additionalBinaryDataProperties: null); + } + + /// Evaluation task for the schedule. + /// Configuration for the task. + /// Identifier of the evaluation group. + /// The evaluation run payload. + /// A new instance for mocking. + public static EvaluationScheduleTask EvaluationScheduleTask(IDictionary configuration = default, string evalId = default, EvaluationScheduleTaskEvalRun evalRun = default) + { + configuration ??= new ChangeTrackingDictionary(); + + return new EvaluationScheduleTask(ScheduleTaskType.Evaluation, configuration, additionalBinaryDataProperties: null, evalId, evalRun); + } + + /// The EvaluationScheduleTaskEvalRun. + /// A new instance for mocking. + public static EvaluationScheduleTaskEvalRun EvaluationScheduleTaskEvalRun() + { + return new EvaluationScheduleTaskEvalRun(additionalBinaryDataProperties: null); + } + + /// Insight task for the schedule. + /// Configuration for the task. + /// The insight payload. + /// A new instance for mocking. + public static InsightScheduleTask InsightScheduleTask(IDictionary configuration = default, Insight insight = default) + { + configuration ??= new ChangeTrackingDictionary(); + + return new InsightScheduleTask(ScheduleTaskType.Insight, configuration, additionalBinaryDataProperties: null, insight); + } + + /// Schedule run model. + /// Identifier of the schedule run. + /// Identifier of the schedule. + /// Trigger success status of the schedule run. + /// Trigger time of the schedule run. + /// Error information for the schedule run. + /// Properties of the schedule run. + /// A new instance for mocking. + public static ScheduleRun ScheduleRun(string runId = default, string scheduleId = default, bool success = default, string triggerTime = default, string error = default, IReadOnlyDictionary properties = default) + { + properties ??= new ChangeTrackingDictionary(); + + return new ScheduleRun( + runId, + scheduleId, + success, + triggerTime, + error, + properties, + additionalBinaryDataProperties: null); + } + + /// Memory search options. + /// Maximum number of memory items to return. + /// A new instance for mocking. + public static MemorySearchResultOptions MemorySearchResultOptions(int? maxMemories = default) + { + return new MemorySearchResultOptions(maxMemories, additionalBinaryDataProperties: null); + } + + /// The AgentManifestOptions. + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + /// A human-readable description of the agent. + /// The manifest ID to import the agent version from. + /// The inputs to the manifest that will result in a fully materialized Agent. + /// A new instance for mocking. + public static AgentManifestOptions AgentManifestOptions(IDictionary metadata = default, string description = default, string manifestId = default, IDictionary parameterValues = default) + { + metadata ??= new ChangeTrackingDictionary(); + parameterValues ??= new ChangeTrackingDictionary(); + + return new AgentManifestOptions(metadata, description, manifestId, parameterValues, additionalBinaryDataProperties: null); + } + + /// + /// Base definition for memory store configurations. + /// Please note this is the abstract base class. The derived classes available for instantiation are: . + /// + /// The kind of the memory store. + /// A new instance for mocking. + public static MemoryStoreDefinition MemoryStoreDefinition(string kind = default) + { + return new UnknownMemoryStoreDefinition(new MemoryStoreKind(kind), additionalBinaryDataProperties: null); + } + + /// Default memory store implementation. + /// The name or identifier of the chat completion model deployment used for memory processing. + /// The name or identifier of the embedding model deployment used for memory processing. + /// Default memory store options. + /// A new instance for mocking. + public static MemoryStoreDefaultDefinition MemoryStoreDefaultDefinition(string chatModel = default, string embeddingModel = default, MemoryStoreDefaultOptions options = default) + { + return new MemoryStoreDefaultDefinition(MemoryStoreKind.Default, additionalBinaryDataProperties: null, chatModel, embeddingModel, options); + } + + /// Default memory store configurations. + /// Whether to enable user profile extraction and storage. Default is true. + /// Specific categories or types of user profile information to extract and store. + /// Whether to enable chat summary extraction and storage. Default is true. + /// A new instance for mocking. + public static MemoryStoreDefaultOptions MemoryStoreDefaultOptions(bool userProfileEnabled = default, string userProfileDetails = default, bool chatSummaryEnabled = default) + { + return new MemoryStoreDefaultOptions(userProfileEnabled, userProfileDetails, chatSummaryEnabled, additionalBinaryDataProperties: null); + } + + /// A memory store that can store and retrieve user memories. + /// The unique identifier of the memory store. + /// The Unix timestamp (seconds) when the memory store was created. + /// The Unix timestamp (seconds) when the memory store was last updated. + /// The name of the memory store. + /// A human-readable description of the memory store. + /// Arbitrary key-value metadata to associate with the memory store. + /// The definition of the memory store. + /// A new instance for mocking. + public static MemoryStore MemoryStore(string id = default, DateTimeOffset createdAt = default, DateTimeOffset updatedAt = default, string name = default, string description = default, IDictionary metadata = default, MemoryStoreDefinition definition = default) + { + metadata ??= new ChangeTrackingDictionary(); + + return new MemoryStore( + "memory_store", + id, + createdAt, + updatedAt, + name, + description, + metadata, + definition, + additionalBinaryDataProperties: null); + } + + /// The DeleteMemoryStoreResponse. + /// The name of the memory store. + /// Whether the memory store was successfully deleted. + /// A new instance for mocking. + public static DeleteMemoryStoreResponse DeleteMemoryStoreResponse(string name = default, bool deleted = default) + { + return new DeleteMemoryStoreResponse("memory_store.deleted", name, deleted, additionalBinaryDataProperties: null); + } + + /// A retrieved memory item from memory search. + /// Retrieved memory item. + /// A new instance for mocking. + public static MemorySearchItem MemorySearchItem(MemoryItem memoryItem = default) + { + return new MemorySearchItem(memoryItem, additionalBinaryDataProperties: null); + } + + /// + /// A single memory item stored in the memory store, containing content and metadata. + /// Please note this is the abstract base class. The derived classes available for instantiation are: and . + /// + /// The unique ID of the memory item. + /// The last update time of the memory item. + /// The namespace that logically groups and isolates memories, such as a user ID. + /// The content of the memory. + /// The kind of the memory item. + /// A new instance for mocking. + public static MemoryItem MemoryItem(string memoryId = default, DateTimeOffset updatedAt = default, string scope = default, string content = default, string kind = default) + { + return new UnknownMemoryItem( + memoryId, + updatedAt, + scope, + content, + new MemoryItemKind(kind), + additionalBinaryDataProperties: null); + } + + /// A memory item specifically containing user profile information extracted from conversations, such as preferences, interests, and personal details. + /// The unique ID of the memory item. + /// The last update time of the memory item. + /// The namespace that logically groups and isolates memories, such as a user ID. + /// The content of the memory. + /// A new instance for mocking. + public static UserProfileMemoryItem UserProfileMemoryItem(string memoryId = default, DateTimeOffset updatedAt = default, string scope = default, string content = default) + { + return new UserProfileMemoryItem( + memoryId, + updatedAt, + scope, + content, + MemoryItemKind.UserProfile, + additionalBinaryDataProperties: null); + } + + /// A memory item containing a summary extracted from conversations. + /// The unique ID of the memory item. + /// The last update time of the memory item. + /// The namespace that logically groups and isolates memories, such as a user ID. + /// The content of the memory. + /// A new instance for mocking. + public static ChatSummaryMemoryItem ChatSummaryMemoryItem(string memoryId = default, DateTimeOffset updatedAt = default, string scope = default, string content = default) + { + return new ChatSummaryMemoryItem( + memoryId, + updatedAt, + scope, + content, + MemoryItemKind.ChatSummary, + additionalBinaryDataProperties: null); + } + + /// Memory search response. + /// The unique ID of this search request. Use this value as previous_search_id in subsequent requests to perform incremental searches. + /// Related memory items found during the search operation. + /// Usage statistics associated with the memory search operation. + /// A new instance for mocking. + public static MemoryStoreSearchResponse MemoryStoreSearchResponse(string searchId = default, IEnumerable memories = default, MemoryStoreOperationUsage usage = default) + { + memories ??= new ChangeTrackingList(); + + return new MemoryStoreSearchResponse(searchId, memories.ToList(), usage, additionalBinaryDataProperties: null); + } + + /// Usage statistics of a memory store operation. + /// The number of embedding tokens. + /// The number of input tokens. + /// A detailed breakdown of the input tokens. + /// The number of output tokens. + /// A detailed breakdown of the output tokens. + /// The total number of tokens used. + /// A new instance for mocking. + public static MemoryStoreOperationUsage MemoryStoreOperationUsage(int embeddingTokens = default, int inputTokens = default, MemoryStoreOperationUsageInputTokensDetails inputTokensDetails = default, int outputTokens = default, MemoryStoreOperationUsageOutputTokensDetails outputTokensDetails = default, int totalTokens = default) + { + return new MemoryStoreOperationUsage( + embeddingTokens, + inputTokens, + inputTokensDetails, + outputTokens, + outputTokensDetails, + totalTokens, + additionalBinaryDataProperties: null); + } + + /// The MemoryStoreOperationUsageInputTokensDetails. + /// + /// The number of tokens that were retrieved from the cache. + /// [More on prompt caching](https://platform.openai.com/docs/guides/prompt-caching). + /// + /// A new instance for mocking. + public static MemoryStoreOperationUsageInputTokensDetails MemoryStoreOperationUsageInputTokensDetails(int cachedTokens = default) + { + return new MemoryStoreOperationUsageInputTokensDetails(cachedTokens, additionalBinaryDataProperties: null); + } + + /// The MemoryStoreOperationUsageOutputTokensDetails. + /// The number of reasoning tokens. + /// A new instance for mocking. + public static MemoryStoreOperationUsageOutputTokensDetails MemoryStoreOperationUsageOutputTokensDetails(int reasoningTokens = default) + { + return new MemoryStoreOperationUsageOutputTokensDetails(reasoningTokens, additionalBinaryDataProperties: null); + } + + /// Memory update result. + /// A list of individual memory operations that were performed during the update. + /// Usage statistics associated with the memory update operation. + /// A new instance for mocking. + public static MemoryUpdateResultDetails MemoryUpdateResultDetails(IEnumerable memoryOperations = default, MemoryStoreOperationUsage usage = default) + { + memoryOperations ??= new ChangeTrackingList(); + + return new MemoryUpdateResultDetails(memoryOperations.ToList(), usage, additionalBinaryDataProperties: null); + } + + /// Represents a single memory operation (create, update, or delete) performed on a memory item. + /// The type of memory operation being performed. + /// The memory item to create, update, or delete. + /// A new instance for mocking. + public static MemoryOperation MemoryOperation(MemoryOperationKind kind = default, MemoryItem memoryItem = default) + { + return new MemoryOperation(kind, memoryItem, additionalBinaryDataProperties: null); + } + + /// Response for deleting memories from a scope. + /// The name of the memory store. + /// The scope from which memories were deleted. + /// Whether the deletion operation was successful. + /// A new instance for mocking. + public static MemoryStoreDeleteScopeResponse MemoryStoreDeleteScopeResponse(string name = default, string scope = default, bool deleted = default) + { + return new MemoryStoreDeleteScopeResponse("memory_store.scope.deleted", name, scope, deleted, additionalBinaryDataProperties: null); + } + + /// The CreateAgentVersionFromManifestRequest. + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + /// A human-readable description of the agent. + /// The manifest ID to import the agent version from. + /// The inputs to the manifest that will result in a fully materialized Agent. + /// A new instance for mocking. + public static CreateAgentVersionFromManifestRequest CreateAgentVersionFromManifestRequest(IDictionary metadata = default, string description = default, string manifestId = default, IDictionary parameterValues = default) + { + metadata ??= new ChangeTrackingDictionary(); + parameterValues ??= new ChangeTrackingDictionary(); + + return new CreateAgentVersionFromManifestRequest(metadata, description, manifestId, parameterValues, additionalBinaryDataProperties: null); + } + /// Represents a request for a pending upload. /// If PendingUploadId is not provided, a random GUID will be used. /// Azure Storage Account connection name to use for generating temporary SAS token. diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchAgentTool.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchAgentTool.Serialization.cs new file mode 100644 index 000000000000..c91e06663e52 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchAgentTool.Serialization.cs @@ -0,0 +1,132 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// The input definition information for an Azure AI search tool as used to configure an agent. + internal partial class AzureAISearchAgentTool : InternalTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AzureAISearchAgentTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureAISearchAgentTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("azure_ai_search"u8); + writer.WriteObjectValue(AzureAiSearch, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + AzureAISearchAgentTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AzureAISearchAgentTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureAISearchAgentTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureAISearchAgentTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureAISearchAgentTool DeserializeAzureAISearchAgentTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + AzureAISearchToolResource azureAiSearch = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("azure_ai_search"u8)) + { + azureAiSearch = AzureAISearchToolResource.DeserializeAzureAISearchToolResource(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureAISearchAgentTool(@type, additionalBinaryDataProperties, azureAiSearch); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(AzureAISearchAgentTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AzureAISearchAgentTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AzureAISearchAgentTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAzureAISearchAgentTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureAISearchAgentTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchAgentTool.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchAgentTool.cs new file mode 100644 index 000000000000..6238603a7fee --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchAgentTool.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// The input definition information for an Azure AI search tool as used to configure an agent. + internal partial class AzureAISearchAgentTool : InternalTool + { + /// Initializes a new instance of . + /// The azure ai search index resource. + /// is null. + public AzureAISearchAgentTool(AzureAISearchToolResource azureAiSearch) : base(ToolType.AzureAiSearch) + { + Argument.AssertNotNull(azureAiSearch, nameof(azureAiSearch)); + + AzureAiSearch = azureAiSearch; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The azure ai search index resource. + internal AzureAISearchAgentTool(ToolType @type, IDictionary additionalBinaryDataProperties, AzureAISearchToolResource azureAiSearch) : base(@type, additionalBinaryDataProperties) + { + AzureAiSearch = azureAiSearch; + } + + /// The azure ai search index resource. + public AzureAISearchToolResource AzureAiSearch { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchQueryType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchQueryType.cs new file mode 100644 index 000000000000..d3193959dcdf --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchQueryType.cs @@ -0,0 +1,82 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// Available query types for Azure AI Search tool. + internal readonly partial struct AzureAISearchQueryType : IEquatable + { + private readonly string _value; + /// Query type `simple`. + private const string SimpleValue = "simple"; + /// Query type `semantic`. + private const string SemanticValue = "semantic"; + /// Query type `vector`. + private const string VectorValue = "vector"; + /// Query type `vector_simple_hybrid`. + private const string VectorSimpleHybridValue = "vector_simple_hybrid"; + /// Query type `vector_semantic_hybrid`. + private const string VectorSemanticHybridValue = "vector_semantic_hybrid"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public AzureAISearchQueryType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Query type `simple`. + public static AzureAISearchQueryType Simple { get; } = new AzureAISearchQueryType(SimpleValue); + + /// Query type `semantic`. + public static AzureAISearchQueryType Semantic { get; } = new AzureAISearchQueryType(SemanticValue); + + /// Query type `vector`. + public static AzureAISearchQueryType Vector { get; } = new AzureAISearchQueryType(VectorValue); + + /// Query type `vector_simple_hybrid`. + public static AzureAISearchQueryType VectorSimpleHybrid { get; } = new AzureAISearchQueryType(VectorSimpleHybridValue); + + /// Query type `vector_semantic_hybrid`. + public static AzureAISearchQueryType VectorSemanticHybrid { get; } = new AzureAISearchQueryType(VectorSemanticHybridValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(AzureAISearchQueryType left, AzureAISearchQueryType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(AzureAISearchQueryType left, AzureAISearchQueryType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator AzureAISearchQueryType(string value) => new AzureAISearchQueryType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator AzureAISearchQueryType?(string value) => value == null ? null : new AzureAISearchQueryType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AzureAISearchQueryType other && Equals(other); + + /// + public bool Equals(AzureAISearchQueryType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchToolResource.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchToolResource.Serialization.cs new file mode 100644 index 000000000000..fd1f4949fff2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchToolResource.Serialization.cs @@ -0,0 +1,149 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// A set of index resources used by the `azure_ai_search` tool. + internal partial class AzureAISearchToolResource : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AzureAISearchToolResource() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureAISearchToolResource)} does not support writing '{format}' format."); + } + writer.WritePropertyName("indexes"u8); + writer.WriteStartArray(); + foreach (AISearchIndexResource item in Indexes) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AzureAISearchToolResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AzureAISearchToolResource JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureAISearchToolResource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureAISearchToolResource(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureAISearchToolResource DeserializeAzureAISearchToolResource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList indexes = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("indexes"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(AISearchIndexResource.DeserializeAISearchIndexResource(item, options)); + } + indexes = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureAISearchToolResource(indexes, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(AzureAISearchToolResource)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AzureAISearchToolResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AzureAISearchToolResource PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAzureAISearchToolResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureAISearchToolResource)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchToolResource.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchToolResource.cs new file mode 100644 index 000000000000..f89cf0be6c1a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureAISearchToolResource.cs @@ -0,0 +1,48 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects +{ + /// A set of index resources used by the `azure_ai_search` tool. + internal partial class AzureAISearchToolResource + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// The indices attached to this agent. There can be a maximum of 1 index + /// resource attached to the agent. + /// + /// is null. + public AzureAISearchToolResource(IEnumerable indexes) + { + Argument.AssertNotNull(indexes, nameof(indexes)); + + Indexes = indexes.ToList(); + } + + /// Initializes a new instance of . + /// + /// The indices attached to this agent. There can be a maximum of 1 index + /// resource attached to the agent. + /// + /// Keeps track of any properties unknown to the library. + internal AzureAISearchToolResource(IList indexes, IDictionary additionalBinaryDataProperties) + { + Indexes = indexes; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// The indices attached to this agent. There can be a maximum of 1 index + /// resource attached to the agent. + /// + public IList Indexes { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionAgentTool.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionAgentTool.Serialization.cs new file mode 100644 index 000000000000..2c30242f3af0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionAgentTool.Serialization.cs @@ -0,0 +1,132 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// The input definition information for an Azure Function Tool, as used to configure an Agent. + internal partial class AzureFunctionAgentTool : InternalTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AzureFunctionAgentTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureFunctionAgentTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("azure_function"u8); + writer.WriteObjectValue(AzureFunction, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + AzureFunctionAgentTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AzureFunctionAgentTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureFunctionAgentTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureFunctionAgentTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureFunctionAgentTool DeserializeAzureFunctionAgentTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + AzureFunctionDefinition azureFunction = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("azure_function"u8)) + { + azureFunction = AzureFunctionDefinition.DeserializeAzureFunctionDefinition(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureFunctionAgentTool(@type, additionalBinaryDataProperties, azureFunction); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(AzureFunctionAgentTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AzureFunctionAgentTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AzureFunctionAgentTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAzureFunctionAgentTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureFunctionAgentTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionAgentTool.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionAgentTool.cs new file mode 100644 index 000000000000..0ff43821753f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionAgentTool.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// The input definition information for an Azure Function Tool, as used to configure an Agent. + internal partial class AzureFunctionAgentTool : InternalTool + { + /// Initializes a new instance of . + /// The Azure Function Tool definition. + /// is null. + public AzureFunctionAgentTool(AzureFunctionDefinition azureFunction) : base(ToolType.AzureFunction) + { + Argument.AssertNotNull(azureFunction, nameof(azureFunction)); + + AzureFunction = azureFunction; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The Azure Function Tool definition. + internal AzureFunctionAgentTool(ToolType @type, IDictionary additionalBinaryDataProperties, AzureFunctionDefinition azureFunction) : base(@type, additionalBinaryDataProperties) + { + AzureFunction = azureFunction; + } + + /// The Azure Function Tool definition. + public AzureFunctionDefinition AzureFunction { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionBinding.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionBinding.Serialization.cs new file mode 100644 index 000000000000..dd5595f80663 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionBinding.Serialization.cs @@ -0,0 +1,147 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The structure for keeping storage queue name and URI. + internal partial class AzureFunctionBinding : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AzureFunctionBinding() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureFunctionBinding)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + writer.WritePropertyName("storage_queue"u8); + writer.WriteObjectValue(StorageQueue, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AzureFunctionBinding IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AzureFunctionBinding JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureFunctionBinding)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureFunctionBinding(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureFunctionBinding DeserializeAzureFunctionBinding(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = default; + AzureFunctionStorageQueue storageQueue = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("storage_queue"u8)) + { + storageQueue = AzureFunctionStorageQueue.DeserializeAzureFunctionStorageQueue(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureFunctionBinding(@type, storageQueue, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(AzureFunctionBinding)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AzureFunctionBinding IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AzureFunctionBinding PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAzureFunctionBinding(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureFunctionBinding)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionBinding.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionBinding.cs new file mode 100644 index 000000000000..28448db0854a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionBinding.cs @@ -0,0 +1,43 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// The structure for keeping storage queue name and URI. + internal partial class AzureFunctionBinding + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Storage queue. + /// is null. + public AzureFunctionBinding(AzureFunctionStorageQueue storageQueue) + { + Argument.AssertNotNull(storageQueue, nameof(storageQueue)); + + StorageQueue = storageQueue; + } + + /// Initializes a new instance of . + /// The type of binding, which is always 'storage_queue'. + /// Storage queue. + /// Keeps track of any properties unknown to the library. + internal AzureFunctionBinding(string @type, AzureFunctionStorageQueue storageQueue, IDictionary additionalBinaryDataProperties) + { + Type = @type; + StorageQueue = storageQueue; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The type of binding, which is always 'storage_queue'. + public string Type { get; } = "storage_queue"; + + /// Storage queue. + public AzureFunctionStorageQueue StorageQueue { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionDefinition.Serialization.cs new file mode 100644 index 000000000000..5b0ab82faf5b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionDefinition.Serialization.cs @@ -0,0 +1,155 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The definition of Azure function. + internal partial class AzureFunctionDefinition : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AzureFunctionDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureFunctionDefinition)} does not support writing '{format}' format."); + } + writer.WritePropertyName("function"u8); + writer.WriteObjectValue(Function, options); + writer.WritePropertyName("input_binding"u8); + writer.WriteObjectValue(InputBinding, options); + writer.WritePropertyName("output_binding"u8); + writer.WriteObjectValue(OutputBinding, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AzureFunctionDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AzureFunctionDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureFunctionDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureFunctionDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureFunctionDefinition DeserializeAzureFunctionDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AzureFunctionDefinitionFunction function = default; + AzureFunctionBinding inputBinding = default; + AzureFunctionBinding outputBinding = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("function"u8)) + { + function = AzureFunctionDefinitionFunction.DeserializeAzureFunctionDefinitionFunction(prop.Value, options); + continue; + } + if (prop.NameEquals("input_binding"u8)) + { + inputBinding = AzureFunctionBinding.DeserializeAzureFunctionBinding(prop.Value, options); + continue; + } + if (prop.NameEquals("output_binding"u8)) + { + outputBinding = AzureFunctionBinding.DeserializeAzureFunctionBinding(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureFunctionDefinition(function, inputBinding, outputBinding, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(AzureFunctionDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AzureFunctionDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AzureFunctionDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAzureFunctionDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureFunctionDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionDefinition.cs new file mode 100644 index 000000000000..1da7d5eb488f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionDefinition.cs @@ -0,0 +1,54 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// The definition of Azure function. + internal partial class AzureFunctionDefinition + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The definition of azure function and its parameters. + /// Input storage queue. The queue storage trigger runs a function as messages are added to it. + /// Output storage queue. The function writes output to this queue when the input items are processed. + /// , or is null. + public AzureFunctionDefinition(AzureFunctionDefinitionFunction function, AzureFunctionBinding inputBinding, AzureFunctionBinding outputBinding) + { + Argument.AssertNotNull(function, nameof(function)); + Argument.AssertNotNull(inputBinding, nameof(inputBinding)); + Argument.AssertNotNull(outputBinding, nameof(outputBinding)); + + Function = function; + InputBinding = inputBinding; + OutputBinding = outputBinding; + } + + /// Initializes a new instance of . + /// The definition of azure function and its parameters. + /// Input storage queue. The queue storage trigger runs a function as messages are added to it. + /// Output storage queue. The function writes output to this queue when the input items are processed. + /// Keeps track of any properties unknown to the library. + internal AzureFunctionDefinition(AzureFunctionDefinitionFunction function, AzureFunctionBinding inputBinding, AzureFunctionBinding outputBinding, IDictionary additionalBinaryDataProperties) + { + Function = function; + InputBinding = inputBinding; + OutputBinding = outputBinding; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The definition of azure function and its parameters. + public AzureFunctionDefinitionFunction Function { get; set; } + + /// Input storage queue. The queue storage trigger runs a function as messages are added to it. + public AzureFunctionBinding InputBinding { get; set; } + + /// Output storage queue. The function writes output to this queue when the input items are processed. + public AzureFunctionBinding OutputBinding { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionDefinitionFunction.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionDefinitionFunction.Serialization.cs new file mode 100644 index 000000000000..8d63ebfdcfc4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionDefinitionFunction.Serialization.cs @@ -0,0 +1,165 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The AzureFunctionDefinitionFunction. + internal partial class AzureFunctionDefinitionFunction : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AzureFunctionDefinitionFunction() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureFunctionDefinitionFunction)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("parameters"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Parameters); +#else + using (JsonDocument document = JsonDocument.Parse(Parameters)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AzureFunctionDefinitionFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AzureFunctionDefinitionFunction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureFunctionDefinitionFunction)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureFunctionDefinitionFunction(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureFunctionDefinitionFunction DeserializeAzureFunctionDefinitionFunction(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string description = default; + BinaryData parameters = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("parameters"u8)) + { + parameters = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureFunctionDefinitionFunction(name, description, parameters, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(AzureFunctionDefinitionFunction)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AzureFunctionDefinitionFunction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AzureFunctionDefinitionFunction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAzureFunctionDefinitionFunction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureFunctionDefinitionFunction)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionDefinitionFunction.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionDefinitionFunction.cs new file mode 100644 index 000000000000..a7136e83936b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionDefinitionFunction.cs @@ -0,0 +1,77 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The AzureFunctionDefinitionFunction. + internal partial class AzureFunctionDefinitionFunction + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The name of the function to be called. + /// The parameters the functions accepts, described as a JSON Schema object. + /// or is null. + public AzureFunctionDefinitionFunction(string name, BinaryData parameters) + { + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(parameters, nameof(parameters)); + + Name = name; + Parameters = parameters; + } + + /// Initializes a new instance of . + /// The name of the function to be called. + /// A description of what the function does, used by the model to choose when and how to call the function. + /// The parameters the functions accepts, described as a JSON Schema object. + /// Keeps track of any properties unknown to the library. + internal AzureFunctionDefinitionFunction(string name, string description, BinaryData parameters, IDictionary additionalBinaryDataProperties) + { + Name = name; + Description = description; + Parameters = parameters; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The name of the function to be called. + public string Name { get; set; } + + /// A description of what the function does, used by the model to choose when and how to call the function. + public string Description { get; set; } + + /// + /// The parameters the functions accepts, described as a JSON Schema object. + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData Parameters { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionStorageQueue.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionStorageQueue.Serialization.cs new file mode 100644 index 000000000000..7e78f87add19 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionStorageQueue.Serialization.cs @@ -0,0 +1,147 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The structure for keeping storage queue name and URI. + internal partial class AzureFunctionStorageQueue : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AzureFunctionStorageQueue() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureFunctionStorageQueue)} does not support writing '{format}' format."); + } + writer.WritePropertyName("queue_service_endpoint"u8); + writer.WriteStringValue(QueueServiceEndpoint); + writer.WritePropertyName("queue_name"u8); + writer.WriteStringValue(QueueName); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + AzureFunctionStorageQueue IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual AzureFunctionStorageQueue JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureFunctionStorageQueue)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureFunctionStorageQueue(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureFunctionStorageQueue DeserializeAzureFunctionStorageQueue(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string queueServiceEndpoint = default; + string queueName = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("queue_service_endpoint"u8)) + { + queueServiceEndpoint = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("queue_name"u8)) + { + queueName = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureFunctionStorageQueue(queueServiceEndpoint, queueName, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(AzureFunctionStorageQueue)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AzureFunctionStorageQueue IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual AzureFunctionStorageQueue PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAzureFunctionStorageQueue(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureFunctionStorageQueue)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionStorageQueue.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionStorageQueue.cs new file mode 100644 index 000000000000..f3b144037c1f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureFunctionStorageQueue.cs @@ -0,0 +1,46 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// The structure for keeping storage queue name and URI. + internal partial class AzureFunctionStorageQueue + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// URI to the Azure Storage Queue service allowing you to manipulate a queue. + /// The name of an Azure function storage queue. + /// or is null. + public AzureFunctionStorageQueue(string queueServiceEndpoint, string queueName) + { + Argument.AssertNotNull(queueServiceEndpoint, nameof(queueServiceEndpoint)); + Argument.AssertNotNull(queueName, nameof(queueName)); + + QueueServiceEndpoint = queueServiceEndpoint; + QueueName = queueName; + } + + /// Initializes a new instance of . + /// URI to the Azure Storage Queue service allowing you to manipulate a queue. + /// The name of an Azure function storage queue. + /// Keeps track of any properties unknown to the library. + internal AzureFunctionStorageQueue(string queueServiceEndpoint, string queueName, IDictionary additionalBinaryDataProperties) + { + QueueServiceEndpoint = queueServiceEndpoint; + QueueName = queueName; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// URI to the Azure Storage Queue service allowing you to manipulate a queue. + public string QueueServiceEndpoint { get; set; } + + /// The name of an Azure function storage queue. + public string QueueName { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureOpenAIModelConfiguration.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureOpenAIModelConfiguration.Serialization.cs new file mode 100644 index 000000000000..71259411aa0c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureOpenAIModelConfiguration.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Azure OpenAI model configuration. The API version would be selected by the service for querying the model. + public partial class AzureOpenAIModelConfiguration : TargetConfig, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal AzureOpenAIModelConfiguration() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureOpenAIModelConfiguration)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("modelDeploymentName"u8); + writer.WriteStringValue(ModelDeploymentName); + } + + /// The JSON reader. + /// The client options for reading and writing models. + AzureOpenAIModelConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AzureOpenAIModelConfiguration)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override TargetConfig JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureOpenAIModelConfiguration)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureOpenAIModelConfiguration(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static AzureOpenAIModelConfiguration DeserializeAzureOpenAIModelConfiguration(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = "AzureOpenAIModel"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string modelDeploymentName = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("modelDeploymentName"u8)) + { + modelDeploymentName = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureOpenAIModelConfiguration(@type, additionalBinaryDataProperties, modelDeploymentName); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(AzureOpenAIModelConfiguration)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + AzureOpenAIModelConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AzureOpenAIModelConfiguration)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override TargetConfig PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeAzureOpenAIModelConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureOpenAIModelConfiguration)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AzureOpenAIModelConfiguration.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AzureOpenAIModelConfiguration.cs new file mode 100644 index 000000000000..6ab4af2f1741 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AzureOpenAIModelConfiguration.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Azure OpenAI model configuration. The API version would be selected by the service for querying the model. + public partial class AzureOpenAIModelConfiguration : TargetConfig + { + /// Initializes a new instance of . + /// Deployment name for AOAI model. Example: gpt-4o if in AIServices or connection based `connection_name/deployment_name` (e.g. `my-aoai-connection/gpt-4o`). + /// is null. + public AzureOpenAIModelConfiguration(string modelDeploymentName) : base("AzureOpenAIModel") + { + Argument.AssertNotNull(modelDeploymentName, nameof(modelDeploymentName)); + + ModelDeploymentName = modelDeploymentName; + } + + /// Initializes a new instance of . + /// Type of the model configuration. + /// Keeps track of any properties unknown to the library. + /// Deployment name for AOAI model. Example: gpt-4o if in AIServices or connection based `connection_name/deployment_name` (e.g. `my-aoai-connection/gpt-4o`). + internal AzureOpenAIModelConfiguration(string @type, IDictionary additionalBinaryDataProperties, string modelDeploymentName) : base(@type, additionalBinaryDataProperties) + { + ModelDeploymentName = modelDeploymentName; + } + + /// Deployment name for AOAI model. Example: gpt-4o if in AIServices or connection based `connection_name/deployment_name` (e.g. `my-aoai-connection/gpt-4o`). + public string ModelDeploymentName { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchAgentTool.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchAgentTool.Serialization.cs new file mode 100644 index 000000000000..cfb5b3860202 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchAgentTool.Serialization.cs @@ -0,0 +1,132 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// The input definition information for a Bing custom search tool as used to configure an agent. + internal partial class BingCustomSearchAgentTool : InternalTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BingCustomSearchAgentTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingCustomSearchAgentTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("bing_custom_search_preview"u8); + writer.WriteObjectValue(BingCustomSearchPreview, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + BingCustomSearchAgentTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (BingCustomSearchAgentTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingCustomSearchAgentTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBingCustomSearchAgentTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BingCustomSearchAgentTool DeserializeBingCustomSearchAgentTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + BingCustomSearchToolParameters bingCustomSearchPreview = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("bing_custom_search_preview"u8)) + { + bingCustomSearchPreview = BingCustomSearchToolParameters.DeserializeBingCustomSearchToolParameters(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BingCustomSearchAgentTool(@type, additionalBinaryDataProperties, bingCustomSearchPreview); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(BingCustomSearchAgentTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + BingCustomSearchAgentTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (BingCustomSearchAgentTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeBingCustomSearchAgentTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BingCustomSearchAgentTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchAgentTool.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchAgentTool.cs new file mode 100644 index 000000000000..444831e67543 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchAgentTool.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// The input definition information for a Bing custom search tool as used to configure an agent. + internal partial class BingCustomSearchAgentTool : InternalTool + { + /// Initializes a new instance of . + /// The bing custom search tool parameters. + /// is null. + public BingCustomSearchAgentTool(BingCustomSearchToolParameters bingCustomSearchPreview) : base(ToolType.BingCustomSearchPreview) + { + Argument.AssertNotNull(bingCustomSearchPreview, nameof(bingCustomSearchPreview)); + + BingCustomSearchPreview = bingCustomSearchPreview; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The bing custom search tool parameters. + internal BingCustomSearchAgentTool(ToolType @type, IDictionary additionalBinaryDataProperties, BingCustomSearchToolParameters bingCustomSearchPreview) : base(@type, additionalBinaryDataProperties) + { + BingCustomSearchPreview = bingCustomSearchPreview; + } + + /// The bing custom search tool parameters. + public BingCustomSearchToolParameters BingCustomSearchPreview { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchConfiguration.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchConfiguration.Serialization.cs new file mode 100644 index 000000000000..fe312158a8f4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchConfiguration.Serialization.cs @@ -0,0 +1,202 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// A bing custom search configuration. + internal partial class BingCustomSearchConfiguration : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BingCustomSearchConfiguration() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingCustomSearchConfiguration)} does not support writing '{format}' format."); + } + writer.WritePropertyName("project_connection_id"u8); + writer.WriteStringValue(ProjectConnectionId); + writer.WritePropertyName("instance_name"u8); + writer.WriteStringValue(InstanceName); + if (Optional.IsDefined(Market)) + { + writer.WritePropertyName("market"u8); + writer.WriteStringValue(Market); + } + if (Optional.IsDefined(SetLang)) + { + writer.WritePropertyName("set_lang"u8); + writer.WriteStringValue(SetLang); + } + if (Optional.IsDefined(Count)) + { + writer.WritePropertyName("count"u8); + writer.WriteNumberValue(Count.Value); + } + if (Optional.IsDefined(Freshness)) + { + writer.WritePropertyName("freshness"u8); + writer.WriteStringValue(Freshness); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + BingCustomSearchConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual BingCustomSearchConfiguration JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingCustomSearchConfiguration)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBingCustomSearchConfiguration(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BingCustomSearchConfiguration DeserializeBingCustomSearchConfiguration(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string projectConnectionId = default; + string instanceName = default; + string market = default; + string setLang = default; + long? count = default; + string freshness = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("project_connection_id"u8)) + { + projectConnectionId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("instance_name"u8)) + { + instanceName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("market"u8)) + { + market = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("set_lang"u8)) + { + setLang = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("count"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + count = prop.Value.GetInt64(); + continue; + } + if (prop.NameEquals("freshness"u8)) + { + freshness = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BingCustomSearchConfiguration( + projectConnectionId, + instanceName, + market, + setLang, + count, + freshness, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(BingCustomSearchConfiguration)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + BingCustomSearchConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual BingCustomSearchConfiguration PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeBingCustomSearchConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BingCustomSearchConfiguration)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchConfiguration.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchConfiguration.cs new file mode 100644 index 000000000000..6e94c63c9234 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchConfiguration.cs @@ -0,0 +1,66 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// A bing custom search configuration. + internal partial class BingCustomSearchConfiguration + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Project connection id for grounding with bing search. + /// Name of the custom configuration instance given to config. + /// or is null. + public BingCustomSearchConfiguration(string projectConnectionId, string instanceName) + { + Argument.AssertNotNull(projectConnectionId, nameof(projectConnectionId)); + Argument.AssertNotNull(instanceName, nameof(instanceName)); + + ProjectConnectionId = projectConnectionId; + InstanceName = instanceName; + } + + /// Initializes a new instance of . + /// Project connection id for grounding with bing search. + /// Name of the custom configuration instance given to config. + /// The market where the results come from. + /// The language to use for user interface strings when calling Bing API. + /// The number of search results to return in the bing api response. + /// Filter search results by a specific time range. See [accepted values here](https://learn.microsoft.com/bing/search-apis/bing-web-search/reference/query-parameters). + /// Keeps track of any properties unknown to the library. + internal BingCustomSearchConfiguration(string projectConnectionId, string instanceName, string market, string setLang, long? count, string freshness, IDictionary additionalBinaryDataProperties) + { + ProjectConnectionId = projectConnectionId; + InstanceName = instanceName; + Market = market; + SetLang = setLang; + Count = count; + Freshness = freshness; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Project connection id for grounding with bing search. + public string ProjectConnectionId { get; set; } + + /// Name of the custom configuration instance given to config. + public string InstanceName { get; set; } + + /// The market where the results come from. + public string Market { get; set; } + + /// The language to use for user interface strings when calling Bing API. + public string SetLang { get; set; } + + /// The number of search results to return in the bing api response. + public long? Count { get; set; } + + /// Filter search results by a specific time range. See [accepted values here](https://learn.microsoft.com/bing/search-apis/bing-web-search/reference/query-parameters). + public string Freshness { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchToolParameters.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchToolParameters.Serialization.cs new file mode 100644 index 000000000000..40ea47ae5e34 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchToolParameters.Serialization.cs @@ -0,0 +1,149 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The bing custom search tool parameters. + internal partial class BingCustomSearchToolParameters : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BingCustomSearchToolParameters() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingCustomSearchToolParameters)} does not support writing '{format}' format."); + } + writer.WritePropertyName("search_configurations"u8); + writer.WriteStartArray(); + foreach (BingCustomSearchConfiguration item in SearchConfigurations) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + BingCustomSearchToolParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual BingCustomSearchToolParameters JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingCustomSearchToolParameters)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBingCustomSearchToolParameters(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BingCustomSearchToolParameters DeserializeBingCustomSearchToolParameters(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList searchConfigurations = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("search_configurations"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(BingCustomSearchConfiguration.DeserializeBingCustomSearchConfiguration(item, options)); + } + searchConfigurations = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BingCustomSearchToolParameters(searchConfigurations, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(BingCustomSearchToolParameters)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + BingCustomSearchToolParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual BingCustomSearchToolParameters PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeBingCustomSearchToolParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BingCustomSearchToolParameters)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchToolParameters.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchToolParameters.cs new file mode 100644 index 000000000000..56f904f90d9f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchToolParameters.cs @@ -0,0 +1,48 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects +{ + /// The bing custom search tool parameters. + internal partial class BingCustomSearchToolParameters + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// The project connections attached to this tool. There can be a maximum of 1 connection + /// resource attached to the tool. + /// + /// is null. + public BingCustomSearchToolParameters(IEnumerable searchConfigurations) + { + Argument.AssertNotNull(searchConfigurations, nameof(searchConfigurations)); + + SearchConfigurations = searchConfigurations.ToList(); + } + + /// Initializes a new instance of . + /// + /// The project connections attached to this tool. There can be a maximum of 1 connection + /// resource attached to the tool. + /// + /// Keeps track of any properties unknown to the library. + internal BingCustomSearchToolParameters(IList searchConfigurations, IDictionary additionalBinaryDataProperties) + { + SearchConfigurations = searchConfigurations; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// The project connections attached to this tool. There can be a maximum of 1 connection + /// resource attached to the tool. + /// + public IList SearchConfigurations { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/BingGroundingAgentTool.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BingGroundingAgentTool.Serialization.cs new file mode 100644 index 000000000000..88dd7d839b16 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/BingGroundingAgentTool.Serialization.cs @@ -0,0 +1,132 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// The input definition information for a bing grounding search tool as used to configure an agent. + internal partial class BingGroundingAgentTool : InternalTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BingGroundingAgentTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingGroundingAgentTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("bing_grounding"u8); + writer.WriteObjectValue(BingGrounding, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + BingGroundingAgentTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (BingGroundingAgentTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingGroundingAgentTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBingGroundingAgentTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BingGroundingAgentTool DeserializeBingGroundingAgentTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + BingGroundingSearchToolParameters bingGrounding = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("bing_grounding"u8)) + { + bingGrounding = BingGroundingSearchToolParameters.DeserializeBingGroundingSearchToolParameters(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BingGroundingAgentTool(@type, additionalBinaryDataProperties, bingGrounding); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(BingGroundingAgentTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + BingGroundingAgentTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (BingGroundingAgentTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeBingGroundingAgentTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BingGroundingAgentTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/BingGroundingAgentTool.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BingGroundingAgentTool.cs new file mode 100644 index 000000000000..1e385fa30e45 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/BingGroundingAgentTool.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// The input definition information for a bing grounding search tool as used to configure an agent. + internal partial class BingGroundingAgentTool : InternalTool + { + /// Initializes a new instance of . + /// The bing grounding search tool parameters. + /// is null. + public BingGroundingAgentTool(BingGroundingSearchToolParameters bingGrounding) : base(ToolType.BingGrounding) + { + Argument.AssertNotNull(bingGrounding, nameof(bingGrounding)); + + BingGrounding = bingGrounding; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The bing grounding search tool parameters. + internal BingGroundingAgentTool(ToolType @type, IDictionary additionalBinaryDataProperties, BingGroundingSearchToolParameters bingGrounding) : base(@type, additionalBinaryDataProperties) + { + BingGrounding = bingGrounding; + } + + /// The bing grounding search tool parameters. + public BingGroundingSearchToolParameters BingGrounding { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/BingGroundingSearchConfiguration.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BingGroundingSearchConfiguration.Serialization.cs new file mode 100644 index 000000000000..2824daa693bb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/BingGroundingSearchConfiguration.Serialization.cs @@ -0,0 +1,193 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Search configuration for Bing Grounding. + internal partial class BingGroundingSearchConfiguration : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BingGroundingSearchConfiguration() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingGroundingSearchConfiguration)} does not support writing '{format}' format."); + } + writer.WritePropertyName("project_connection_id"u8); + writer.WriteStringValue(ProjectConnectionId); + if (Optional.IsDefined(Market)) + { + writer.WritePropertyName("market"u8); + writer.WriteStringValue(Market); + } + if (Optional.IsDefined(SetLang)) + { + writer.WritePropertyName("set_lang"u8); + writer.WriteStringValue(SetLang); + } + if (Optional.IsDefined(Count)) + { + writer.WritePropertyName("count"u8); + writer.WriteNumberValue(Count.Value); + } + if (Optional.IsDefined(Freshness)) + { + writer.WritePropertyName("freshness"u8); + writer.WriteStringValue(Freshness); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + BingGroundingSearchConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual BingGroundingSearchConfiguration JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingGroundingSearchConfiguration)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBingGroundingSearchConfiguration(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BingGroundingSearchConfiguration DeserializeBingGroundingSearchConfiguration(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string projectConnectionId = default; + string market = default; + string setLang = default; + long? count = default; + string freshness = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("project_connection_id"u8)) + { + projectConnectionId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("market"u8)) + { + market = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("set_lang"u8)) + { + setLang = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("count"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + count = prop.Value.GetInt64(); + continue; + } + if (prop.NameEquals("freshness"u8)) + { + freshness = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BingGroundingSearchConfiguration( + projectConnectionId, + market, + setLang, + count, + freshness, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(BingGroundingSearchConfiguration)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + BingGroundingSearchConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual BingGroundingSearchConfiguration PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeBingGroundingSearchConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BingGroundingSearchConfiguration)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/BingGroundingSearchConfiguration.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BingGroundingSearchConfiguration.cs new file mode 100644 index 000000000000..703b1cd586d9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/BingGroundingSearchConfiguration.cs @@ -0,0 +1,58 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Search configuration for Bing Grounding. + internal partial class BingGroundingSearchConfiguration + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Project connection id for grounding with bing search. + /// is null. + public BingGroundingSearchConfiguration(string projectConnectionId) + { + Argument.AssertNotNull(projectConnectionId, nameof(projectConnectionId)); + + ProjectConnectionId = projectConnectionId; + } + + /// Initializes a new instance of . + /// Project connection id for grounding with bing search. + /// The market where the results come from. + /// The language to use for user interface strings when calling Bing API. + /// The number of search results to return in the bing api response. + /// Filter search results by a specific time range. See [accepted values here](https://learn.microsoft.com/bing/search-apis/bing-web-search/reference/query-parameters). + /// Keeps track of any properties unknown to the library. + internal BingGroundingSearchConfiguration(string projectConnectionId, string market, string setLang, long? count, string freshness, IDictionary additionalBinaryDataProperties) + { + ProjectConnectionId = projectConnectionId; + Market = market; + SetLang = setLang; + Count = count; + Freshness = freshness; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Project connection id for grounding with bing search. + public string ProjectConnectionId { get; set; } + + /// The market where the results come from. + public string Market { get; set; } + + /// The language to use for user interface strings when calling Bing API. + public string SetLang { get; set; } + + /// The number of search results to return in the bing api response. + public long? Count { get; set; } + + /// Filter search results by a specific time range. See [accepted values here](https://learn.microsoft.com/bing/search-apis/bing-web-search/reference/query-parameters). + public string Freshness { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/BingGroundingSearchToolParameters.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BingGroundingSearchToolParameters.Serialization.cs new file mode 100644 index 000000000000..66b1ac9daf9d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/BingGroundingSearchToolParameters.Serialization.cs @@ -0,0 +1,149 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The bing grounding search tool parameters. + internal partial class BingGroundingSearchToolParameters : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BingGroundingSearchToolParameters() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingGroundingSearchToolParameters)} does not support writing '{format}' format."); + } + writer.WritePropertyName("search_configurations"u8); + writer.WriteStartArray(); + foreach (BingGroundingSearchConfiguration item in SearchConfigurations) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + BingGroundingSearchToolParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual BingGroundingSearchToolParameters JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BingGroundingSearchToolParameters)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBingGroundingSearchToolParameters(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BingGroundingSearchToolParameters DeserializeBingGroundingSearchToolParameters(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList searchConfigurations = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("search_configurations"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(BingGroundingSearchConfiguration.DeserializeBingGroundingSearchConfiguration(item, options)); + } + searchConfigurations = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BingGroundingSearchToolParameters(searchConfigurations, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(BingGroundingSearchToolParameters)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + BingGroundingSearchToolParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual BingGroundingSearchToolParameters PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeBingGroundingSearchToolParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BingGroundingSearchToolParameters)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/BingGroundingSearchToolParameters.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BingGroundingSearchToolParameters.cs new file mode 100644 index 000000000000..fe8f998cb056 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/BingGroundingSearchToolParameters.cs @@ -0,0 +1,48 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects +{ + /// The bing grounding search tool parameters. + internal partial class BingGroundingSearchToolParameters + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// The search configurations attached to this tool. There can be a maximum of 1 + /// search configuration resource attached to the tool. + /// + /// is null. + public BingGroundingSearchToolParameters(IEnumerable searchConfigurations) + { + Argument.AssertNotNull(searchConfigurations, nameof(searchConfigurations)); + + SearchConfigurations = searchConfigurations.ToList(); + } + + /// Initializes a new instance of . + /// + /// The search configurations attached to this tool. There can be a maximum of 1 + /// search configuration resource attached to the tool. + /// + /// Keeps track of any properties unknown to the library. + internal BingGroundingSearchToolParameters(IList searchConfigurations, IDictionary additionalBinaryDataProperties) + { + SearchConfigurations = searchConfigurations; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// The search configurations attached to this tool. There can be a maximum of 1 + /// search configuration resource attached to the tool. + /// + public IList SearchConfigurations { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/BrowserAutomationAgentTool.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BrowserAutomationAgentTool.Serialization.cs new file mode 100644 index 000000000000..1afc54e9190e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/BrowserAutomationAgentTool.Serialization.cs @@ -0,0 +1,132 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// The input definition information for a Browser Automation Tool, as used to configure an Agent. + internal partial class BrowserAutomationAgentTool : InternalTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BrowserAutomationAgentTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrowserAutomationAgentTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("browser_automation_preview"u8); + writer.WriteObjectValue(BrowserAutomationPreview, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + BrowserAutomationAgentTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (BrowserAutomationAgentTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrowserAutomationAgentTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrowserAutomationAgentTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BrowserAutomationAgentTool DeserializeBrowserAutomationAgentTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + BrowserAutomationToolParameters browserAutomationPreview = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("browser_automation_preview"u8)) + { + browserAutomationPreview = BrowserAutomationToolParameters.DeserializeBrowserAutomationToolParameters(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BrowserAutomationAgentTool(@type, additionalBinaryDataProperties, browserAutomationPreview); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(BrowserAutomationAgentTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + BrowserAutomationAgentTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (BrowserAutomationAgentTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeBrowserAutomationAgentTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrowserAutomationAgentTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/BrowserAutomationAgentTool.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BrowserAutomationAgentTool.cs new file mode 100644 index 000000000000..f8b1c4199809 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/BrowserAutomationAgentTool.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// The input definition information for a Browser Automation Tool, as used to configure an Agent. + internal partial class BrowserAutomationAgentTool : InternalTool + { + /// Initializes a new instance of . + /// The Browser Automation Tool parameters. + /// is null. + public BrowserAutomationAgentTool(BrowserAutomationToolParameters browserAutomationPreview) : base(ToolType.BrowserAutomationPreview) + { + Argument.AssertNotNull(browserAutomationPreview, nameof(browserAutomationPreview)); + + BrowserAutomationPreview = browserAutomationPreview; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The Browser Automation Tool parameters. + internal BrowserAutomationAgentTool(ToolType @type, IDictionary additionalBinaryDataProperties, BrowserAutomationToolParameters browserAutomationPreview) : base(@type, additionalBinaryDataProperties) + { + BrowserAutomationPreview = browserAutomationPreview; + } + + /// The Browser Automation Tool parameters. + public BrowserAutomationToolParameters BrowserAutomationPreview { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/BrowserAutomationToolConnectionParameters.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BrowserAutomationToolConnectionParameters.Serialization.cs new file mode 100644 index 000000000000..88476074f0b1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/BrowserAutomationToolConnectionParameters.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Definition of input parameters for the connection used by the Browser Automation Tool. + internal partial class BrowserAutomationToolConnectionParameters : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BrowserAutomationToolConnectionParameters() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrowserAutomationToolConnectionParameters)} does not support writing '{format}' format."); + } + writer.WritePropertyName("project_connection_id"u8); + writer.WriteStringValue(ProjectConnectionId); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + BrowserAutomationToolConnectionParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual BrowserAutomationToolConnectionParameters JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrowserAutomationToolConnectionParameters)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrowserAutomationToolConnectionParameters(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BrowserAutomationToolConnectionParameters DeserializeBrowserAutomationToolConnectionParameters(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string projectConnectionId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("project_connection_id"u8)) + { + projectConnectionId = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BrowserAutomationToolConnectionParameters(projectConnectionId, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(BrowserAutomationToolConnectionParameters)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + BrowserAutomationToolConnectionParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual BrowserAutomationToolConnectionParameters PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeBrowserAutomationToolConnectionParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrowserAutomationToolConnectionParameters)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/BrowserAutomationToolConnectionParameters.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BrowserAutomationToolConnectionParameters.cs new file mode 100644 index 000000000000..d231b1b79792 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/BrowserAutomationToolConnectionParameters.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Definition of input parameters for the connection used by the Browser Automation Tool. + internal partial class BrowserAutomationToolConnectionParameters + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The ID of the project connection to your Azure Playwright resource. + /// is null. + public BrowserAutomationToolConnectionParameters(string projectConnectionId) + { + Argument.AssertNotNull(projectConnectionId, nameof(projectConnectionId)); + + ProjectConnectionId = projectConnectionId; + } + + /// Initializes a new instance of . + /// The ID of the project connection to your Azure Playwright resource. + /// Keeps track of any properties unknown to the library. + internal BrowserAutomationToolConnectionParameters(string projectConnectionId, IDictionary additionalBinaryDataProperties) + { + ProjectConnectionId = projectConnectionId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The ID of the project connection to your Azure Playwright resource. + public string ProjectConnectionId { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/BrowserAutomationToolParameters.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BrowserAutomationToolParameters.Serialization.cs new file mode 100644 index 000000000000..9ba60ccca73f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/BrowserAutomationToolParameters.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Definition of input parameters for the Browser Automation Tool. + internal partial class BrowserAutomationToolParameters : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal BrowserAutomationToolParameters() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrowserAutomationToolParameters)} does not support writing '{format}' format."); + } + writer.WritePropertyName("connection"u8); + writer.WriteObjectValue(Connection, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + BrowserAutomationToolParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual BrowserAutomationToolParameters JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BrowserAutomationToolParameters)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBrowserAutomationToolParameters(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BrowserAutomationToolParameters DeserializeBrowserAutomationToolParameters(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BrowserAutomationToolConnectionParameters connection = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("connection"u8)) + { + connection = BrowserAutomationToolConnectionParameters.DeserializeBrowserAutomationToolConnectionParameters(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new BrowserAutomationToolParameters(connection, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(BrowserAutomationToolParameters)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + BrowserAutomationToolParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual BrowserAutomationToolParameters PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeBrowserAutomationToolParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BrowserAutomationToolParameters)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/BrowserAutomationToolParameters.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BrowserAutomationToolParameters.cs new file mode 100644 index 000000000000..548df8e8d28e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/BrowserAutomationToolParameters.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Definition of input parameters for the Browser Automation Tool. + internal partial class BrowserAutomationToolParameters + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The project connection parameters associated with the Browser Automation Tool. + /// is null. + public BrowserAutomationToolParameters(BrowserAutomationToolConnectionParameters connection) + { + Argument.AssertNotNull(connection, nameof(connection)); + + Connection = connection; + } + + /// Initializes a new instance of . + /// The project connection parameters associated with the Browser Automation Tool. + /// Keeps track of any properties unknown to the library. + internal BrowserAutomationToolParameters(BrowserAutomationToolConnectionParameters connection, IDictionary additionalBinaryDataProperties) + { + Connection = connection; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The project connection parameters associated with the Browser Automation Tool. + public BrowserAutomationToolConnectionParameters Connection { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CaptureStructuredOutputsTool.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CaptureStructuredOutputsTool.Serialization.cs new file mode 100644 index 000000000000..9300fd2e3cb7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CaptureStructuredOutputsTool.Serialization.cs @@ -0,0 +1,132 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// A tool for capturing structured outputs. + internal partial class CaptureStructuredOutputsTool : InternalTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal CaptureStructuredOutputsTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CaptureStructuredOutputsTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("outputs"u8); + writer.WriteObjectValue(Outputs, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + CaptureStructuredOutputsTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (CaptureStructuredOutputsTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CaptureStructuredOutputsTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCaptureStructuredOutputsTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static CaptureStructuredOutputsTool DeserializeCaptureStructuredOutputsTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + StructuredOutputDefinition outputs = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("outputs"u8)) + { + outputs = StructuredOutputDefinition.DeserializeStructuredOutputDefinition(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new CaptureStructuredOutputsTool(@type, additionalBinaryDataProperties, outputs); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(CaptureStructuredOutputsTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + CaptureStructuredOutputsTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (CaptureStructuredOutputsTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeCaptureStructuredOutputsTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CaptureStructuredOutputsTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CaptureStructuredOutputsTool.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CaptureStructuredOutputsTool.cs new file mode 100644 index 000000000000..2dd2108e7f66 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CaptureStructuredOutputsTool.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// A tool for capturing structured outputs. + internal partial class CaptureStructuredOutputsTool : InternalTool + { + /// Initializes a new instance of . + /// The structured outputs to capture from the model. + /// is null. + public CaptureStructuredOutputsTool(StructuredOutputDefinition outputs) : base(ToolType.CaptureStructuredOutputs) + { + Argument.AssertNotNull(outputs, nameof(outputs)); + + Outputs = outputs; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The structured outputs to capture from the model. + internal CaptureStructuredOutputsTool(ToolType @type, IDictionary additionalBinaryDataProperties, StructuredOutputDefinition outputs) : base(@type, additionalBinaryDataProperties) + { + Outputs = outputs; + } + + /// The structured outputs to capture from the model. + public StructuredOutputDefinition Outputs { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ChartCoordinate.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ChartCoordinate.Serialization.cs new file mode 100644 index 000000000000..92db4905f0f7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ChartCoordinate.Serialization.cs @@ -0,0 +1,155 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Coordinates for the analysis chart. + public partial class ChartCoordinate : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ChartCoordinate() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ChartCoordinate)} does not support writing '{format}' format."); + } + writer.WritePropertyName("x"u8); + writer.WriteNumberValue(X); + writer.WritePropertyName("y"u8); + writer.WriteNumberValue(Y); + writer.WritePropertyName("size"u8); + writer.WriteNumberValue(Size); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ChartCoordinate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ChartCoordinate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ChartCoordinate)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChartCoordinate(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ChartCoordinate DeserializeChartCoordinate(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int x = default; + int y = default; + int size = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("x"u8)) + { + x = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("y"u8)) + { + y = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("size"u8)) + { + size = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ChartCoordinate(x, y, size, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(ChartCoordinate)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ChartCoordinate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ChartCoordinate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeChartCoordinate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChartCoordinate)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ChartCoordinate.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ChartCoordinate.cs new file mode 100644 index 000000000000..52c4c8407527 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ChartCoordinate.cs @@ -0,0 +1,49 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Coordinates for the analysis chart. + public partial class ChartCoordinate + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// X-axis coordinate. + /// Y-axis coordinate. + /// Size of the chart element. + internal ChartCoordinate(int x, int y, int size) + { + X = x; + Y = y; + Size = size; + } + + /// Initializes a new instance of . + /// X-axis coordinate. + /// Y-axis coordinate. + /// Size of the chart element. + /// Keeps track of any properties unknown to the library. + internal ChartCoordinate(int x, int y, int size, IDictionary additionalBinaryDataProperties) + { + X = x; + Y = y; + Size = size; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// X-axis coordinate. + public int X { get; } + + /// Y-axis coordinate. + public int Y { get; } + + /// Size of the chart element. + public int Size { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ChatSummaryMemoryItem.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ChatSummaryMemoryItem.Serialization.cs new file mode 100644 index 000000000000..50a229a7c619 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ChatSummaryMemoryItem.Serialization.cs @@ -0,0 +1,153 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// A memory item containing a summary extracted from conversations. + public partial class ChatSummaryMemoryItem : MemoryItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ChatSummaryMemoryItem() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ChatSummaryMemoryItem)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + ChatSummaryMemoryItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (ChatSummaryMemoryItem)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override MemoryItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ChatSummaryMemoryItem)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatSummaryMemoryItem(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ChatSummaryMemoryItem DeserializeChatSummaryMemoryItem(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string memoryId = default; + DateTimeOffset updatedAt = default; + string scope = default; + string content = default; + MemoryItemKind kind = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("memory_id"u8)) + { + memoryId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("updated_at"u8)) + { + updatedAt = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64()); + continue; + } + if (prop.NameEquals("scope"u8)) + { + scope = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("content"u8)) + { + content = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("kind"u8)) + { + kind = new MemoryItemKind(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ChatSummaryMemoryItem( + memoryId, + updatedAt, + scope, + content, + kind, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(ChatSummaryMemoryItem)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ChatSummaryMemoryItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (ChatSummaryMemoryItem)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override MemoryItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeChatSummaryMemoryItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatSummaryMemoryItem)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ChatSummaryMemoryItem.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ChatSummaryMemoryItem.cs new file mode 100644 index 000000000000..4a2df1a05fb2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ChatSummaryMemoryItem.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// A memory item containing a summary extracted from conversations. + public partial class ChatSummaryMemoryItem : MemoryItem + { + /// Initializes a new instance of . + /// The unique ID of the memory item. + /// The last update time of the memory item. + /// The namespace that logically groups and isolates memories, such as a user ID. + /// The content of the memory. + /// , or is null. + public ChatSummaryMemoryItem(string memoryId, DateTimeOffset updatedAt, string scope, string content) : base(memoryId, updatedAt, scope, content, MemoryItemKind.ChatSummary) + { + Argument.AssertNotNull(memoryId, nameof(memoryId)); + Argument.AssertNotNull(scope, nameof(scope)); + Argument.AssertNotNull(content, nameof(content)); + + } + + /// Initializes a new instance of . + /// The unique ID of the memory item. + /// The last update time of the memory item. + /// The namespace that logically groups and isolates memories, such as a user ID. + /// The content of the memory. + /// The kind of the memory item. + /// Keeps track of any properties unknown to the library. + internal ChatSummaryMemoryItem(string memoryId, DateTimeOffset updatedAt, string scope, string content, MemoryItemKind kind, IDictionary additionalBinaryDataProperties) : base(memoryId, updatedAt, scope, content, kind, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ClusterInsightResult.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ClusterInsightResult.Serialization.cs new file mode 100644 index 000000000000..eb42a2489e55 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ClusterInsightResult.Serialization.cs @@ -0,0 +1,183 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Insights from the cluster analysis. + public partial class ClusterInsightResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ClusterInsightResult() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ClusterInsightResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("summary"u8); + writer.WriteObjectValue(Summary, options); + writer.WritePropertyName("clusters"u8); + writer.WriteStartArray(); + foreach (InsightCluster item in Clusters) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsCollectionDefined(Coordinates)) + { + writer.WritePropertyName("coordinates"u8); + writer.WriteStartObject(); + foreach (var item in Coordinates) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ClusterInsightResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ClusterInsightResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ClusterInsightResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeClusterInsightResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ClusterInsightResult DeserializeClusterInsightResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InsightSummary summary = default; + IList clusters = default; + IDictionary coordinates = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("summary"u8)) + { + summary = InsightSummary.DeserializeInsightSummary(prop.Value, options); + continue; + } + if (prop.NameEquals("clusters"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InsightCluster.DeserializeInsightCluster(item, options)); + } + clusters = array; + continue; + } + if (prop.NameEquals("coordinates"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + dictionary.Add(prop0.Name, ChartCoordinate.DeserializeChartCoordinate(prop0.Value, options)); + } + coordinates = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ClusterInsightResult(summary, clusters, coordinates ?? new ChangeTrackingDictionary(), additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(ClusterInsightResult)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ClusterInsightResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ClusterInsightResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeClusterInsightResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ClusterInsightResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ClusterInsightResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ClusterInsightResult.cs new file mode 100644 index 000000000000..7dfe6f01d8ed --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ClusterInsightResult.cs @@ -0,0 +1,87 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects +{ + /// Insights from the cluster analysis. + public partial class ClusterInsightResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Summary of the insights report. + /// List of clusters identified in the insights. + internal ClusterInsightResult(InsightSummary summary, IEnumerable clusters) + { + Summary = summary; + Clusters = clusters.ToList(); + Coordinates = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Summary of the insights report. + /// List of clusters identified in the insights. + /// + /// Optional mapping of IDs to 2D coordinates used by the UX for visualization. + /// + /// The map keys are string identifiers (for example, a cluster id or a sample id) + /// and the values are the coordinates and visual size for rendering on a 2D chart. + /// + /// This property is omitted unless the client requests coordinates (for example, + /// by passing `includeCoordinates=true` as a query parameter). + /// + /// Example: + /// ``` + /// { + /// "cluster-1": { "x": 12, "y": 34, "size": 8 }, + /// "sample-123": { "x": 18, "y": 22, "size": 4 } + /// } + /// ``` + /// + /// Coordinates are intended only for client-side visualization and do not + /// modify the canonical insights results. + /// + /// Keeps track of any properties unknown to the library. + internal ClusterInsightResult(InsightSummary summary, IList clusters, IDictionary coordinates, IDictionary additionalBinaryDataProperties) + { + Summary = summary; + Clusters = clusters; + Coordinates = coordinates; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Summary of the insights report. + public InsightSummary Summary { get; } + + /// List of clusters identified in the insights. + public IList Clusters { get; } + + /// + /// Optional mapping of IDs to 2D coordinates used by the UX for visualization. + /// + /// The map keys are string identifiers (for example, a cluster id or a sample id) + /// and the values are the coordinates and visual size for rendering on a 2D chart. + /// + /// This property is omitted unless the client requests coordinates (for example, + /// by passing `includeCoordinates=true` as a query parameter). + /// + /// Example: + /// ``` + /// { + /// "cluster-1": { "x": 12, "y": 34, "size": 8 }, + /// "sample-123": { "x": 18, "y": 22, "size": 4 } + /// } + /// ``` + /// + /// Coordinates are intended only for client-side visualization and do not + /// modify the canonical insights results. + /// + public IDictionary Coordinates { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ClusterTokenUsage.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ClusterTokenUsage.Serialization.cs new file mode 100644 index 000000000000..519e7367b9f3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ClusterTokenUsage.Serialization.cs @@ -0,0 +1,155 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Token usage for cluster analysis. + public partial class ClusterTokenUsage : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ClusterTokenUsage() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ClusterTokenUsage)} does not support writing '{format}' format."); + } + writer.WritePropertyName("inputTokenUsage"u8); + writer.WriteNumberValue(InputTokenUsage); + writer.WritePropertyName("outputTokenUsage"u8); + writer.WriteNumberValue(OutputTokenUsage); + writer.WritePropertyName("totalTokenUsage"u8); + writer.WriteNumberValue(TotalTokenUsage); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ClusterTokenUsage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ClusterTokenUsage JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ClusterTokenUsage)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeClusterTokenUsage(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ClusterTokenUsage DeserializeClusterTokenUsage(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int inputTokenUsage = default; + int outputTokenUsage = default; + int totalTokenUsage = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("inputTokenUsage"u8)) + { + inputTokenUsage = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("outputTokenUsage"u8)) + { + outputTokenUsage = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("totalTokenUsage"u8)) + { + totalTokenUsage = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ClusterTokenUsage(inputTokenUsage, outputTokenUsage, totalTokenUsage, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(ClusterTokenUsage)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ClusterTokenUsage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ClusterTokenUsage PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeClusterTokenUsage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ClusterTokenUsage)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ClusterTokenUsage.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ClusterTokenUsage.cs new file mode 100644 index 000000000000..c44eb11f3d46 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ClusterTokenUsage.cs @@ -0,0 +1,49 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Token usage for cluster analysis. + public partial class ClusterTokenUsage + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// input token usage. + /// output token usage. + /// total token usage. + internal ClusterTokenUsage(int inputTokenUsage, int outputTokenUsage, int totalTokenUsage) + { + InputTokenUsage = inputTokenUsage; + OutputTokenUsage = outputTokenUsage; + TotalTokenUsage = totalTokenUsage; + } + + /// Initializes a new instance of . + /// input token usage. + /// output token usage. + /// total token usage. + /// Keeps track of any properties unknown to the library. + internal ClusterTokenUsage(int inputTokenUsage, int outputTokenUsage, int totalTokenUsage, IDictionary additionalBinaryDataProperties) + { + InputTokenUsage = inputTokenUsage; + OutputTokenUsage = outputTokenUsage; + TotalTokenUsage = totalTokenUsage; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// input token usage. + public int InputTokenUsage { get; } + + /// output token usage. + public int OutputTokenUsage { get; } + + /// total token usage. + public int TotalTokenUsage { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CodeBasedEvaluatorDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CodeBasedEvaluatorDefinition.Serialization.cs new file mode 100644 index 000000000000..7307107a9f90 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CodeBasedEvaluatorDefinition.Serialization.cs @@ -0,0 +1,172 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Code-based evaluator definition using python code. + public partial class CodeBasedEvaluatorDefinition : EvaluatorDefinition, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal CodeBasedEvaluatorDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CodeBasedEvaluatorDefinition)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("code_text"u8); + writer.WriteStringValue(CodeText); + } + + /// The JSON reader. + /// The client options for reading and writing models. + CodeBasedEvaluatorDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (CodeBasedEvaluatorDefinition)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override EvaluatorDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CodeBasedEvaluatorDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCodeBasedEvaluatorDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static CodeBasedEvaluatorDefinition DeserializeCodeBasedEvaluatorDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + EvaluatorDefinitionType @type = default; + BinaryData initParameters = default; + BinaryData dataSchema = default; + IDictionary metrics = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string codeText = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new EvaluatorDefinitionType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("init_parameters"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + initParameters = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("data_schema"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dataSchema = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("metrics"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + dictionary.Add(prop0.Name, EvaluatorMetric.DeserializeEvaluatorMetric(prop0.Value, options)); + } + metrics = dictionary; + continue; + } + if (prop.NameEquals("code_text"u8)) + { + codeText = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new CodeBasedEvaluatorDefinition( + @type, + initParameters, + dataSchema, + metrics ?? new ChangeTrackingDictionary(), + additionalBinaryDataProperties, + codeText); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(CodeBasedEvaluatorDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + CodeBasedEvaluatorDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (CodeBasedEvaluatorDefinition)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override EvaluatorDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeCodeBasedEvaluatorDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CodeBasedEvaluatorDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CodeBasedEvaluatorDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CodeBasedEvaluatorDefinition.cs new file mode 100644 index 000000000000..bf34e86e2dfe --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CodeBasedEvaluatorDefinition.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Code-based evaluator definition using python code. + public partial class CodeBasedEvaluatorDefinition : EvaluatorDefinition + { + /// Initializes a new instance of . + /// Inline code text for the evaluator. + /// is null. + public CodeBasedEvaluatorDefinition(string codeText) : base(EvaluatorDefinitionType.Code) + { + Argument.AssertNotNull(codeText, nameof(codeText)); + + CodeText = codeText; + } + + /// Initializes a new instance of . + /// The type of evaluator definition. + /// The JSON schema (Draft 2020-12) for the evaluator's input parameters. This includes parameters like type, properties, required. + /// The JSON schema (Draft 2020-12) for the evaluator's input data. This includes parameters like type, properties, required. + /// List of output metrics produced by this evaluator. + /// Keeps track of any properties unknown to the library. + /// Inline code text for the evaluator. + internal CodeBasedEvaluatorDefinition(EvaluatorDefinitionType @type, BinaryData initParameters, BinaryData dataSchema, IDictionary metrics, IDictionary additionalBinaryDataProperties, string codeText) : base(@type, initParameters, dataSchema, metrics, additionalBinaryDataProperties) + { + CodeText = codeText; + } + + /// Inline code text for the evaluator. + public string CodeText { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CodeInterpreterOutputType.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CodeInterpreterOutputType.Serialization.cs new file mode 100644 index 000000000000..7135b4f06aa0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CodeInterpreterOutputType.Serialization.cs @@ -0,0 +1,33 @@ +// + +#nullable disable + +using System; + +namespace OpenAI +{ + internal static partial class CodeInterpreterOutputTypeExtensions + { + /// The value to serialize. + public static string ToSerialString(this CodeInterpreterOutputType value) => value switch + { + CodeInterpreterOutputType.Logs => "logs", + CodeInterpreterOutputType.Image => "image", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown CodeInterpreterOutputType value.") + }; + + /// The value to deserialize. + public static CodeInterpreterOutputType ToCodeInterpreterOutputType(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "logs")) + { + return CodeInterpreterOutputType.Logs; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "image")) + { + return CodeInterpreterOutputType.Image; + } + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown CodeInterpreterOutputType value."); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CodeInterpreterOutputType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CodeInterpreterOutputType.cs new file mode 100644 index 000000000000..248d68672c81 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CodeInterpreterOutputType.cs @@ -0,0 +1,15 @@ +// + +#nullable disable + +namespace OpenAI +{ + /// + internal enum CodeInterpreterOutputType + { + /// Logs. + Logs, + /// Image. + Image + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluationRulesGetAllAsyncCollectionResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluationRulesGetAllAsyncCollectionResult.cs new file mode 100644 index 000000000000..ce18f5e148f4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluationRulesGetAllAsyncCollectionResult.cs @@ -0,0 +1,72 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + internal partial class EvaluationRulesGetAllAsyncCollectionResult : AsyncCollectionResult + { + private readonly EvaluationRules _client; + private readonly string _actionType; + private readonly string _agentName; + private readonly bool? _enabled; + private readonly RequestOptions _options; + + /// Initializes a new instance of EvaluationRulesGetAllAsyncCollectionResult, which is used to iterate over the pages of a collection. + /// The EvaluationRules client used to send requests. + /// Filter by the type of evaluation rule. + /// Filter by the agent name. + /// Filter by the enabled status. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public EvaluationRulesGetAllAsyncCollectionResult(EvaluationRules client, string actionType, string agentName, bool? enabled, RequestOptions options) + { + _client = client; + _actionType = actionType; + _agentName = agentName; + _enabled = enabled; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override async IAsyncEnumerable GetRawPagesAsync() + { + PipelineMessage message = _client.CreateGetAllRequest(_actionType, _agentName, _enabled, _options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + yield return result; + + nextPageUri = ((PagedEvaluationRule)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetAllRequest(nextPageUri, _actionType, _agentName, _enabled, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedEvaluationRule)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluationRulesGetAllAsyncCollectionResultOfT.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluationRulesGetAllAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..c17f066cec75 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluationRulesGetAllAsyncCollectionResultOfT.cs @@ -0,0 +1,85 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + internal partial class EvaluationRulesGetAllAsyncCollectionResultOfT : AsyncCollectionResult + { + private readonly EvaluationRules _client; + private readonly string _actionType; + private readonly string _agentName; + private readonly bool? _enabled; + private readonly RequestOptions _options; + + /// Initializes a new instance of EvaluationRulesGetAllAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The EvaluationRules client used to send requests. + /// Filter by the type of evaluation rule. + /// Filter by the agent name. + /// Filter by the enabled status. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public EvaluationRulesGetAllAsyncCollectionResultOfT(EvaluationRules client, string actionType, string agentName, bool? enabled, RequestOptions options) + { + _client = client; + _actionType = actionType; + _agentName = agentName; + _enabled = enabled; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override async IAsyncEnumerable GetRawPagesAsync() + { + PipelineMessage message = _client.CreateGetAllRequest(_actionType, _agentName, _enabled, _options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + yield return result; + + nextPageUri = ((PagedEvaluationRule)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetAllRequest(nextPageUri, _actionType, _agentName, _enabled, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedEvaluationRule)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + + /// Gets the values from the specified page. + /// + /// The values from the specified page. + protected override async IAsyncEnumerable GetValuesFromPageAsync(ClientResult page) + { + foreach (EvaluationRule item in ((PagedEvaluationRule)page).Value) + { + yield return item; + await Task.Yield(); + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluationRulesGetAllCollectionResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluationRulesGetAllCollectionResult.cs new file mode 100644 index 000000000000..198a6fca03b2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluationRulesGetAllCollectionResult.cs @@ -0,0 +1,72 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + internal partial class EvaluationRulesGetAllCollectionResult : CollectionResult + { + private readonly EvaluationRules _client; + private readonly string _actionType; + private readonly string _agentName; + private readonly bool? _enabled; + private readonly RequestOptions _options; + + /// Initializes a new instance of EvaluationRulesGetAllCollectionResult, which is used to iterate over the pages of a collection. + /// The EvaluationRules client used to send requests. + /// Filter by the type of evaluation rule. + /// Filter by the agent name. + /// Filter by the enabled status. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public EvaluationRulesGetAllCollectionResult(EvaluationRules client, string actionType, string agentName, bool? enabled, RequestOptions options) + { + _client = client; + _actionType = actionType; + _agentName = agentName; + _enabled = enabled; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override IEnumerable GetRawPages() + { + PipelineMessage message = _client.CreateGetAllRequest(_actionType, _agentName, _enabled, _options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + yield return result; + + nextPageUri = ((PagedEvaluationRule)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetAllRequest(nextPageUri, _actionType, _agentName, _enabled, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedEvaluationRule)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluationRulesGetAllCollectionResultOfT.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluationRulesGetAllCollectionResultOfT.cs new file mode 100644 index 000000000000..de9e8d7efe8e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluationRulesGetAllCollectionResultOfT.cs @@ -0,0 +1,80 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + internal partial class EvaluationRulesGetAllCollectionResultOfT : CollectionResult + { + private readonly EvaluationRules _client; + private readonly string _actionType; + private readonly string _agentName; + private readonly bool? _enabled; + private readonly RequestOptions _options; + + /// Initializes a new instance of EvaluationRulesGetAllCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The EvaluationRules client used to send requests. + /// Filter by the type of evaluation rule. + /// Filter by the agent name. + /// Filter by the enabled status. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public EvaluationRulesGetAllCollectionResultOfT(EvaluationRules client, string actionType, string agentName, bool? enabled, RequestOptions options) + { + _client = client; + _actionType = actionType; + _agentName = agentName; + _enabled = enabled; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override IEnumerable GetRawPages() + { + PipelineMessage message = _client.CreateGetAllRequest(_actionType, _agentName, _enabled, _options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + yield return result; + + nextPageUri = ((PagedEvaluationRule)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetAllRequest(nextPageUri, _actionType, _agentName, _enabled, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedEvaluationRule)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + + /// Gets the values from the specified page. + /// + /// The values from the specified page. + protected override IEnumerable GetValuesFromPage(ClientResult page) + { + return ((PagedEvaluationRule)page).Value; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluationTaxonomiesGetAllAsyncCollectionResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluationTaxonomiesGetAllAsyncCollectionResult.cs new file mode 100644 index 000000000000..3f798c2ecd46 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluationTaxonomiesGetAllAsyncCollectionResult.cs @@ -0,0 +1,69 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + internal partial class EvaluationTaxonomiesGetAllAsyncCollectionResult : AsyncCollectionResult + { + private readonly EvaluationTaxonomies _client; + private readonly string _inputName; + private readonly string _inputType; + private readonly RequestOptions _options; + + /// Initializes a new instance of EvaluationTaxonomiesGetAllAsyncCollectionResult, which is used to iterate over the pages of a collection. + /// The EvaluationTaxonomies client used to send requests. + /// Filter by the evaluation input name. + /// Filter by taxonomy input type. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public EvaluationTaxonomiesGetAllAsyncCollectionResult(EvaluationTaxonomies client, string inputName, string inputType, RequestOptions options) + { + _client = client; + _inputName = inputName; + _inputType = inputType; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override async IAsyncEnumerable GetRawPagesAsync() + { + PipelineMessage message = _client.CreateGetAllRequest(_inputName, _inputType, _options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + yield return result; + + nextPageUri = ((PagedEvaluationTaxonomy)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetAllRequest(nextPageUri, _inputName, _inputType, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedEvaluationTaxonomy)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluationTaxonomiesGetAllAsyncCollectionResultOfT.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluationTaxonomiesGetAllAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..4122cd40dcdc --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluationTaxonomiesGetAllAsyncCollectionResultOfT.cs @@ -0,0 +1,82 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + internal partial class EvaluationTaxonomiesGetAllAsyncCollectionResultOfT : AsyncCollectionResult + { + private readonly EvaluationTaxonomies _client; + private readonly string _inputName; + private readonly string _inputType; + private readonly RequestOptions _options; + + /// Initializes a new instance of EvaluationTaxonomiesGetAllAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The EvaluationTaxonomies client used to send requests. + /// Filter by the evaluation input name. + /// Filter by taxonomy input type. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public EvaluationTaxonomiesGetAllAsyncCollectionResultOfT(EvaluationTaxonomies client, string inputName, string inputType, RequestOptions options) + { + _client = client; + _inputName = inputName; + _inputType = inputType; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override async IAsyncEnumerable GetRawPagesAsync() + { + PipelineMessage message = _client.CreateGetAllRequest(_inputName, _inputType, _options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + yield return result; + + nextPageUri = ((PagedEvaluationTaxonomy)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetAllRequest(nextPageUri, _inputName, _inputType, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedEvaluationTaxonomy)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + + /// Gets the values from the specified page. + /// + /// The values from the specified page. + protected override async IAsyncEnumerable GetValuesFromPageAsync(ClientResult page) + { + foreach (EvaluationTaxonomy item in ((PagedEvaluationTaxonomy)page).Value) + { + yield return item; + await Task.Yield(); + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluationTaxonomiesGetAllCollectionResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluationTaxonomiesGetAllCollectionResult.cs new file mode 100644 index 000000000000..2823c48a0ce0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluationTaxonomiesGetAllCollectionResult.cs @@ -0,0 +1,69 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + internal partial class EvaluationTaxonomiesGetAllCollectionResult : CollectionResult + { + private readonly EvaluationTaxonomies _client; + private readonly string _inputName; + private readonly string _inputType; + private readonly RequestOptions _options; + + /// Initializes a new instance of EvaluationTaxonomiesGetAllCollectionResult, which is used to iterate over the pages of a collection. + /// The EvaluationTaxonomies client used to send requests. + /// Filter by the evaluation input name. + /// Filter by taxonomy input type. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public EvaluationTaxonomiesGetAllCollectionResult(EvaluationTaxonomies client, string inputName, string inputType, RequestOptions options) + { + _client = client; + _inputName = inputName; + _inputType = inputType; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override IEnumerable GetRawPages() + { + PipelineMessage message = _client.CreateGetAllRequest(_inputName, _inputType, _options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + yield return result; + + nextPageUri = ((PagedEvaluationTaxonomy)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetAllRequest(nextPageUri, _inputName, _inputType, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedEvaluationTaxonomy)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluationTaxonomiesGetAllCollectionResultOfT.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluationTaxonomiesGetAllCollectionResultOfT.cs new file mode 100644 index 000000000000..f50bc5a743c6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluationTaxonomiesGetAllCollectionResultOfT.cs @@ -0,0 +1,77 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + internal partial class EvaluationTaxonomiesGetAllCollectionResultOfT : CollectionResult + { + private readonly EvaluationTaxonomies _client; + private readonly string _inputName; + private readonly string _inputType; + private readonly RequestOptions _options; + + /// Initializes a new instance of EvaluationTaxonomiesGetAllCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The EvaluationTaxonomies client used to send requests. + /// Filter by the evaluation input name. + /// Filter by taxonomy input type. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public EvaluationTaxonomiesGetAllCollectionResultOfT(EvaluationTaxonomies client, string inputName, string inputType, RequestOptions options) + { + _client = client; + _inputName = inputName; + _inputType = inputType; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override IEnumerable GetRawPages() + { + PipelineMessage message = _client.CreateGetAllRequest(_inputName, _inputType, _options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + yield return result; + + nextPageUri = ((PagedEvaluationTaxonomy)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetAllRequest(nextPageUri, _inputName, _inputType, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedEvaluationTaxonomy)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + + /// Gets the values from the specified page. + /// + /// The values from the specified page. + protected override IEnumerable GetValuesFromPage(ClientResult page) + { + return ((PagedEvaluationTaxonomy)page).Value; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluatorsGetLatestVersionsAsyncCollectionResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluatorsGetLatestVersionsAsyncCollectionResult.cs new file mode 100644 index 000000000000..687a1b3be38b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluatorsGetLatestVersionsAsyncCollectionResult.cs @@ -0,0 +1,69 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.Projects +{ + internal partial class EvaluatorsGetLatestVersionsAsyncCollectionResult : AsyncCollectionResult + { + private readonly Evaluators _client; + private readonly string _type; + private readonly int? _limit; + private readonly RequestOptions _options; + + /// Initializes a new instance of EvaluatorsGetLatestVersionsAsyncCollectionResult, which is used to iterate over the pages of a collection. + /// The Evaluators client used to send requests. + /// Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public EvaluatorsGetLatestVersionsAsyncCollectionResult(Evaluators client, string @type, int? limit, RequestOptions options) + { + _client = client; + _type = @type; + _limit = limit; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override async IAsyncEnumerable GetRawPagesAsync() + { + PipelineMessage message = _client.CreateGetLatestVersionsRequest(_type, _limit, _options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + yield return result; + + nextPageUri = ((PagedEvaluatorVersion)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetLatestVersionsRequest(nextPageUri, _type, _limit, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedEvaluatorVersion)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluatorsGetLatestVersionsAsyncCollectionResultOfT.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluatorsGetLatestVersionsAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..4365e0138c05 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluatorsGetLatestVersionsAsyncCollectionResultOfT.cs @@ -0,0 +1,82 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.AI.Projects +{ + internal partial class EvaluatorsGetLatestVersionsAsyncCollectionResultOfT : AsyncCollectionResult + { + private readonly Evaluators _client; + private readonly string _type; + private readonly int? _limit; + private readonly RequestOptions _options; + + /// Initializes a new instance of EvaluatorsGetLatestVersionsAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Evaluators client used to send requests. + /// Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public EvaluatorsGetLatestVersionsAsyncCollectionResultOfT(Evaluators client, string @type, int? limit, RequestOptions options) + { + _client = client; + _type = @type; + _limit = limit; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override async IAsyncEnumerable GetRawPagesAsync() + { + PipelineMessage message = _client.CreateGetLatestVersionsRequest(_type, _limit, _options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + yield return result; + + nextPageUri = ((PagedEvaluatorVersion)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetLatestVersionsRequest(nextPageUri, _type, _limit, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedEvaluatorVersion)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + + /// Gets the values from the specified page. + /// + /// The values from the specified page. + protected override async IAsyncEnumerable GetValuesFromPageAsync(ClientResult page) + { + foreach (EvaluatorVersion item in ((PagedEvaluatorVersion)page).Value) + { + yield return item; + await Task.Yield(); + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluatorsGetLatestVersionsCollectionResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluatorsGetLatestVersionsCollectionResult.cs new file mode 100644 index 000000000000..fb732381618c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluatorsGetLatestVersionsCollectionResult.cs @@ -0,0 +1,69 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.Projects +{ + internal partial class EvaluatorsGetLatestVersionsCollectionResult : CollectionResult + { + private readonly Evaluators _client; + private readonly string _type; + private readonly int? _limit; + private readonly RequestOptions _options; + + /// Initializes a new instance of EvaluatorsGetLatestVersionsCollectionResult, which is used to iterate over the pages of a collection. + /// The Evaluators client used to send requests. + /// Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public EvaluatorsGetLatestVersionsCollectionResult(Evaluators client, string @type, int? limit, RequestOptions options) + { + _client = client; + _type = @type; + _limit = limit; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override IEnumerable GetRawPages() + { + PipelineMessage message = _client.CreateGetLatestVersionsRequest(_type, _limit, _options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + yield return result; + + nextPageUri = ((PagedEvaluatorVersion)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetLatestVersionsRequest(nextPageUri, _type, _limit, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedEvaluatorVersion)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluatorsGetLatestVersionsCollectionResultOfT.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluatorsGetLatestVersionsCollectionResultOfT.cs new file mode 100644 index 000000000000..b3a319cad5a8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluatorsGetLatestVersionsCollectionResultOfT.cs @@ -0,0 +1,77 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.Projects +{ + internal partial class EvaluatorsGetLatestVersionsCollectionResultOfT : CollectionResult + { + private readonly Evaluators _client; + private readonly string _type; + private readonly int? _limit; + private readonly RequestOptions _options; + + /// Initializes a new instance of EvaluatorsGetLatestVersionsCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Evaluators client used to send requests. + /// Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public EvaluatorsGetLatestVersionsCollectionResultOfT(Evaluators client, string @type, int? limit, RequestOptions options) + { + _client = client; + _type = @type; + _limit = limit; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override IEnumerable GetRawPages() + { + PipelineMessage message = _client.CreateGetLatestVersionsRequest(_type, _limit, _options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + yield return result; + + nextPageUri = ((PagedEvaluatorVersion)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetLatestVersionsRequest(nextPageUri, _type, _limit, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedEvaluatorVersion)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + + /// Gets the values from the specified page. + /// + /// The values from the specified page. + protected override IEnumerable GetValuesFromPage(ClientResult page) + { + return ((PagedEvaluatorVersion)page).Value; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluatorsGetVersionsAsyncCollectionResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluatorsGetVersionsAsyncCollectionResult.cs new file mode 100644 index 000000000000..a0b1663251dd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluatorsGetVersionsAsyncCollectionResult.cs @@ -0,0 +1,76 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.Projects +{ + internal partial class EvaluatorsGetVersionsAsyncCollectionResult : AsyncCollectionResult + { + private readonly Evaluators _client; + private readonly string _name; + private readonly string _type; + private readonly int? _limit; + private readonly RequestOptions _options; + + /// Initializes a new instance of EvaluatorsGetVersionsAsyncCollectionResult, which is used to iterate over the pages of a collection. + /// The Evaluators client used to send requests. + /// The name of the resource. + /// Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + public EvaluatorsGetVersionsAsyncCollectionResult(Evaluators client, string name, string @type, int? limit, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + _client = client; + _name = name; + _type = @type; + _limit = limit; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override async IAsyncEnumerable GetRawPagesAsync() + { + PipelineMessage message = _client.CreateGetVersionsRequest(_name, _type, _limit, _options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + yield return result; + + nextPageUri = ((PagedEvaluatorVersion)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetVersionsRequest(nextPageUri, _name, _type, _limit, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedEvaluatorVersion)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluatorsGetVersionsAsyncCollectionResultOfT.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluatorsGetVersionsAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..914453977c62 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluatorsGetVersionsAsyncCollectionResultOfT.cs @@ -0,0 +1,89 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.AI.Projects +{ + internal partial class EvaluatorsGetVersionsAsyncCollectionResultOfT : AsyncCollectionResult + { + private readonly Evaluators _client; + private readonly string _name; + private readonly string _type; + private readonly int? _limit; + private readonly RequestOptions _options; + + /// Initializes a new instance of EvaluatorsGetVersionsAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Evaluators client used to send requests. + /// The name of the resource. + /// Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + public EvaluatorsGetVersionsAsyncCollectionResultOfT(Evaluators client, string name, string @type, int? limit, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + _client = client; + _name = name; + _type = @type; + _limit = limit; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override async IAsyncEnumerable GetRawPagesAsync() + { + PipelineMessage message = _client.CreateGetVersionsRequest(_name, _type, _limit, _options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + yield return result; + + nextPageUri = ((PagedEvaluatorVersion)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetVersionsRequest(nextPageUri, _name, _type, _limit, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedEvaluatorVersion)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + + /// Gets the values from the specified page. + /// + /// The values from the specified page. + protected override async IAsyncEnumerable GetValuesFromPageAsync(ClientResult page) + { + foreach (EvaluatorVersion item in ((PagedEvaluatorVersion)page).Value) + { + yield return item; + await Task.Yield(); + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluatorsGetVersionsCollectionResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluatorsGetVersionsCollectionResult.cs new file mode 100644 index 000000000000..f7d4cdacfd6a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluatorsGetVersionsCollectionResult.cs @@ -0,0 +1,76 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.Projects +{ + internal partial class EvaluatorsGetVersionsCollectionResult : CollectionResult + { + private readonly Evaluators _client; + private readonly string _name; + private readonly string _type; + private readonly int? _limit; + private readonly RequestOptions _options; + + /// Initializes a new instance of EvaluatorsGetVersionsCollectionResult, which is used to iterate over the pages of a collection. + /// The Evaluators client used to send requests. + /// The name of the resource. + /// Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + public EvaluatorsGetVersionsCollectionResult(Evaluators client, string name, string @type, int? limit, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + _client = client; + _name = name; + _type = @type; + _limit = limit; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override IEnumerable GetRawPages() + { + PipelineMessage message = _client.CreateGetVersionsRequest(_name, _type, _limit, _options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + yield return result; + + nextPageUri = ((PagedEvaluatorVersion)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetVersionsRequest(nextPageUri, _name, _type, _limit, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedEvaluatorVersion)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluatorsGetVersionsCollectionResultOfT.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluatorsGetVersionsCollectionResultOfT.cs new file mode 100644 index 000000000000..99051f90e637 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/EvaluatorsGetVersionsCollectionResultOfT.cs @@ -0,0 +1,84 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.AI.Projects +{ + internal partial class EvaluatorsGetVersionsCollectionResultOfT : CollectionResult + { + private readonly Evaluators _client; + private readonly string _name; + private readonly string _type; + private readonly int? _limit; + private readonly RequestOptions _options; + + /// Initializes a new instance of EvaluatorsGetVersionsCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Evaluators client used to send requests. + /// The name of the resource. + /// Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + public EvaluatorsGetVersionsCollectionResultOfT(Evaluators client, string name, string @type, int? limit, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + _client = client; + _name = name; + _type = @type; + _limit = limit; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override IEnumerable GetRawPages() + { + PipelineMessage message = _client.CreateGetVersionsRequest(_name, _type, _limit, _options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + yield return result; + + nextPageUri = ((PagedEvaluatorVersion)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetVersionsRequest(nextPageUri, _name, _type, _limit, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedEvaluatorVersion)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + + /// Gets the values from the specified page. + /// + /// The values from the specified page. + protected override IEnumerable GetValuesFromPage(ClientResult page) + { + return ((PagedEvaluatorVersion)page).Value; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/InsightsGetAllAsyncCollectionResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/InsightsGetAllAsyncCollectionResult.cs new file mode 100644 index 000000000000..576b87b3cc72 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/InsightsGetAllAsyncCollectionResult.cs @@ -0,0 +1,78 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + internal partial class InsightsGetAllAsyncCollectionResult : AsyncCollectionResult + { + private readonly Insights _client; + private readonly string _type; + private readonly string _evalId; + private readonly string _runId; + private readonly string _agentName; + private readonly bool? _includeCoordinates; + private readonly RequestOptions _options; + + /// Initializes a new instance of InsightsGetAllAsyncCollectionResult, which is used to iterate over the pages of a collection. + /// The Insights client used to send requests. + /// Filter by the type of analysis. + /// Filter by the evaluation ID. + /// Filter by the evaluation run ID. + /// Filter by the agent name. + /// Whether to include coordinates for visualization in the response. Defaults to false. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public InsightsGetAllAsyncCollectionResult(Insights client, string @type, string evalId, string runId, string agentName, bool? includeCoordinates, RequestOptions options) + { + _client = client; + _type = @type; + _evalId = evalId; + _runId = runId; + _agentName = agentName; + _includeCoordinates = includeCoordinates; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override async IAsyncEnumerable GetRawPagesAsync() + { + PipelineMessage message = _client.CreateGetAllRequest(_type, _evalId, _runId, _agentName, _includeCoordinates, _options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + yield return result; + + nextPageUri = ((PagedInsight)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetAllRequest(nextPageUri, _type, _evalId, _runId, _agentName, _includeCoordinates, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedInsight)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/InsightsGetAllAsyncCollectionResultOfT.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/InsightsGetAllAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..099bc2e41b7d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/InsightsGetAllAsyncCollectionResultOfT.cs @@ -0,0 +1,91 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + internal partial class InsightsGetAllAsyncCollectionResultOfT : AsyncCollectionResult + { + private readonly Insights _client; + private readonly string _type; + private readonly string _evalId; + private readonly string _runId; + private readonly string _agentName; + private readonly bool? _includeCoordinates; + private readonly RequestOptions _options; + + /// Initializes a new instance of InsightsGetAllAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Insights client used to send requests. + /// Filter by the type of analysis. + /// Filter by the evaluation ID. + /// Filter by the evaluation run ID. + /// Filter by the agent name. + /// Whether to include coordinates for visualization in the response. Defaults to false. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public InsightsGetAllAsyncCollectionResultOfT(Insights client, string @type, string evalId, string runId, string agentName, bool? includeCoordinates, RequestOptions options) + { + _client = client; + _type = @type; + _evalId = evalId; + _runId = runId; + _agentName = agentName; + _includeCoordinates = includeCoordinates; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override async IAsyncEnumerable GetRawPagesAsync() + { + PipelineMessage message = _client.CreateGetAllRequest(_type, _evalId, _runId, _agentName, _includeCoordinates, _options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + yield return result; + + nextPageUri = ((PagedInsight)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetAllRequest(nextPageUri, _type, _evalId, _runId, _agentName, _includeCoordinates, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedInsight)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + + /// Gets the values from the specified page. + /// + /// The values from the specified page. + protected override async IAsyncEnumerable GetValuesFromPageAsync(ClientResult page) + { + foreach (Insight item in ((PagedInsight)page).Value) + { + yield return item; + await Task.Yield(); + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/InsightsGetAllCollectionResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/InsightsGetAllCollectionResult.cs new file mode 100644 index 000000000000..1f7757be0570 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/InsightsGetAllCollectionResult.cs @@ -0,0 +1,78 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + internal partial class InsightsGetAllCollectionResult : CollectionResult + { + private readonly Insights _client; + private readonly string _type; + private readonly string _evalId; + private readonly string _runId; + private readonly string _agentName; + private readonly bool? _includeCoordinates; + private readonly RequestOptions _options; + + /// Initializes a new instance of InsightsGetAllCollectionResult, which is used to iterate over the pages of a collection. + /// The Insights client used to send requests. + /// Filter by the type of analysis. + /// Filter by the evaluation ID. + /// Filter by the evaluation run ID. + /// Filter by the agent name. + /// Whether to include coordinates for visualization in the response. Defaults to false. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public InsightsGetAllCollectionResult(Insights client, string @type, string evalId, string runId, string agentName, bool? includeCoordinates, RequestOptions options) + { + _client = client; + _type = @type; + _evalId = evalId; + _runId = runId; + _agentName = agentName; + _includeCoordinates = includeCoordinates; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override IEnumerable GetRawPages() + { + PipelineMessage message = _client.CreateGetAllRequest(_type, _evalId, _runId, _agentName, _includeCoordinates, _options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + yield return result; + + nextPageUri = ((PagedInsight)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetAllRequest(nextPageUri, _type, _evalId, _runId, _agentName, _includeCoordinates, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedInsight)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/InsightsGetAllCollectionResultOfT.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/InsightsGetAllCollectionResultOfT.cs new file mode 100644 index 000000000000..905ab22ba80b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/InsightsGetAllCollectionResultOfT.cs @@ -0,0 +1,86 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + internal partial class InsightsGetAllCollectionResultOfT : CollectionResult + { + private readonly Insights _client; + private readonly string _type; + private readonly string _evalId; + private readonly string _runId; + private readonly string _agentName; + private readonly bool? _includeCoordinates; + private readonly RequestOptions _options; + + /// Initializes a new instance of InsightsGetAllCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Insights client used to send requests. + /// Filter by the type of analysis. + /// Filter by the evaluation ID. + /// Filter by the evaluation run ID. + /// Filter by the agent name. + /// Whether to include coordinates for visualization in the response. Defaults to false. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public InsightsGetAllCollectionResultOfT(Insights client, string @type, string evalId, string runId, string agentName, bool? includeCoordinates, RequestOptions options) + { + _client = client; + _type = @type; + _evalId = evalId; + _runId = runId; + _agentName = agentName; + _includeCoordinates = includeCoordinates; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override IEnumerable GetRawPages() + { + PipelineMessage message = _client.CreateGetAllRequest(_type, _evalId, _runId, _agentName, _includeCoordinates, _options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + yield return result; + + nextPageUri = ((PagedInsight)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetAllRequest(nextPageUri, _type, _evalId, _runId, _agentName, _includeCoordinates, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedInsight)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + + /// Gets the values from the specified page. + /// + /// The values from the specified page. + protected override IEnumerable GetValuesFromPage(ClientResult page) + { + return ((PagedInsight)page).Value; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/RedTeamsGetAllAsyncCollectionResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/RedTeamsGetAllAsyncCollectionResult.cs new file mode 100644 index 000000000000..79c83c9de67c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/RedTeamsGetAllAsyncCollectionResult.cs @@ -0,0 +1,63 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + internal partial class RedTeamsGetAllAsyncCollectionResult : AsyncCollectionResult + { + private readonly RedTeams _client; + private readonly RequestOptions _options; + + /// Initializes a new instance of RedTeamsGetAllAsyncCollectionResult, which is used to iterate over the pages of a collection. + /// The RedTeams client used to send requests. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public RedTeamsGetAllAsyncCollectionResult(RedTeams client, RequestOptions options) + { + _client = client; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override async IAsyncEnumerable GetRawPagesAsync() + { + PipelineMessage message = _client.CreateGetAllRequest(_options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + yield return result; + + nextPageUri = ((PagedRedTeam)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetAllRequest(nextPageUri, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedRedTeam)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/RedTeamsGetAllAsyncCollectionResultOfT.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/RedTeamsGetAllAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..81c7812915b5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/RedTeamsGetAllAsyncCollectionResultOfT.cs @@ -0,0 +1,76 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + internal partial class RedTeamsGetAllAsyncCollectionResultOfT : AsyncCollectionResult + { + private readonly RedTeams _client; + private readonly RequestOptions _options; + + /// Initializes a new instance of RedTeamsGetAllAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The RedTeams client used to send requests. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public RedTeamsGetAllAsyncCollectionResultOfT(RedTeams client, RequestOptions options) + { + _client = client; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override async IAsyncEnumerable GetRawPagesAsync() + { + PipelineMessage message = _client.CreateGetAllRequest(_options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + yield return result; + + nextPageUri = ((PagedRedTeam)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetAllRequest(nextPageUri, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedRedTeam)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + + /// Gets the values from the specified page. + /// + /// The values from the specified page. + protected override async IAsyncEnumerable GetValuesFromPageAsync(ClientResult page) + { + foreach (RedTeam item in ((PagedRedTeam)page).Value) + { + yield return item; + await Task.Yield(); + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/RedTeamsGetAllCollectionResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/RedTeamsGetAllCollectionResult.cs new file mode 100644 index 000000000000..44d0c241d13e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/RedTeamsGetAllCollectionResult.cs @@ -0,0 +1,63 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + internal partial class RedTeamsGetAllCollectionResult : CollectionResult + { + private readonly RedTeams _client; + private readonly RequestOptions _options; + + /// Initializes a new instance of RedTeamsGetAllCollectionResult, which is used to iterate over the pages of a collection. + /// The RedTeams client used to send requests. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public RedTeamsGetAllCollectionResult(RedTeams client, RequestOptions options) + { + _client = client; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override IEnumerable GetRawPages() + { + PipelineMessage message = _client.CreateGetAllRequest(_options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + yield return result; + + nextPageUri = ((PagedRedTeam)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetAllRequest(nextPageUri, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedRedTeam)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/RedTeamsGetAllCollectionResultOfT.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/RedTeamsGetAllCollectionResultOfT.cs new file mode 100644 index 000000000000..101e6cd381ee --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/RedTeamsGetAllCollectionResultOfT.cs @@ -0,0 +1,71 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + internal partial class RedTeamsGetAllCollectionResultOfT : CollectionResult + { + private readonly RedTeams _client; + private readonly RequestOptions _options; + + /// Initializes a new instance of RedTeamsGetAllCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The RedTeams client used to send requests. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public RedTeamsGetAllCollectionResultOfT(RedTeams client, RequestOptions options) + { + _client = client; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override IEnumerable GetRawPages() + { + PipelineMessage message = _client.CreateGetAllRequest(_options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + yield return result; + + nextPageUri = ((PagedRedTeam)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetAllRequest(nextPageUri, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedRedTeam)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + + /// Gets the values from the specified page. + /// + /// The values from the specified page. + protected override IEnumerable GetValuesFromPage(ClientResult page) + { + return ((PagedRedTeam)page).Value; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/SchedulesGetAllAsyncCollectionResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/SchedulesGetAllAsyncCollectionResult.cs new file mode 100644 index 000000000000..3b221f19383f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/SchedulesGetAllAsyncCollectionResult.cs @@ -0,0 +1,63 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + internal partial class SchedulesGetAllAsyncCollectionResult : AsyncCollectionResult + { + private readonly Schedules _client; + private readonly RequestOptions _options; + + /// Initializes a new instance of SchedulesGetAllAsyncCollectionResult, which is used to iterate over the pages of a collection. + /// The Schedules client used to send requests. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public SchedulesGetAllAsyncCollectionResult(Schedules client, RequestOptions options) + { + _client = client; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override async IAsyncEnumerable GetRawPagesAsync() + { + PipelineMessage message = _client.CreateGetAllRequest(_options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + yield return result; + + nextPageUri = ((PagedSchedule)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetAllRequest(nextPageUri, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedSchedule)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/SchedulesGetAllAsyncCollectionResultOfT.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/SchedulesGetAllAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..c4975720a24c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/SchedulesGetAllAsyncCollectionResultOfT.cs @@ -0,0 +1,76 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + internal partial class SchedulesGetAllAsyncCollectionResultOfT : AsyncCollectionResult + { + private readonly Schedules _client; + private readonly RequestOptions _options; + + /// Initializes a new instance of SchedulesGetAllAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Schedules client used to send requests. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public SchedulesGetAllAsyncCollectionResultOfT(Schedules client, RequestOptions options) + { + _client = client; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override async IAsyncEnumerable GetRawPagesAsync() + { + PipelineMessage message = _client.CreateGetAllRequest(_options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + yield return result; + + nextPageUri = ((PagedSchedule)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetAllRequest(nextPageUri, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedSchedule)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + + /// Gets the values from the specified page. + /// + /// The values from the specified page. + protected override async IAsyncEnumerable GetValuesFromPageAsync(ClientResult page) + { + foreach (Schedule item in ((PagedSchedule)page).Value) + { + yield return item; + await Task.Yield(); + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/SchedulesGetAllCollectionResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/SchedulesGetAllCollectionResult.cs new file mode 100644 index 000000000000..805a84519874 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/SchedulesGetAllCollectionResult.cs @@ -0,0 +1,63 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + internal partial class SchedulesGetAllCollectionResult : CollectionResult + { + private readonly Schedules _client; + private readonly RequestOptions _options; + + /// Initializes a new instance of SchedulesGetAllCollectionResult, which is used to iterate over the pages of a collection. + /// The Schedules client used to send requests. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public SchedulesGetAllCollectionResult(Schedules client, RequestOptions options) + { + _client = client; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override IEnumerable GetRawPages() + { + PipelineMessage message = _client.CreateGetAllRequest(_options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + yield return result; + + nextPageUri = ((PagedSchedule)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetAllRequest(nextPageUri, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedSchedule)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/SchedulesGetAllCollectionResultOfT.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/SchedulesGetAllCollectionResultOfT.cs new file mode 100644 index 000000000000..0b2d0bdb91d1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/SchedulesGetAllCollectionResultOfT.cs @@ -0,0 +1,71 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + internal partial class SchedulesGetAllCollectionResultOfT : CollectionResult + { + private readonly Schedules _client; + private readonly RequestOptions _options; + + /// Initializes a new instance of SchedulesGetAllCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Schedules client used to send requests. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public SchedulesGetAllCollectionResultOfT(Schedules client, RequestOptions options) + { + _client = client; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override IEnumerable GetRawPages() + { + PipelineMessage message = _client.CreateGetAllRequest(_options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + yield return result; + + nextPageUri = ((PagedSchedule)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetAllRequest(nextPageUri, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedSchedule)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + + /// Gets the values from the specified page. + /// + /// The values from the specified page. + protected override IEnumerable GetValuesFromPage(ClientResult page) + { + return ((PagedSchedule)page).Value; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/SchedulesGetRunsAsyncCollectionResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/SchedulesGetRunsAsyncCollectionResult.cs new file mode 100644 index 000000000000..9e6ba596fbab --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/SchedulesGetRunsAsyncCollectionResult.cs @@ -0,0 +1,70 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + internal partial class SchedulesGetRunsAsyncCollectionResult : AsyncCollectionResult + { + private readonly Schedules _client; + private readonly string _id; + private readonly RequestOptions _options; + + /// Initializes a new instance of SchedulesGetRunsAsyncCollectionResult, which is used to iterate over the pages of a collection. + /// The Schedules client used to send requests. + /// Identifier of the schedule. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + public SchedulesGetRunsAsyncCollectionResult(Schedules client, string id, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + _client = client; + _id = id; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override async IAsyncEnumerable GetRawPagesAsync() + { + PipelineMessage message = _client.CreateGetRunsRequest(_id, _options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + yield return result; + + nextPageUri = ((PagedScheduleRun)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetRunsRequest(nextPageUri, _id, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedScheduleRun)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/SchedulesGetRunsAsyncCollectionResultOfT.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/SchedulesGetRunsAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..8a465ef3274a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/SchedulesGetRunsAsyncCollectionResultOfT.cs @@ -0,0 +1,83 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + internal partial class SchedulesGetRunsAsyncCollectionResultOfT : AsyncCollectionResult + { + private readonly Schedules _client; + private readonly string _id; + private readonly RequestOptions _options; + + /// Initializes a new instance of SchedulesGetRunsAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Schedules client used to send requests. + /// Identifier of the schedule. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + public SchedulesGetRunsAsyncCollectionResultOfT(Schedules client, string id, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + _client = client; + _id = id; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override async IAsyncEnumerable GetRawPagesAsync() + { + PipelineMessage message = _client.CreateGetRunsRequest(_id, _options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(await _client.Pipeline.ProcessMessageAsync(message, _options).ConfigureAwait(false)); + yield return result; + + nextPageUri = ((PagedScheduleRun)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetRunsRequest(nextPageUri, _id, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedScheduleRun)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + + /// Gets the values from the specified page. + /// + /// The values from the specified page. + protected override async IAsyncEnumerable GetValuesFromPageAsync(ClientResult page) + { + foreach (ScheduleRun item in ((PagedScheduleRun)page).Value) + { + yield return item; + await Task.Yield(); + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/SchedulesGetRunsCollectionResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/SchedulesGetRunsCollectionResult.cs new file mode 100644 index 000000000000..e56c7a2c8f41 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/SchedulesGetRunsCollectionResult.cs @@ -0,0 +1,70 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + internal partial class SchedulesGetRunsCollectionResult : CollectionResult + { + private readonly Schedules _client; + private readonly string _id; + private readonly RequestOptions _options; + + /// Initializes a new instance of SchedulesGetRunsCollectionResult, which is used to iterate over the pages of a collection. + /// The Schedules client used to send requests. + /// Identifier of the schedule. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + public SchedulesGetRunsCollectionResult(Schedules client, string id, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + _client = client; + _id = id; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override IEnumerable GetRawPages() + { + PipelineMessage message = _client.CreateGetRunsRequest(_id, _options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + yield return result; + + nextPageUri = ((PagedScheduleRun)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetRunsRequest(nextPageUri, _id, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedScheduleRun)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/SchedulesGetRunsCollectionResultOfT.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/SchedulesGetRunsCollectionResultOfT.cs new file mode 100644 index 000000000000..d30e34a51765 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CollectionResults/SchedulesGetRunsCollectionResultOfT.cs @@ -0,0 +1,78 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + internal partial class SchedulesGetRunsCollectionResultOfT : CollectionResult + { + private readonly Schedules _client; + private readonly string _id; + private readonly RequestOptions _options; + + /// Initializes a new instance of SchedulesGetRunsCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Schedules client used to send requests. + /// Identifier of the schedule. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + public SchedulesGetRunsCollectionResultOfT(Schedules client, string id, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + _client = client; + _id = id; + _options = options; + } + + /// Gets the raw pages of the collection. + /// The raw pages of the collection. + public override IEnumerable GetRawPages() + { + PipelineMessage message = _client.CreateGetRunsRequest(_id, _options); + Uri nextPageUri = null; + while (true) + { + ClientResult result = ClientResult.FromResponse(_client.Pipeline.ProcessMessage(message, _options)); + yield return result; + + nextPageUri = ((PagedScheduleRun)result).NextLink; + if (nextPageUri == null) + { + yield break; + } + message = _client.CreateNextGetRunsRequest(nextPageUri, _id, _options); + } + } + + /// Gets the continuation token from the specified page. + /// + /// The continuation token for the specified page. + public override ContinuationToken GetContinuationToken(ClientResult page) + { + Uri nextPage = ((PagedScheduleRun)page).NextLink; + if (nextPage != null) + { + return ContinuationToken.FromBytes(BinaryData.FromString(nextPage.AbsoluteUri)); + } + else + { + return null; + } + } + + /// Gets the values from the specified page. + /// + /// The values from the specified page. + protected override IEnumerable GetValuesFromPage(ClientResult page) + { + return ((PagedScheduleRun)page).Value; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ComparisonFilterType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ComparisonFilterType.cs new file mode 100644 index 000000000000..8e83fe356ed6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ComparisonFilterType.cs @@ -0,0 +1,81 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal readonly partial struct ComparisonFilterType : IEquatable + { + private readonly string _value; + private const string EqValue = "eq"; + private const string NeValue = "ne"; + private const string GtValue = "gt"; + private const string GteValue = "gte"; + private const string LtValue = "lt"; + private const string LteValue = "lte"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ComparisonFilterType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Eq. + public static ComparisonFilterType Eq { get; } = new ComparisonFilterType(EqValue); + + /// Gets the Ne. + public static ComparisonFilterType Ne { get; } = new ComparisonFilterType(NeValue); + + /// Gets the Gt. + public static ComparisonFilterType Gt { get; } = new ComparisonFilterType(GtValue); + + /// Gets the Gte. + public static ComparisonFilterType Gte { get; } = new ComparisonFilterType(GteValue); + + /// Gets the Lt. + public static ComparisonFilterType Lt { get; } = new ComparisonFilterType(LtValue); + + /// Gets the Lte. + public static ComparisonFilterType Lte { get; } = new ComparisonFilterType(LteValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ComparisonFilterType left, ComparisonFilterType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ComparisonFilterType left, ComparisonFilterType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ComparisonFilterType(string value) => new ComparisonFilterType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ComparisonFilterType?(string value) => value == null ? null : new ComparisonFilterType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ComparisonFilterType other && Equals(other); + + /// + public bool Equals(ComparisonFilterType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CompoundFilterType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CompoundFilterType.cs new file mode 100644 index 000000000000..a00e9a4bb259 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CompoundFilterType.cs @@ -0,0 +1,65 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal readonly partial struct CompoundFilterType : IEquatable + { + private readonly string _value; + private const string AndValue = "and"; + private const string OrValue = "or"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public CompoundFilterType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the And. + public static CompoundFilterType And { get; } = new CompoundFilterType(AndValue); + + /// Gets the Or. + public static CompoundFilterType Or { get; } = new CompoundFilterType(OrValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(CompoundFilterType left, CompoundFilterType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(CompoundFilterType left, CompoundFilterType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator CompoundFilterType(string value) => new CompoundFilterType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator CompoundFilterType?(string value) => value == null ? null : new CompoundFilterType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CompoundFilterType other && Equals(other); + + /// + public bool Equals(CompoundFilterType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ComputerActionClickButton.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ComputerActionClickButton.cs new file mode 100644 index 000000000000..2a53d3609bf5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ComputerActionClickButton.cs @@ -0,0 +1,77 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal readonly partial struct ComputerActionClickButton : IEquatable + { + private readonly string _value; + private const string LeftValue = "left"; + private const string RightValue = "right"; + private const string WheelValue = "wheel"; + private const string BackValue = "back"; + private const string ForwardValue = "forward"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ComputerActionClickButton(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Left. + public static ComputerActionClickButton Left { get; } = new ComputerActionClickButton(LeftValue); + + /// Gets the Right. + public static ComputerActionClickButton Right { get; } = new ComputerActionClickButton(RightValue); + + /// Gets the Wheel. + public static ComputerActionClickButton Wheel { get; } = new ComputerActionClickButton(WheelValue); + + /// Gets the Back. + public static ComputerActionClickButton Back { get; } = new ComputerActionClickButton(BackValue); + + /// Gets the Forward. + public static ComputerActionClickButton Forward { get; } = new ComputerActionClickButton(ForwardValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ComputerActionClickButton left, ComputerActionClickButton right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ComputerActionClickButton left, ComputerActionClickButton right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ComputerActionClickButton(string value) => new ComputerActionClickButton(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ComputerActionClickButton?(string value) => value == null ? null : new ComputerActionClickButton(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ComputerActionClickButton other && Equals(other); + + /// + public bool Equals(ComputerActionClickButton other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ComputerActionType.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ComputerActionType.Serialization.cs new file mode 100644 index 000000000000..7d8320c8f191 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ComputerActionType.Serialization.cs @@ -0,0 +1,68 @@ +// + +#nullable disable + +using System; + +namespace OpenAI +{ + internal static partial class ComputerActionTypeExtensions + { + /// The value to serialize. + public static string ToSerialString(this ComputerActionType value) => value switch + { + ComputerActionType.Screenshot => "screenshot", + ComputerActionType.Click => "click", + ComputerActionType.DoubleClick => "double_click", + ComputerActionType.Scroll => "scroll", + ComputerActionType.Type => "type", + ComputerActionType.Wait => "wait", + ComputerActionType.Keypress => "keypress", + ComputerActionType.Drag => "drag", + ComputerActionType.Move => "move", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ComputerActionType value.") + }; + + /// The value to deserialize. + public static ComputerActionType ToComputerActionType(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "screenshot")) + { + return ComputerActionType.Screenshot; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "click")) + { + return ComputerActionType.Click; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "double_click")) + { + return ComputerActionType.DoubleClick; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "scroll")) + { + return ComputerActionType.Scroll; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "type")) + { + return ComputerActionType.Type; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "wait")) + { + return ComputerActionType.Wait; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "keypress")) + { + return ComputerActionType.Keypress; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "drag")) + { + return ComputerActionType.Drag; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "move")) + { + return ComputerActionType.Move; + } + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ComputerActionType value."); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ComputerActionType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ComputerActionType.cs new file mode 100644 index 000000000000..658b1f92b8c2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ComputerActionType.cs @@ -0,0 +1,29 @@ +// + +#nullable disable + +namespace OpenAI +{ + /// + internal enum ComputerActionType + { + /// Screenshot. + Screenshot, + /// Click. + Click, + /// DoubleClick. + DoubleClick, + /// Scroll. + Scroll, + /// Type. + Type, + /// Wait. + Wait, + /// Keypress. + Keypress, + /// Drag. + Drag, + /// Move. + Move + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ComputerToolCallOutputItemOutputType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ComputerToolCallOutputItemOutputType.cs new file mode 100644 index 000000000000..b82b92a6948b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ComputerToolCallOutputItemOutputType.cs @@ -0,0 +1,62 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects; + +namespace OpenAI +{ + /// A computer screenshot image used with the computer use tool. + internal readonly partial struct ComputerToolCallOutputItemOutputType : IEquatable + { + private readonly string _value; + private const string ScreenshotValue = "computer_screenshot"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ComputerToolCallOutputItemOutputType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Screenshot. + public static ComputerToolCallOutputItemOutputType Screenshot { get; } = new ComputerToolCallOutputItemOutputType(ScreenshotValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ComputerToolCallOutputItemOutputType left, ComputerToolCallOutputItemOutputType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ComputerToolCallOutputItemOutputType left, ComputerToolCallOutputItemOutputType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ComputerToolCallOutputItemOutputType(string value) => new ComputerToolCallOutputItemOutputType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ComputerToolCallOutputItemOutputType?(string value) => value == null ? null : new ComputerToolCallOutputItemOutputType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ComputerToolCallOutputItemOutputType other && Equals(other); + + /// + public bool Equals(ComputerToolCallOutputItemOutputType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ComputerUsePreviewToolEnvironment.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ComputerUsePreviewToolEnvironment.cs new file mode 100644 index 000000000000..43b5352162a6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ComputerUsePreviewToolEnvironment.cs @@ -0,0 +1,77 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal readonly partial struct ComputerUsePreviewToolEnvironment : IEquatable + { + private readonly string _value; + private const string WindowsValue = "windows"; + private const string MacValue = "mac"; + private const string LinuxValue = "linux"; + private const string UbuntuValue = "ubuntu"; + private const string BrowserValue = "browser"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ComputerUsePreviewToolEnvironment(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Windows. + public static ComputerUsePreviewToolEnvironment Windows { get; } = new ComputerUsePreviewToolEnvironment(WindowsValue); + + /// Gets the Mac. + public static ComputerUsePreviewToolEnvironment Mac { get; } = new ComputerUsePreviewToolEnvironment(MacValue); + + /// Gets the Linux. + public static ComputerUsePreviewToolEnvironment Linux { get; } = new ComputerUsePreviewToolEnvironment(LinuxValue); + + /// Gets the Ubuntu. + public static ComputerUsePreviewToolEnvironment Ubuntu { get; } = new ComputerUsePreviewToolEnvironment(UbuntuValue); + + /// Gets the Browser. + public static ComputerUsePreviewToolEnvironment Browser { get; } = new ComputerUsePreviewToolEnvironment(BrowserValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ComputerUsePreviewToolEnvironment left, ComputerUsePreviewToolEnvironment right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ComputerUsePreviewToolEnvironment left, ComputerUsePreviewToolEnvironment right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ComputerUsePreviewToolEnvironment(string value) => new ComputerUsePreviewToolEnvironment(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ComputerUsePreviewToolEnvironment?(string value) => value == null ? null : new ComputerUsePreviewToolEnvironment(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ComputerUsePreviewToolEnvironment other && Equals(other); + + /// + public bool Equals(ComputerUsePreviewToolEnvironment other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionType.cs index 42289d1cb3bc..de4569de400a 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionType.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ConnectionType.cs @@ -29,6 +29,8 @@ namespace Azure.AI.Projects private const string ApplicationInsightsValue = "AppInsights"; /// Custom Keys. private const string CustomValue = "CustomKeys"; + /// Remote tool. + private const string RemoteToolValue = "RemoteTool"; /// Initializes a new instance of . /// The value. @@ -67,6 +69,9 @@ public ConnectionType(string value) /// Custom Keys. public static ConnectionType Custom { get; } = new ConnectionType(CustomValue); + /// Remote tool. + public static ConnectionType RemoteTool { get; } = new ConnectionType(RemoteToolValue); + /// Determines if two values are the same. /// The left value to compare. /// The right value to compare. diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ContainerAppAgentDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ContainerAppAgentDefinition.Serialization.cs new file mode 100644 index 000000000000..56a419b10b0b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ContainerAppAgentDefinition.Serialization.cs @@ -0,0 +1,173 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The container app agent definition. + internal partial class ContainerAppAgentDefinition : InternalAgentDefinition, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ContainerAppAgentDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ContainerAppAgentDefinition)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("container_protocol_versions"u8); + writer.WriteStartArray(); + foreach (ProtocolVersionRecord item in ContainerProtocolVersions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + writer.WritePropertyName("container_app_resource_id"u8); + writer.WriteStringValue(ContainerAppResourceId); + writer.WritePropertyName("ingress_subdomain_suffix"u8); + writer.WriteStringValue(IngressSubdomainSuffix); + } + + /// The JSON reader. + /// The client options for reading and writing models. + ContainerAppAgentDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (ContainerAppAgentDefinition)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalAgentDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ContainerAppAgentDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeContainerAppAgentDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ContainerAppAgentDefinition DeserializeContainerAppAgentDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentKind kind = default; + RaiConfig raiConfig = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList containerProtocolVersions = default; + string containerAppResourceId = default; + string ingressSubdomainSuffix = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("kind"u8)) + { + kind = new AgentKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("rai_config"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + raiConfig = RaiConfig.DeserializeRaiConfig(prop.Value, options); + continue; + } + if (prop.NameEquals("container_protocol_versions"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ProtocolVersionRecord.DeserializeProtocolVersionRecord(item, options)); + } + containerProtocolVersions = array; + continue; + } + if (prop.NameEquals("container_app_resource_id"u8)) + { + containerAppResourceId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("ingress_subdomain_suffix"u8)) + { + ingressSubdomainSuffix = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ContainerAppAgentDefinition( + kind, + raiConfig, + additionalBinaryDataProperties, + containerProtocolVersions, + containerAppResourceId, + ingressSubdomainSuffix); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(ContainerAppAgentDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ContainerAppAgentDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (ContainerAppAgentDefinition)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalAgentDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeContainerAppAgentDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ContainerAppAgentDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ContainerAppAgentDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ContainerAppAgentDefinition.cs new file mode 100644 index 000000000000..1a9b712abf37 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ContainerAppAgentDefinition.cs @@ -0,0 +1,53 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects +{ + /// The container app agent definition. + internal partial class ContainerAppAgentDefinition : InternalAgentDefinition + { + /// Initializes a new instance of . + /// The protocols that the agent supports for ingress communication of the containers. + /// The resource ID of the Azure Container App that hosts this agent. Not mutable across versions. + /// The suffix to apply to the app subdomain when sending ingress to the agent. This can be a label (e.g., '---current'), a specific revision (e.g., '--0000001'), or empty to use the default endpoint for the container app. + /// , or is null. + public ContainerAppAgentDefinition(IEnumerable containerProtocolVersions, string containerAppResourceId, string ingressSubdomainSuffix) : base(AgentKind.ContainerApp) + { + Argument.AssertNotNull(containerProtocolVersions, nameof(containerProtocolVersions)); + Argument.AssertNotNull(containerAppResourceId, nameof(containerAppResourceId)); + Argument.AssertNotNull(ingressSubdomainSuffix, nameof(ingressSubdomainSuffix)); + + ContainerProtocolVersions = containerProtocolVersions.ToList(); + ContainerAppResourceId = containerAppResourceId; + IngressSubdomainSuffix = ingressSubdomainSuffix; + } + + /// Initializes a new instance of . + /// + /// Configuration for Responsible AI (RAI) content filtering and safety features. + /// Keeps track of any properties unknown to the library. + /// The protocols that the agent supports for ingress communication of the containers. + /// The resource ID of the Azure Container App that hosts this agent. Not mutable across versions. + /// The suffix to apply to the app subdomain when sending ingress to the agent. This can be a label (e.g., '---current'), a specific revision (e.g., '--0000001'), or empty to use the default endpoint for the container app. + internal ContainerAppAgentDefinition(AgentKind kind, RaiConfig raiConfig, IDictionary additionalBinaryDataProperties, IList containerProtocolVersions, string containerAppResourceId, string ingressSubdomainSuffix) : base(kind, raiConfig, additionalBinaryDataProperties) + { + ContainerProtocolVersions = containerProtocolVersions; + ContainerAppResourceId = containerAppResourceId; + IngressSubdomainSuffix = ingressSubdomainSuffix; + } + + /// The protocols that the agent supports for ingress communication of the containers. + public IList ContainerProtocolVersions { get; } + + /// The resource ID of the Azure Container App that hosts this agent. Not mutable across versions. + public string ContainerAppResourceId { get; set; } + + /// The suffix to apply to the app subdomain when sending ingress to the agent. This can be a label (e.g., '---current'), a specific revision (e.g., '--0000001'), or empty to use the default endpoint for the container app. + public string IngressSubdomainSuffix { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ContinuousEvaluationRuleAction.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ContinuousEvaluationRuleAction.Serialization.cs new file mode 100644 index 000000000000..8202a0eec5ae --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ContinuousEvaluationRuleAction.Serialization.cs @@ -0,0 +1,146 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Evaluation rule action for continuous evaluation. + public partial class ContinuousEvaluationRuleAction : EvaluationRuleAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ContinuousEvaluationRuleAction() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ContinuousEvaluationRuleAction)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("evalId"u8); + writer.WriteStringValue(EvalId); + if (Optional.IsDefined(MaxHourlyRuns)) + { + writer.WritePropertyName("maxHourlyRuns"u8); + writer.WriteNumberValue(MaxHourlyRuns.Value); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ContinuousEvaluationRuleAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (ContinuousEvaluationRuleAction)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override EvaluationRuleAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ContinuousEvaluationRuleAction)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeContinuousEvaluationRuleAction(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ContinuousEvaluationRuleAction DeserializeContinuousEvaluationRuleAction(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + EvaluationRuleActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string evalId = default; + int? maxHourlyRuns = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new EvaluationRuleActionType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("evalId"u8)) + { + evalId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("maxHourlyRuns"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxHourlyRuns = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ContinuousEvaluationRuleAction(@type, additionalBinaryDataProperties, evalId, maxHourlyRuns); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(ContinuousEvaluationRuleAction)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ContinuousEvaluationRuleAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (ContinuousEvaluationRuleAction)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override EvaluationRuleAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeContinuousEvaluationRuleAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ContinuousEvaluationRuleAction)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ContinuousEvaluationRuleAction.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ContinuousEvaluationRuleAction.cs new file mode 100644 index 000000000000..447ed6bac5bb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ContinuousEvaluationRuleAction.cs @@ -0,0 +1,40 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Evaluation rule action for continuous evaluation. + public partial class ContinuousEvaluationRuleAction : EvaluationRuleAction + { + /// Initializes a new instance of . + /// Eval Id to add continuous evaluation runs to. + /// is null. + public ContinuousEvaluationRuleAction(string evalId) : base(EvaluationRuleActionType.ContinuousEvaluation) + { + Argument.AssertNotNull(evalId, nameof(evalId)); + + EvalId = evalId; + } + + /// Initializes a new instance of . + /// Type of the evaluation action. + /// Keeps track of any properties unknown to the library. + /// Eval Id to add continuous evaluation runs to. + /// Maximum number of evaluation runs allowed per hour. + internal ContinuousEvaluationRuleAction(EvaluationRuleActionType @type, IDictionary additionalBinaryDataProperties, string evalId, int? maxHourlyRuns) : base(@type, additionalBinaryDataProperties) + { + EvalId = evalId; + MaxHourlyRuns = maxHourlyRuns; + } + + /// Eval Id to add continuous evaluation runs to. + public string EvalId { get; set; } + + /// Maximum number of evaluation runs allowed per hour. + public int? MaxHourlyRuns { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CreateAgentVersionFromManifestRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CreateAgentVersionFromManifestRequest.Serialization.cs new file mode 100644 index 000000000000..1ef11b03a556 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CreateAgentVersionFromManifestRequest.Serialization.cs @@ -0,0 +1,226 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The CreateAgentVersionFromManifestRequest. + public partial class CreateAgentVersionFromManifestRequest : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal CreateAgentVersionFromManifestRequest() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateAgentVersionFromManifestRequest)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("manifest_id"u8); + writer.WriteStringValue(ManifestId); + writer.WritePropertyName("parameter_values"u8); + writer.WriteStartObject(); + foreach (var item in ParameterValues) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#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(); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + CreateAgentVersionFromManifestRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual CreateAgentVersionFromManifestRequest JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateAgentVersionFromManifestRequest)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCreateAgentVersionFromManifestRequest(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static CreateAgentVersionFromManifestRequest DeserializeCreateAgentVersionFromManifestRequest(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary metadata = default; + string description = default; + string manifestId = default; + IDictionary parameterValues = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("metadata"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + metadata = dictionary; + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("manifest_id"u8)) + { + manifestId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("parameter_values"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + parameterValues = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new CreateAgentVersionFromManifestRequest(metadata ?? new ChangeTrackingDictionary(), description, manifestId, parameterValues, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(CreateAgentVersionFromManifestRequest)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + CreateAgentVersionFromManifestRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual CreateAgentVersionFromManifestRequest PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeCreateAgentVersionFromManifestRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CreateAgentVersionFromManifestRequest)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CreateAgentVersionFromManifestRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CreateAgentVersionFromManifestRequest.cs new file mode 100644 index 000000000000..1c122cff6873 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CreateAgentVersionFromManifestRequest.cs @@ -0,0 +1,97 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The CreateAgentVersionFromManifestRequest. + public partial class CreateAgentVersionFromManifestRequest + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The manifest ID to import the agent version from. + /// The inputs to the manifest that will result in a fully materialized Agent. + /// or is null. + public CreateAgentVersionFromManifestRequest(string manifestId, IDictionary parameterValues) + { + Argument.AssertNotNull(manifestId, nameof(manifestId)); + Argument.AssertNotNull(parameterValues, nameof(parameterValues)); + + Metadata = new ChangeTrackingDictionary(); + ManifestId = manifestId; + ParameterValues = parameterValues; + } + + /// Initializes a new instance of . + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + /// A human-readable description of the agent. + /// The manifest ID to import the agent version from. + /// The inputs to the manifest that will result in a fully materialized Agent. + /// Keeps track of any properties unknown to the library. + internal CreateAgentVersionFromManifestRequest(IDictionary metadata, string description, string manifestId, IDictionary parameterValues, IDictionary additionalBinaryDataProperties) + { + Metadata = metadata; + Description = description; + ManifestId = manifestId; + ParameterValues = parameterValues; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + public IDictionary Metadata { get; } + + /// A human-readable description of the agent. + public string Description { get; set; } + + /// The manifest ID to import the agent version from. + public string ManifestId { get; } + + /// + /// The inputs to the manifest that will result in a fully materialized Agent. + /// 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" }. + /// + /// + /// + /// + public IDictionary ParameterValues { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CredentialType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CredentialType.cs index 04e4104368d7..6df69462b969 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CredentialType.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CredentialType.cs @@ -21,6 +21,8 @@ namespace Azure.AI.Projects private const string CustomValue = "CustomKeys"; /// No credential. private const string NoneValue = "None"; + /// Agentic identity credential. + private const string AgenticIdentityValue = "AgenticIdentityToken"; /// Initializes a new instance of . /// The value. @@ -47,6 +49,9 @@ public CredentialType(string value) /// No credential. public static CredentialType None { get; } = new CredentialType(NoneValue); + /// Agentic identity credential. + public static CredentialType AgenticIdentity { get; } = new CredentialType(AgenticIdentityValue); + /// Determines if two values are the same. /// The left value to compare. /// The right value to compare. diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CronTrigger.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CronTrigger.Serialization.cs new file mode 100644 index 000000000000..fd2a788a5aa8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CronTrigger.Serialization.cs @@ -0,0 +1,170 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Cron based trigger. + public partial class CronTrigger : Trigger, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal CronTrigger() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CronTrigger)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("expression"u8); + writer.WriteStringValue(Expression); + if (Optional.IsDefined(TimeZone)) + { + writer.WritePropertyName("timeZone"u8); + writer.WriteStringValue(TimeZone); + } + if (Optional.IsDefined(StartTime)) + { + writer.WritePropertyName("startTime"u8); + writer.WriteStringValue(StartTime); + } + if (Optional.IsDefined(EndTime)) + { + writer.WritePropertyName("endTime"u8); + writer.WriteStringValue(EndTime); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + CronTrigger IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (CronTrigger)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override Trigger JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CronTrigger)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCronTrigger(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static CronTrigger DeserializeCronTrigger(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TriggerType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string expression = default; + string timeZone = default; + string startTime = default; + string endTime = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new TriggerType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("expression"u8)) + { + expression = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("timeZone"u8)) + { + timeZone = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("startTime"u8)) + { + startTime = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("endTime"u8)) + { + endTime = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new CronTrigger( + @type, + additionalBinaryDataProperties, + expression, + timeZone, + startTime, + endTime); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(CronTrigger)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + CronTrigger IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (CronTrigger)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override Trigger PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeCronTrigger(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CronTrigger)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CronTrigger.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CronTrigger.cs new file mode 100644 index 000000000000..f6cb5e042fe2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CronTrigger.cs @@ -0,0 +1,50 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Cron based trigger. + public partial class CronTrigger : Trigger + { + /// Initializes a new instance of . + /// Cron expression that defines the schedule frequency. + /// is null. + public CronTrigger(string expression) : base(TriggerType.Cron) + { + Argument.AssertNotNull(expression, nameof(expression)); + + Expression = expression; + } + + /// Initializes a new instance of . + /// Type of the trigger. + /// Keeps track of any properties unknown to the library. + /// Cron expression that defines the schedule frequency. + /// Time zone for the cron schedule. + /// Start time for the cron schedule in ISO 8601 format. + /// End time for the cron schedule in ISO 8601 format. + internal CronTrigger(TriggerType @type, IDictionary additionalBinaryDataProperties, string expression, string timeZone, string startTime, string endTime) : base(@type, additionalBinaryDataProperties) + { + Expression = expression; + TimeZone = timeZone; + StartTime = startTime; + EndTime = endTime; + } + + /// Cron expression that defines the schedule frequency. + public string Expression { get; set; } + + /// Time zone for the cron schedule. + public string TimeZone { get; set; } + + /// Start time for the cron schedule in ISO 8601 format. + public string StartTime { get; set; } + + /// End time for the cron schedule in ISO 8601 format. + public string EndTime { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/DailyRecurrenceSchedule.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/DailyRecurrenceSchedule.Serialization.cs new file mode 100644 index 000000000000..3fbbc25f00d5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/DailyRecurrenceSchedule.Serialization.cs @@ -0,0 +1,141 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Daily recurrence schedule. + public partial class DailyRecurrenceSchedule : RecurrenceSchedule, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal DailyRecurrenceSchedule() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DailyRecurrenceSchedule)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("hours"u8); + writer.WriteStartArray(); + foreach (int item in Hours) + { + writer.WriteNumberValue(item); + } + writer.WriteEndArray(); + } + + /// The JSON reader. + /// The client options for reading and writing models. + DailyRecurrenceSchedule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (DailyRecurrenceSchedule)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override RecurrenceSchedule JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DailyRecurrenceSchedule)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDailyRecurrenceSchedule(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DailyRecurrenceSchedule DeserializeDailyRecurrenceSchedule(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RecurrenceType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList hours = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new RecurrenceType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("hours"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(item.GetInt32()); + } + hours = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new DailyRecurrenceSchedule(@type, additionalBinaryDataProperties, hours); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(DailyRecurrenceSchedule)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + DailyRecurrenceSchedule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (DailyRecurrenceSchedule)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override RecurrenceSchedule PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeDailyRecurrenceSchedule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DailyRecurrenceSchedule)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/DailyRecurrenceSchedule.cs b/sdk/ai/Azure.AI.Projects/src/Generated/DailyRecurrenceSchedule.cs new file mode 100644 index 000000000000..0e0c2b1e9a75 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/DailyRecurrenceSchedule.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects +{ + /// Daily recurrence schedule. + public partial class DailyRecurrenceSchedule : RecurrenceSchedule + { + /// Initializes a new instance of . + /// Hours for the recurrence schedule. + /// is null. + public DailyRecurrenceSchedule(IEnumerable hours) : base(RecurrenceType.Daily) + { + Argument.AssertNotNull(hours, nameof(hours)); + + Hours = hours.ToList(); + } + + /// Initializes a new instance of . + /// Recurrence type for the recurrence schedule. + /// Keeps track of any properties unknown to the library. + /// Hours for the recurrence schedule. + internal DailyRecurrenceSchedule(RecurrenceType @type, IDictionary additionalBinaryDataProperties, IList hours) : base(@type, additionalBinaryDataProperties) + { + Hours = hours; + } + + /// Hours for the recurrence schedule. + public IList Hours { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/DayOfWeek.cs b/sdk/ai/Azure.AI.Projects/src/Generated/DayOfWeek.cs new file mode 100644 index 000000000000..6d56704ad79f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/DayOfWeek.cs @@ -0,0 +1,92 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// Days of the week for recurrence schedule. + public readonly partial struct DayOfWeek : IEquatable + { + private readonly string _value; + /// Sunday. + private const string SundayValue = "Sunday"; + /// Monday. + private const string MondayValue = "Monday"; + /// Tuesday. + private const string TuesdayValue = "Tuesday"; + /// Wednesday. + private const string WednesdayValue = "Wednesday"; + /// Thursday. + private const string ThursdayValue = "Thursday"; + /// Friday. + private const string FridayValue = "Friday"; + /// Saturday. + private const string SaturdayValue = "Saturday"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public DayOfWeek(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Sunday. + public static DayOfWeek Sunday { get; } = new DayOfWeek(SundayValue); + + /// Monday. + public static DayOfWeek Monday { get; } = new DayOfWeek(MondayValue); + + /// Tuesday. + public static DayOfWeek Tuesday { get; } = new DayOfWeek(TuesdayValue); + + /// Wednesday. + public static DayOfWeek Wednesday { get; } = new DayOfWeek(WednesdayValue); + + /// Thursday. + public static DayOfWeek Thursday { get; } = new DayOfWeek(ThursdayValue); + + /// Friday. + public static DayOfWeek Friday { get; } = new DayOfWeek(FridayValue); + + /// Saturday. + public static DayOfWeek Saturday { get; } = new DayOfWeek(SaturdayValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(DayOfWeek left, DayOfWeek right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(DayOfWeek left, DayOfWeek right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator DayOfWeek(string value) => new DayOfWeek(value); + + /// Converts a string to a . + /// The value. + public static implicit operator DayOfWeek?(string value) => value == null ? null : new DayOfWeek(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DayOfWeek other && Equals(other); + + /// + public bool Equals(DayOfWeek other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/DeleteMemoryStoreResponse.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/DeleteMemoryStoreResponse.Serialization.cs new file mode 100644 index 000000000000..534852592386 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/DeleteMemoryStoreResponse.Serialization.cs @@ -0,0 +1,164 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The DeleteMemoryStoreResponse. + public partial class DeleteMemoryStoreResponse : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal DeleteMemoryStoreResponse() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DeleteMemoryStoreResponse)} does not support writing '{format}' format."); + } + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("deleted"u8); + writer.WriteBooleanValue(Deleted); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + DeleteMemoryStoreResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DeleteMemoryStoreResponse JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DeleteMemoryStoreResponse)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDeleteMemoryStoreResponse(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DeleteMemoryStoreResponse DeserializeDeleteMemoryStoreResponse(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @object = default; + string name = default; + bool deleted = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("object"u8)) + { + @object = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("deleted"u8)) + { + deleted = prop.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new DeleteMemoryStoreResponse(@object, name, deleted, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(DeleteMemoryStoreResponse)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + DeleteMemoryStoreResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DeleteMemoryStoreResponse PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeDeleteMemoryStoreResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DeleteMemoryStoreResponse)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator DeleteMemoryStoreResponse(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDeleteMemoryStoreResponse(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/DeleteMemoryStoreResponse.cs b/sdk/ai/Azure.AI.Projects/src/Generated/DeleteMemoryStoreResponse.cs new file mode 100644 index 000000000000..5009cb911093 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/DeleteMemoryStoreResponse.cs @@ -0,0 +1,47 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// The DeleteMemoryStoreResponse. + public partial class DeleteMemoryStoreResponse + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The name of the memory store. + /// Whether the memory store was successfully deleted. + internal DeleteMemoryStoreResponse(string name, bool deleted) + { + Name = name; + Deleted = deleted; + } + + /// Initializes a new instance of . + /// The object type. Always 'memory_store.deleted'. + /// The name of the memory store. + /// Whether the memory store was successfully deleted. + /// Keeps track of any properties unknown to the library. + internal DeleteMemoryStoreResponse(string @object, string name, bool deleted, IDictionary additionalBinaryDataProperties) + { + Object = @object; + Name = name; + Deleted = deleted; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The object type. Always 'memory_store.deleted'. + public string Object { get; } = "memory_store.deleted"; + + /// The name of the memory store. + public string Name { get; } + + /// Whether the memory store was successfully deleted. + public bool Deleted { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/DeleteScopeRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/DeleteScopeRequest.Serialization.cs new file mode 100644 index 000000000000..daa6338b0635 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/DeleteScopeRequest.Serialization.cs @@ -0,0 +1,150 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The DeleteScopeRequest. + internal partial class DeleteScopeRequest : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal DeleteScopeRequest() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DeleteScopeRequest)} does not support writing '{format}' format."); + } + writer.WritePropertyName("scope"u8); + writer.WriteStringValue(Scope); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + DeleteScopeRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DeleteScopeRequest JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DeleteScopeRequest)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDeleteScopeRequest(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static DeleteScopeRequest DeserializeDeleteScopeRequest(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string scope = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("scope"u8)) + { + scope = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new DeleteScopeRequest(scope, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(DeleteScopeRequest)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + DeleteScopeRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DeleteScopeRequest PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeDeleteScopeRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DeleteScopeRequest)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(DeleteScopeRequest deleteScopeRequest) + { + if (deleteScopeRequest == null) + { + return null; + } + return BinaryContent.Create(deleteScopeRequest, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/DeleteScopeRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/DeleteScopeRequest.cs new file mode 100644 index 000000000000..9c43b6bd4065 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/DeleteScopeRequest.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// The DeleteScopeRequest. + internal partial class DeleteScopeRequest + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The namespace that logically groups and isolates memories to delete, such as a user ID. + internal DeleteScopeRequest(string scope) + { + Scope = scope; + } + + /// Initializes a new instance of . + /// The namespace that logically groups and isolates memories to delete, such as a user ID. + /// Keeps track of any properties unknown to the library. + internal DeleteScopeRequest(string scope, IDictionary additionalBinaryDataProperties) + { + Scope = scope; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The namespace that logically groups and isolates memories to delete, such as a user ID. + public string Scope { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvalCompareReport.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvalCompareReport.Serialization.cs new file mode 100644 index 000000000000..4d46e6c4b574 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvalCompareReport.Serialization.cs @@ -0,0 +1,149 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Insights from the evaluation comparison. + public partial class EvalCompareReport : InsightResult, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal EvalCompareReport() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvalCompareReport)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("comparisons"u8); + writer.WriteStartArray(); + foreach (EvalRunResultComparison item in Comparisons) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + writer.WritePropertyName("method"u8); + writer.WriteStringValue(Method); + } + + /// The JSON reader. + /// The client options for reading and writing models. + EvalCompareReport IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (EvalCompareReport)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InsightResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvalCompareReport)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEvalCompareReport(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EvalCompareReport DeserializeEvalCompareReport(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InsightType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList comparisons = default; + string @method = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InsightType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("comparisons"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(EvalRunResultComparison.DeserializeEvalRunResultComparison(item, options)); + } + comparisons = array; + continue; + } + if (prop.NameEquals("method"u8)) + { + @method = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new EvalCompareReport(@type, additionalBinaryDataProperties, comparisons, @method); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(EvalCompareReport)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + EvalCompareReport IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (EvalCompareReport)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InsightResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEvalCompareReport(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EvalCompareReport)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvalCompareReport.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvalCompareReport.cs new file mode 100644 index 000000000000..a49e0ed9d9d4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvalCompareReport.cs @@ -0,0 +1,40 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects +{ + /// Insights from the evaluation comparison. + public partial class EvalCompareReport : InsightResult + { + /// Initializes a new instance of . + /// Comparison results for each treatment run against the baseline. + /// The statistical method used for comparison. + internal EvalCompareReport(IEnumerable comparisons, string @method) : base(InsightType.EvaluationComparison) + { + Comparisons = comparisons.ToList(); + Method = @method; + } + + /// Initializes a new instance of . + /// The type of insights result. + /// Keeps track of any properties unknown to the library. + /// Comparison results for each treatment run against the baseline. + /// The statistical method used for comparison. + internal EvalCompareReport(InsightType @type, IDictionary additionalBinaryDataProperties, IList comparisons, string @method) : base(@type, additionalBinaryDataProperties) + { + Comparisons = comparisons; + Method = @method; + } + + /// Comparison results for each treatment run against the baseline. + public IList Comparisons { get; } + + /// The statistical method used for comparison. + public string Method { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvalResult.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvalResult.Serialization.cs new file mode 100644 index 000000000000..0436bf8fb50d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvalResult.Serialization.cs @@ -0,0 +1,163 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Result of the evaluation. + public partial class EvalResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal EvalResult() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvalResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + writer.WritePropertyName("score"u8); + writer.WriteNumberValue(Score); + writer.WritePropertyName("passed"u8); + writer.WriteBooleanValue(Passed); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + EvalResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual EvalResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvalResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEvalResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EvalResult DeserializeEvalResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string @type = default; + float score = default; + bool passed = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("score"u8)) + { + score = prop.Value.GetSingle(); + continue; + } + if (prop.NameEquals("passed"u8)) + { + passed = prop.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new EvalResult(name, @type, score, passed, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(EvalResult)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + EvalResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual EvalResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEvalResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EvalResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvalResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvalResult.cs new file mode 100644 index 000000000000..c459f3c60835 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvalResult.cs @@ -0,0 +1,56 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Result of the evaluation. + public partial class EvalResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// name of the check. + /// type of the check. + /// score. + /// indicates if the check passed or failed. + internal EvalResult(string name, string @type, float score, bool passed) + { + Name = name; + Type = @type; + Score = score; + Passed = passed; + } + + /// Initializes a new instance of . + /// name of the check. + /// type of the check. + /// score. + /// indicates if the check passed or failed. + /// Keeps track of any properties unknown to the library. + internal EvalResult(string name, string @type, float score, bool passed, IDictionary additionalBinaryDataProperties) + { + Name = name; + Type = @type; + Score = score; + Passed = passed; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// name of the check. + public string Name { get; } + + /// type of the check. + public string Type { get; } + + /// score. + public float Score { get; } + + /// indicates if the check passed or failed. + public bool Passed { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvalRunResultCompareItem.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvalRunResultCompareItem.Serialization.cs new file mode 100644 index 000000000000..043e6d48c999 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvalRunResultCompareItem.Serialization.cs @@ -0,0 +1,177 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Metric comparison for a treatment against the baseline. + public partial class EvalRunResultCompareItem : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal EvalRunResultCompareItem() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvalRunResultCompareItem)} does not support writing '{format}' format."); + } + writer.WritePropertyName("treatmentRunId"u8); + writer.WriteStringValue(TreatmentRunId); + writer.WritePropertyName("treatmentRunSummary"u8); + writer.WriteObjectValue(TreatmentRunSummary, options); + writer.WritePropertyName("deltaEstimate"u8); + writer.WriteNumberValue(DeltaEstimate); + writer.WritePropertyName("pValue"u8); + writer.WriteNumberValue(PValue); + writer.WritePropertyName("treatmentEffect"u8); + writer.WriteStringValue(TreatmentEffect.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + EvalRunResultCompareItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual EvalRunResultCompareItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvalRunResultCompareItem)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEvalRunResultCompareItem(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EvalRunResultCompareItem DeserializeEvalRunResultCompareItem(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string treatmentRunId = default; + EvalRunResultSummary treatmentRunSummary = default; + float deltaEstimate = default; + float pValue = default; + TreatmentEffectType treatmentEffect = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("treatmentRunId"u8)) + { + treatmentRunId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("treatmentRunSummary"u8)) + { + treatmentRunSummary = EvalRunResultSummary.DeserializeEvalRunResultSummary(prop.Value, options); + continue; + } + if (prop.NameEquals("deltaEstimate"u8)) + { + deltaEstimate = prop.Value.GetSingle(); + continue; + } + if (prop.NameEquals("pValue"u8)) + { + pValue = prop.Value.GetSingle(); + continue; + } + if (prop.NameEquals("treatmentEffect"u8)) + { + treatmentEffect = new TreatmentEffectType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new EvalRunResultCompareItem( + treatmentRunId, + treatmentRunSummary, + deltaEstimate, + pValue, + treatmentEffect, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(EvalRunResultCompareItem)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + EvalRunResultCompareItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual EvalRunResultCompareItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEvalRunResultCompareItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EvalRunResultCompareItem)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvalRunResultCompareItem.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvalRunResultCompareItem.cs new file mode 100644 index 000000000000..669bfe85a374 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvalRunResultCompareItem.cs @@ -0,0 +1,63 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Metric comparison for a treatment against the baseline. + public partial class EvalRunResultCompareItem + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The treatment run ID. + /// Summary statistics of the treatment run. + /// Estimated difference between treatment and baseline. + /// P-value for the treatment effect. + /// Type of treatment effect. + internal EvalRunResultCompareItem(string treatmentRunId, EvalRunResultSummary treatmentRunSummary, float deltaEstimate, float pValue, TreatmentEffectType treatmentEffect) + { + TreatmentRunId = treatmentRunId; + TreatmentRunSummary = treatmentRunSummary; + DeltaEstimate = deltaEstimate; + PValue = pValue; + TreatmentEffect = treatmentEffect; + } + + /// Initializes a new instance of . + /// The treatment run ID. + /// Summary statistics of the treatment run. + /// Estimated difference between treatment and baseline. + /// P-value for the treatment effect. + /// Type of treatment effect. + /// Keeps track of any properties unknown to the library. + internal EvalRunResultCompareItem(string treatmentRunId, EvalRunResultSummary treatmentRunSummary, float deltaEstimate, float pValue, TreatmentEffectType treatmentEffect, IDictionary additionalBinaryDataProperties) + { + TreatmentRunId = treatmentRunId; + TreatmentRunSummary = treatmentRunSummary; + DeltaEstimate = deltaEstimate; + PValue = pValue; + TreatmentEffect = treatmentEffect; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The treatment run ID. + public string TreatmentRunId { get; } + + /// Summary statistics of the treatment run. + public EvalRunResultSummary TreatmentRunSummary { get; } + + /// Estimated difference between treatment and baseline. + public float DeltaEstimate { get; } + + /// P-value for the treatment effect. + public float PValue { get; } + + /// Type of treatment effect. + public TreatmentEffectType TreatmentEffect { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvalRunResultComparison.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvalRunResultComparison.Serialization.cs new file mode 100644 index 000000000000..7726523d7a53 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvalRunResultComparison.Serialization.cs @@ -0,0 +1,187 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Comparison results for treatment runs against the baseline. + public partial class EvalRunResultComparison : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal EvalRunResultComparison() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvalRunResultComparison)} does not support writing '{format}' format."); + } + writer.WritePropertyName("testingCriteria"u8); + writer.WriteStringValue(TestingCriteria); + writer.WritePropertyName("metric"u8); + writer.WriteStringValue(Metric); + writer.WritePropertyName("evaluator"u8); + writer.WriteStringValue(Evaluator); + writer.WritePropertyName("baselineRunSummary"u8); + writer.WriteObjectValue(BaselineRunSummary, options); + writer.WritePropertyName("compareItems"u8); + writer.WriteStartArray(); + foreach (EvalRunResultCompareItem item in CompareItems) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + EvalRunResultComparison IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual EvalRunResultComparison JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvalRunResultComparison)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEvalRunResultComparison(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EvalRunResultComparison DeserializeEvalRunResultComparison(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string testingCriteria = default; + string metric = default; + string evaluator = default; + EvalRunResultSummary baselineRunSummary = default; + IList compareItems = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("testingCriteria"u8)) + { + testingCriteria = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("metric"u8)) + { + metric = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("evaluator"u8)) + { + evaluator = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("baselineRunSummary"u8)) + { + baselineRunSummary = EvalRunResultSummary.DeserializeEvalRunResultSummary(prop.Value, options); + continue; + } + if (prop.NameEquals("compareItems"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(EvalRunResultCompareItem.DeserializeEvalRunResultCompareItem(item, options)); + } + compareItems = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new EvalRunResultComparison( + testingCriteria, + metric, + evaluator, + baselineRunSummary, + compareItems, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(EvalRunResultComparison)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + EvalRunResultComparison IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual EvalRunResultComparison PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEvalRunResultComparison(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EvalRunResultComparison)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvalRunResultComparison.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvalRunResultComparison.cs new file mode 100644 index 000000000000..36c943cf21bb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvalRunResultComparison.cs @@ -0,0 +1,64 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects +{ + /// Comparison results for treatment runs against the baseline. + public partial class EvalRunResultComparison + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Name of the testing criteria. + /// Metric being evaluated. + /// Name of the evaluator for this testing criteria. + /// Summary statistics of the baseline run. + /// List of comparison results for each treatment run. + internal EvalRunResultComparison(string testingCriteria, string metric, string evaluator, EvalRunResultSummary baselineRunSummary, IEnumerable compareItems) + { + TestingCriteria = testingCriteria; + Metric = metric; + Evaluator = evaluator; + BaselineRunSummary = baselineRunSummary; + CompareItems = compareItems.ToList(); + } + + /// Initializes a new instance of . + /// Name of the testing criteria. + /// Metric being evaluated. + /// Name of the evaluator for this testing criteria. + /// Summary statistics of the baseline run. + /// List of comparison results for each treatment run. + /// Keeps track of any properties unknown to the library. + internal EvalRunResultComparison(string testingCriteria, string metric, string evaluator, EvalRunResultSummary baselineRunSummary, IList compareItems, IDictionary additionalBinaryDataProperties) + { + TestingCriteria = testingCriteria; + Metric = metric; + Evaluator = evaluator; + BaselineRunSummary = baselineRunSummary; + CompareItems = compareItems; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Name of the testing criteria. + public string TestingCriteria { get; } + + /// Metric being evaluated. + public string Metric { get; } + + /// Name of the evaluator for this testing criteria. + public string Evaluator { get; } + + /// Summary statistics of the baseline run. + public EvalRunResultSummary BaselineRunSummary { get; } + + /// List of comparison results for each treatment run. + public IList CompareItems { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvalRunResultSummary.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvalRunResultSummary.Serialization.cs new file mode 100644 index 000000000000..032d967b422e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvalRunResultSummary.Serialization.cs @@ -0,0 +1,163 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Summary statistics of a metric in an evaluation run. + public partial class EvalRunResultSummary : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal EvalRunResultSummary() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvalRunResultSummary)} does not support writing '{format}' format."); + } + writer.WritePropertyName("runId"u8); + writer.WriteStringValue(RunId); + writer.WritePropertyName("sampleCount"u8); + writer.WriteNumberValue(SampleCount); + writer.WritePropertyName("average"u8); + writer.WriteNumberValue(Average); + writer.WritePropertyName("standardDeviation"u8); + writer.WriteNumberValue(StandardDeviation); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + EvalRunResultSummary IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual EvalRunResultSummary JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvalRunResultSummary)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEvalRunResultSummary(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EvalRunResultSummary DeserializeEvalRunResultSummary(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string runId = default; + int sampleCount = default; + float average = default; + float standardDeviation = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("runId"u8)) + { + runId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("sampleCount"u8)) + { + sampleCount = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("average"u8)) + { + average = prop.Value.GetSingle(); + continue; + } + if (prop.NameEquals("standardDeviation"u8)) + { + standardDeviation = prop.Value.GetSingle(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new EvalRunResultSummary(runId, sampleCount, average, standardDeviation, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(EvalRunResultSummary)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + EvalRunResultSummary IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual EvalRunResultSummary PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEvalRunResultSummary(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EvalRunResultSummary)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvalRunResultSummary.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvalRunResultSummary.cs new file mode 100644 index 000000000000..3336bd0a9ce3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvalRunResultSummary.cs @@ -0,0 +1,56 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Summary statistics of a metric in an evaluation run. + public partial class EvalRunResultSummary + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The evaluation run ID. + /// Number of samples in the evaluation run. + /// Average value of the metric in the evaluation run. + /// Standard deviation of the metric in the evaluation run. + internal EvalRunResultSummary(string runId, int sampleCount, float average, float standardDeviation) + { + RunId = runId; + SampleCount = sampleCount; + Average = average; + StandardDeviation = standardDeviation; + } + + /// Initializes a new instance of . + /// The evaluation run ID. + /// Number of samples in the evaluation run. + /// Average value of the metric in the evaluation run. + /// Standard deviation of the metric in the evaluation run. + /// Keeps track of any properties unknown to the library. + internal EvalRunResultSummary(string runId, int sampleCount, float average, float standardDeviation, IDictionary additionalBinaryDataProperties) + { + RunId = runId; + SampleCount = sampleCount; + Average = average; + StandardDeviation = standardDeviation; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The evaluation run ID. + public string RunId { get; } + + /// Number of samples in the evaluation run. + public int SampleCount { get; } + + /// Average value of the metric in the evaluation run. + public float Average { get; } + + /// Standard deviation of the metric in the evaluation run. + public float StandardDeviation { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationComparisonRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationComparisonRequest.Serialization.cs new file mode 100644 index 000000000000..fed34470a6b6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationComparisonRequest.Serialization.cs @@ -0,0 +1,169 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Evaluation Comparison Request. + public partial class EvaluationComparisonRequest : InsightRequest, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal EvaluationComparisonRequest() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationComparisonRequest)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("evalId"u8); + writer.WriteStringValue(EvalId); + writer.WritePropertyName("baselineRunId"u8); + writer.WriteStringValue(BaselineRunId); + writer.WritePropertyName("treatmentRunIds"u8); + writer.WriteStartArray(); + foreach (string item in TreatmentRunIds) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + + /// The JSON reader. + /// The client options for reading and writing models. + EvaluationComparisonRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (EvaluationComparisonRequest)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InsightRequest JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationComparisonRequest)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEvaluationComparisonRequest(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EvaluationComparisonRequest DeserializeEvaluationComparisonRequest(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InsightType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string evalId = default; + string baselineRunId = default; + IList treatmentRunIds = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InsightType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("evalId"u8)) + { + evalId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("baselineRunId"u8)) + { + baselineRunId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("treatmentRunIds"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + treatmentRunIds = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new EvaluationComparisonRequest(@type, additionalBinaryDataProperties, evalId, baselineRunId, treatmentRunIds); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(EvaluationComparisonRequest)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + EvaluationComparisonRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (EvaluationComparisonRequest)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InsightRequest PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEvaluationComparisonRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EvaluationComparisonRequest)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationComparisonRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationComparisonRequest.cs new file mode 100644 index 000000000000..72252982f2c2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationComparisonRequest.cs @@ -0,0 +1,52 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects +{ + /// Evaluation Comparison Request. + public partial class EvaluationComparisonRequest : InsightRequest + { + /// Initializes a new instance of . + /// Identifier for the evaluation. + /// The baseline run ID for comparison. + /// List of treatment run IDs for comparison. + /// , or is null. + public EvaluationComparisonRequest(string evalId, string baselineRunId, IEnumerable treatmentRunIds) : base(InsightType.EvaluationComparison) + { + Argument.AssertNotNull(evalId, nameof(evalId)); + Argument.AssertNotNull(baselineRunId, nameof(baselineRunId)); + Argument.AssertNotNull(treatmentRunIds, nameof(treatmentRunIds)); + + EvalId = evalId; + BaselineRunId = baselineRunId; + TreatmentRunIds = treatmentRunIds.ToList(); + } + + /// Initializes a new instance of . + /// The type of request. + /// Keeps track of any properties unknown to the library. + /// Identifier for the evaluation. + /// The baseline run ID for comparison. + /// List of treatment run IDs for comparison. + internal EvaluationComparisonRequest(InsightType @type, IDictionary additionalBinaryDataProperties, string evalId, string baselineRunId, IList treatmentRunIds) : base(@type, additionalBinaryDataProperties) + { + EvalId = evalId; + BaselineRunId = baselineRunId; + TreatmentRunIds = treatmentRunIds; + } + + /// Identifier for the evaluation. + public string EvalId { get; set; } + + /// The baseline run ID for comparison. + public string BaselineRunId { get; set; } + + /// List of treatment run IDs for comparison. + public IList TreatmentRunIds { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationResultSample.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationResultSample.Serialization.cs new file mode 100644 index 000000000000..d4673568c29b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationResultSample.Serialization.cs @@ -0,0 +1,179 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// A sample from the evaluation result. + public partial class EvaluationResultSample : InsightSample, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal EvaluationResultSample() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationResultSample)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("evaluationResult"u8); + writer.WriteObjectValue(EvaluationResult, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + EvaluationResultSample IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (EvaluationResultSample)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InsightSample JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationResultSample)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEvaluationResultSample(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EvaluationResultSample DeserializeEvaluationResultSample(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + SampleType @type = default; + IDictionary features = default; + IDictionary correlationInfo = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + EvalResult evaluationResult = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + @type = new SampleType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("features"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + features = dictionary; + continue; + } + if (prop.NameEquals("correlationInfo"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + correlationInfo = dictionary; + continue; + } + if (prop.NameEquals("evaluationResult"u8)) + { + evaluationResult = EvalResult.DeserializeEvalResult(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new EvaluationResultSample( + id, + @type, + features, + correlationInfo, + additionalBinaryDataProperties, + evaluationResult); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(EvaluationResultSample)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + EvaluationResultSample IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (EvaluationResultSample)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InsightSample PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEvaluationResultSample(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EvaluationResultSample)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationResultSample.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationResultSample.cs new file mode 100644 index 000000000000..d692464f63cd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationResultSample.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// A sample from the evaluation result. + public partial class EvaluationResultSample : InsightSample + { + /// Initializes a new instance of . + /// The unique identifier for the analysis sample. + /// Features to help with additional filtering of data in UX. + /// Info about the correlation for the analysis sample. + /// Evaluation result for the analysis sample. + internal EvaluationResultSample(string id, IDictionary features, IDictionary correlationInfo, EvalResult evaluationResult) : base(id, SampleType.EvaluationResultSample, features, correlationInfo) + { + EvaluationResult = evaluationResult; + } + + /// Initializes a new instance of . + /// The unique identifier for the analysis sample. + /// Sample type. + /// Features to help with additional filtering of data in UX. + /// Info about the correlation for the analysis sample. + /// Keeps track of any properties unknown to the library. + /// Evaluation result for the analysis sample. + internal EvaluationResultSample(string id, SampleType @type, IDictionary features, IDictionary correlationInfo, IDictionary additionalBinaryDataProperties, EvalResult evaluationResult) : base(id, @type, features, correlationInfo, additionalBinaryDataProperties) + { + EvaluationResult = evaluationResult; + } + + /// Evaluation result for the analysis sample. + public EvalResult EvaluationResult { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRule.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRule.Serialization.cs new file mode 100644 index 000000000000..97fbf8aba22f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRule.Serialization.cs @@ -0,0 +1,265 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Evaluation rule model. + public partial class EvaluationRule : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal EvaluationRule() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationRule)} does not support writing '{format}' format."); + } + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("action"u8); + writer.WriteObjectValue(Action, options); + if (Optional.IsDefined(Filter)) + { + writer.WritePropertyName("filter"u8); + writer.WriteObjectValue(Filter, options); + } + writer.WritePropertyName("eventType"u8); + writer.WriteStringValue(EventType.ToString()); + writer.WritePropertyName("enabled"u8); + writer.WriteBooleanValue(Enabled); + if (options.Format != "W") + { + writer.WritePropertyName("systemData"u8); + writer.WriteStartObject(); + foreach (var item in SystemData) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + EvaluationRule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual EvaluationRule JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationRule)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEvaluationRule(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EvaluationRule DeserializeEvaluationRule(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string displayName = default; + string description = default; + EvaluationRuleAction action = default; + EvaluationRuleFilter filter = default; + EvaluationRuleEventType eventType = default; + bool enabled = default; + IReadOnlyDictionary systemData = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("displayName"u8)) + { + displayName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("action"u8)) + { + action = EvaluationRuleAction.DeserializeEvaluationRuleAction(prop.Value, options); + continue; + } + if (prop.NameEquals("filter"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + filter = EvaluationRuleFilter.DeserializeEvaluationRuleFilter(prop.Value, options); + continue; + } + if (prop.NameEquals("eventType"u8)) + { + eventType = new EvaluationRuleEventType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("enabled"u8)) + { + enabled = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("systemData"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + systemData = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new EvaluationRule( + id, + displayName, + description, + action, + filter, + eventType, + enabled, + systemData, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(EvaluationRule)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + EvaluationRule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual EvaluationRule PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEvaluationRule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EvaluationRule)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(EvaluationRule evaluationRule) + { + if (evaluationRule == null) + { + return null; + } + return BinaryContent.Create(evaluationRule, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + public static explicit operator EvaluationRule(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEvaluationRule(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRule.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRule.cs new file mode 100644 index 000000000000..6f3b77612897 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRule.cs @@ -0,0 +1,78 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Evaluation rule model. + public partial class EvaluationRule + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Definition of the evaluation rule action. + /// Event type that the evaluation rule applies to. + /// Indicates whether the evaluation rule is enabled. Default is true. + /// is null. + public EvaluationRule(EvaluationRuleAction action, EvaluationRuleEventType eventType, bool enabled) + { + Argument.AssertNotNull(action, nameof(action)); + + Action = action; + EventType = eventType; + Enabled = enabled; + SystemData = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Unique identifier for the evaluation rule. + /// Display Name for the evaluation rule. + /// Description for the evaluation rule. + /// Definition of the evaluation rule action. + /// Filter condition of the evaluation rule. + /// Event type that the evaluation rule applies to. + /// Indicates whether the evaluation rule is enabled. Default is true. + /// System metadata for the evaluation rule. + /// Keeps track of any properties unknown to the library. + internal EvaluationRule(string id, string displayName, string description, EvaluationRuleAction action, EvaluationRuleFilter filter, EvaluationRuleEventType eventType, bool enabled, IReadOnlyDictionary systemData, IDictionary additionalBinaryDataProperties) + { + Id = id; + DisplayName = displayName; + Description = description; + Action = action; + Filter = filter; + EventType = eventType; + Enabled = enabled; + SystemData = systemData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Unique identifier for the evaluation rule. + public string Id { get; } + + /// Display Name for the evaluation rule. + public string DisplayName { get; set; } + + /// Description for the evaluation rule. + public string Description { get; set; } + + /// Definition of the evaluation rule action. + public EvaluationRuleAction Action { get; set; } + + /// Filter condition of the evaluation rule. + public EvaluationRuleFilter Filter { get; set; } + + /// Event type that the evaluation rule applies to. + public EvaluationRuleEventType EventType { get; set; } + + /// Indicates whether the evaluation rule is enabled. Default is true. + public bool Enabled { get; set; } + + /// System metadata for the evaluation rule. + public IReadOnlyDictionary SystemData { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRuleAction.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRuleAction.Serialization.cs new file mode 100644 index 000000000000..a58ddbed85ca --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRuleAction.Serialization.cs @@ -0,0 +1,138 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// + /// Evaluation action model. + /// Please note this is the abstract base class. The derived classes available for instantiation are: and . + /// + [PersistableModelProxy(typeof(UnknownEvaluationRuleAction))] + public abstract partial class EvaluationRuleAction : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal EvaluationRuleAction() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationRuleAction)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + EvaluationRuleAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual EvaluationRuleAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationRuleAction)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEvaluationRuleAction(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EvaluationRuleAction DeserializeEvaluationRuleAction(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "continuousEvaluation": + return ContinuousEvaluationRuleAction.DeserializeContinuousEvaluationRuleAction(element, options); + case "humanEvaluation": + return HumanEvaluationRuleAction.DeserializeHumanEvaluationRuleAction(element, options); + } + } + return UnknownEvaluationRuleAction.DeserializeUnknownEvaluationRuleAction(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(EvaluationRuleAction)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + EvaluationRuleAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual EvaluationRuleAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEvaluationRuleAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EvaluationRuleAction)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRuleAction.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRuleAction.cs new file mode 100644 index 000000000000..6ae50beb589d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRuleAction.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// + /// Evaluation action model. + /// Please note this is the abstract base class. The derived classes available for instantiation are: and . + /// + public abstract partial class EvaluationRuleAction + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Type of the evaluation action. + private protected EvaluationRuleAction(EvaluationRuleActionType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// Type of the evaluation action. + /// Keeps track of any properties unknown to the library. + internal EvaluationRuleAction(EvaluationRuleActionType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Type of the evaluation action. + internal EvaluationRuleActionType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRuleActionType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRuleActionType.cs new file mode 100644 index 000000000000..1b0a62ded638 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRuleActionType.cs @@ -0,0 +1,67 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// Type of the evaluation action. + public readonly partial struct EvaluationRuleActionType : IEquatable + { + private readonly string _value; + /// Continuous evaluation. + private const string ContinuousEvaluationValue = "continuousEvaluation"; + /// Human evaluation. + private const string HumanEvaluationValue = "humanEvaluation"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public EvaluationRuleActionType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Continuous evaluation. + public static EvaluationRuleActionType ContinuousEvaluation { get; } = new EvaluationRuleActionType(ContinuousEvaluationValue); + + /// Human evaluation. + public static EvaluationRuleActionType HumanEvaluation { get; } = new EvaluationRuleActionType(HumanEvaluationValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(EvaluationRuleActionType left, EvaluationRuleActionType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(EvaluationRuleActionType left, EvaluationRuleActionType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator EvaluationRuleActionType(string value) => new EvaluationRuleActionType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator EvaluationRuleActionType?(string value) => value == null ? null : new EvaluationRuleActionType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is EvaluationRuleActionType other && Equals(other); + + /// + public bool Equals(EvaluationRuleActionType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRuleEventType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRuleEventType.cs new file mode 100644 index 000000000000..44ec7f87c346 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRuleEventType.cs @@ -0,0 +1,67 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// Type of the evaluation rule event. + public readonly partial struct EvaluationRuleEventType : IEquatable + { + private readonly string _value; + /// Response completed. + private const string ResponseCompletedValue = "responseCompleted"; + /// Manual trigger. + private const string ManualValue = "manual"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public EvaluationRuleEventType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Response completed. + public static EvaluationRuleEventType ResponseCompleted { get; } = new EvaluationRuleEventType(ResponseCompletedValue); + + /// Manual trigger. + public static EvaluationRuleEventType Manual { get; } = new EvaluationRuleEventType(ManualValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(EvaluationRuleEventType left, EvaluationRuleEventType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(EvaluationRuleEventType left, EvaluationRuleEventType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator EvaluationRuleEventType(string value) => new EvaluationRuleEventType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator EvaluationRuleEventType?(string value) => value == null ? null : new EvaluationRuleEventType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is EvaluationRuleEventType other && Equals(other); + + /// + public bool Equals(EvaluationRuleEventType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRuleFilter.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRuleFilter.Serialization.cs new file mode 100644 index 000000000000..a21f61af4e9a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRuleFilter.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Evaluation filter model. + public partial class EvaluationRuleFilter : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal EvaluationRuleFilter() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationRuleFilter)} does not support writing '{format}' format."); + } + writer.WritePropertyName("agentName"u8); + writer.WriteStringValue(AgentName); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + EvaluationRuleFilter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual EvaluationRuleFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationRuleFilter)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEvaluationRuleFilter(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EvaluationRuleFilter DeserializeEvaluationRuleFilter(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string agentName = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("agentName"u8)) + { + agentName = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new EvaluationRuleFilter(agentName, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(EvaluationRuleFilter)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + EvaluationRuleFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual EvaluationRuleFilter PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEvaluationRuleFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EvaluationRuleFilter)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRuleFilter.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRuleFilter.cs new file mode 100644 index 000000000000..7ceca614e416 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRuleFilter.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Evaluation filter model. + public partial class EvaluationRuleFilter + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Filter by agent name. + /// is null. + public EvaluationRuleFilter(string agentName) + { + Argument.AssertNotNull(agentName, nameof(agentName)); + + AgentName = agentName; + } + + /// Initializes a new instance of . + /// Filter by agent name. + /// Keeps track of any properties unknown to the library. + internal EvaluationRuleFilter(string agentName, IDictionary additionalBinaryDataProperties) + { + AgentName = agentName; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Filter by agent name. + public string AgentName { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRules.RestClient.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRules.RestClient.cs new file mode 100644 index 000000000000..c73940c8178f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRules.RestClient.cs @@ -0,0 +1,107 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace Azure.AI.Projects +{ + /// + public partial class EvaluationRules + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier200201; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier200201 => _pipelineMessageClassifier200201 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200, 201 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 = PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateGetRequest(string id, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/evaluationrules/", false); + uri.AppendPath(id, true); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + request.Headers.Set("x-ms-client-request-id", request.ClientRequestId); + return message; + } + + internal PipelineMessage CreateDeleteRequest(string id, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/evaluationrules/", false); + uri.AppendPath(id, true); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "DELETE", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + message.Apply(options); + request.Headers.Set("x-ms-client-request-id", request.ClientRequestId); + return message; + } + + internal PipelineMessage CreateCreateOrUpdateRequest(string id, BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/evaluationrules/", false); + uri.AppendPath(id, true); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "PUT", PipelineMessageClassifier200201); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Headers.Set("Accept", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal PipelineMessage CreateGetAllRequest(string actionType, string agentName, bool? enabled, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/evaluationrules", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (actionType != null) + { + uri.AppendQuery("actionType", actionType, true); + } + if (agentName != null) + { + uri.AppendQuery("agentName", agentName, true); + } + if (enabled != null) + { + uri.AppendQuery("enabled", TypeFormatters.ConvertToString(enabled), true); + } + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + request.Headers.Set("x-ms-client-request-id", request.ClientRequestId); + return message; + } + + internal PipelineMessage CreateNextGetAllRequest(Uri nextPage, string actionType, string agentName, bool? enabled, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(nextPage); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + request.Headers.Set("x-ms-client-request-id", request.ClientRequestId); + return message; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRules.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRules.cs new file mode 100644 index 000000000000..0bd91b928d0c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRules.cs @@ -0,0 +1,320 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; + +namespace Azure.AI.Projects +{ + /// The EvaluationRules sub-client. + public partial class EvaluationRules + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of EvaluationRules for mocking. + protected EvaluationRules() + { + } + + /// Initializes a new instance of EvaluationRules. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal EvaluationRules(ClientPipeline pipeline, Uri endpoint, string apiVersion) + { + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } + + /// + /// [Protocol Method] Get an evaluation rule. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Unique identifier for the evaluation rule. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(string id, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + using PipelineMessage message = CreateGetRequest(id, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Get an evaluation rule. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Unique identifier for the evaluation rule. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(string id, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + using PipelineMessage message = CreateGetRequest(id, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Get an evaluation rule. + /// Unique identifier for the evaluation rule. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult Get(string id, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + ClientResult result = Get(id, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((EvaluationRule)result, result.GetRawResponse()); + } + + /// Get an evaluation rule. + /// Unique identifier for the evaluation rule. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(string id, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + ClientResult result = await GetAsync(id, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((EvaluationRule)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] Delete an evaluation rule. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Unique identifier for the evaluation rule. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Delete(string id, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + using PipelineMessage message = CreateDeleteRequest(id, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Delete an evaluation rule. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Unique identifier for the evaluation rule. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task DeleteAsync(string id, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + using PipelineMessage message = CreateDeleteRequest(id, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Delete an evaluation rule. + /// Unique identifier for the evaluation rule. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult Delete(string id, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + return Delete(id, cancellationToken.ToRequestOptions()); + } + + /// Delete an evaluation rule. + /// Unique identifier for the evaluation rule. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task DeleteAsync(string id, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + return await DeleteAsync(id, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + + /// + /// [Protocol Method] Create or update an evaluation rule. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Unique identifier for the evaluation rule. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult CreateOrUpdate(string id, BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateCreateOrUpdateRequest(id, content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Create or update an evaluation rule. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Unique identifier for the evaluation rule. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task CreateOrUpdateAsync(string id, BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateCreateOrUpdateRequest(id, content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Create or update an evaluation rule. + /// Unique identifier for the evaluation rule. + /// Evaluation rule resource. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult CreateOrUpdate(string id, EvaluationRule evaluationRule, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + Argument.AssertNotNull(evaluationRule, nameof(evaluationRule)); + + ClientResult result = CreateOrUpdate(id, evaluationRule, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((EvaluationRule)result, result.GetRawResponse()); + } + + /// Create or update an evaluation rule. + /// Unique identifier for the evaluation rule. + /// Evaluation rule resource. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> CreateOrUpdateAsync(string id, EvaluationRule evaluationRule, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + Argument.AssertNotNull(evaluationRule, nameof(evaluationRule)); + + ClientResult result = await CreateOrUpdateAsync(id, evaluationRule, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((EvaluationRule)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] List all evaluation rules. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Filter by the type of evaluation rule. + /// Filter by the agent name. + /// Filter by the enabled status. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual CollectionResult GetAll(string actionType, string agentName, bool? enabled, RequestOptions options) + { + return new EvaluationRulesGetAllCollectionResult(this, actionType, agentName, enabled, options); + } + + /// + /// [Protocol Method] List all evaluation rules. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Filter by the type of evaluation rule. + /// Filter by the agent name. + /// Filter by the enabled status. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual AsyncCollectionResult GetAllAsync(string actionType, string agentName, bool? enabled, RequestOptions options) + { + return new EvaluationRulesGetAllAsyncCollectionResult(this, actionType, agentName, enabled, options); + } + + /// List all evaluation rules. + /// Filter by the type of evaluation rule. + /// Filter by the agent name. + /// Filter by the enabled status. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual CollectionResult GetAll(EvaluationRuleActionType? actionType = default, string agentName = default, bool? enabled = default, CancellationToken cancellationToken = default) + { + return new EvaluationRulesGetAllCollectionResultOfT(this, actionType?.ToString(), agentName, enabled, cancellationToken.ToRequestOptions()); + } + + /// List all evaluation rules. + /// Filter by the type of evaluation rule. + /// Filter by the agent name. + /// Filter by the enabled status. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual AsyncCollectionResult GetAllAsync(EvaluationRuleActionType? actionType = default, string agentName = default, bool? enabled = default, CancellationToken cancellationToken = default) + { + return new EvaluationRulesGetAllAsyncCollectionResultOfT(this, actionType?.ToString(), agentName, enabled, cancellationToken.ToRequestOptions()); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRunClusterInsightResult.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRunClusterInsightResult.Serialization.cs new file mode 100644 index 000000000000..d8225bf3aed4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRunClusterInsightResult.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Insights from the evaluation run cluster analysis. + public partial class EvaluationRunClusterInsightResult : InsightResult, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal EvaluationRunClusterInsightResult() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationRunClusterInsightResult)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("clusterInsight"u8); + writer.WriteObjectValue(ClusterInsight, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + EvaluationRunClusterInsightResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (EvaluationRunClusterInsightResult)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InsightResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationRunClusterInsightResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEvaluationRunClusterInsightResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EvaluationRunClusterInsightResult DeserializeEvaluationRunClusterInsightResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InsightType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ClusterInsightResult clusterInsight = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InsightType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("clusterInsight"u8)) + { + clusterInsight = ClusterInsightResult.DeserializeClusterInsightResult(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new EvaluationRunClusterInsightResult(@type, additionalBinaryDataProperties, clusterInsight); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(EvaluationRunClusterInsightResult)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + EvaluationRunClusterInsightResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (EvaluationRunClusterInsightResult)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InsightResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEvaluationRunClusterInsightResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EvaluationRunClusterInsightResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRunClusterInsightResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRunClusterInsightResult.cs new file mode 100644 index 000000000000..1d7acc1367af --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRunClusterInsightResult.cs @@ -0,0 +1,32 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Insights from the evaluation run cluster analysis. + public partial class EvaluationRunClusterInsightResult : InsightResult + { + /// Initializes a new instance of . + /// + internal EvaluationRunClusterInsightResult(ClusterInsightResult clusterInsight) : base(InsightType.EvaluationRunClusterInsight) + { + ClusterInsight = clusterInsight; + } + + /// Initializes a new instance of . + /// The type of insights result. + /// Keeps track of any properties unknown to the library. + /// + internal EvaluationRunClusterInsightResult(InsightType @type, IDictionary additionalBinaryDataProperties, ClusterInsightResult clusterInsight) : base(@type, additionalBinaryDataProperties) + { + ClusterInsight = clusterInsight; + } + + /// Gets the ClusterInsight. + public ClusterInsightResult ClusterInsight { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRunClusterInsightsRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRunClusterInsightsRequest.Serialization.cs new file mode 100644 index 000000000000..950ab3b43e28 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRunClusterInsightsRequest.Serialization.cs @@ -0,0 +1,176 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Insights on set of Evaluation Results. + public partial class EvaluationRunClusterInsightsRequest : InsightRequest, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal EvaluationRunClusterInsightsRequest() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationRunClusterInsightsRequest)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("evalId"u8); + writer.WriteStringValue(EvalId); + writer.WritePropertyName("runIds"u8); + writer.WriteStartArray(); + foreach (string item in RunIds) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + if (Optional.IsDefined(ModelConfiguration)) + { + writer.WritePropertyName("modelConfiguration"u8); + writer.WriteObjectValue(ModelConfiguration, options); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + EvaluationRunClusterInsightsRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (EvaluationRunClusterInsightsRequest)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InsightRequest JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationRunClusterInsightsRequest)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEvaluationRunClusterInsightsRequest(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EvaluationRunClusterInsightsRequest DeserializeEvaluationRunClusterInsightsRequest(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InsightType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string evalId = default; + IList runIds = default; + InsightModelConfiguration modelConfiguration = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InsightType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("evalId"u8)) + { + evalId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("runIds"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + runIds = array; + continue; + } + if (prop.NameEquals("modelConfiguration"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + modelConfiguration = InsightModelConfiguration.DeserializeInsightModelConfiguration(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new EvaluationRunClusterInsightsRequest(@type, additionalBinaryDataProperties, evalId, runIds, modelConfiguration); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(EvaluationRunClusterInsightsRequest)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + EvaluationRunClusterInsightsRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (EvaluationRunClusterInsightsRequest)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InsightRequest PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEvaluationRunClusterInsightsRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EvaluationRunClusterInsightsRequest)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRunClusterInsightsRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRunClusterInsightsRequest.cs new file mode 100644 index 000000000000..a794eb221851 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationRunClusterInsightsRequest.cs @@ -0,0 +1,49 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects +{ + /// Insights on set of Evaluation Results. + public partial class EvaluationRunClusterInsightsRequest : InsightRequest + { + /// Initializes a new instance of . + /// Evaluation Id for the insights. + /// List of evaluation run IDs for the insights. + /// or is null. + public EvaluationRunClusterInsightsRequest(string evalId, IEnumerable runIds) : base(InsightType.EvaluationRunClusterInsight) + { + Argument.AssertNotNull(evalId, nameof(evalId)); + Argument.AssertNotNull(runIds, nameof(runIds)); + + EvalId = evalId; + RunIds = runIds.ToList(); + } + + /// Initializes a new instance of . + /// The type of request. + /// Keeps track of any properties unknown to the library. + /// Evaluation Id for the insights. + /// List of evaluation run IDs for the insights. + /// Configuration of the model used in the insight generation. + internal EvaluationRunClusterInsightsRequest(InsightType @type, IDictionary additionalBinaryDataProperties, string evalId, IList runIds, InsightModelConfiguration modelConfiguration) : base(@type, additionalBinaryDataProperties) + { + EvalId = evalId; + RunIds = runIds; + ModelConfiguration = modelConfiguration; + } + + /// Evaluation Id for the insights. + public string EvalId { get; set; } + + /// List of evaluation run IDs for the insights. + public IList RunIds { get; } + + /// Configuration of the model used in the insight generation. + public InsightModelConfiguration ModelConfiguration { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationScheduleTask.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationScheduleTask.Serialization.cs new file mode 100644 index 000000000000..74726fc927e6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationScheduleTask.Serialization.cs @@ -0,0 +1,161 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Evaluation task for the schedule. + public partial class EvaluationScheduleTask : ScheduleTask, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal EvaluationScheduleTask() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationScheduleTask)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("evalId"u8); + writer.WriteStringValue(EvalId); + writer.WritePropertyName("evalRun"u8); + writer.WriteObjectValue(EvalRun, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + EvaluationScheduleTask IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (EvaluationScheduleTask)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override ScheduleTask JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationScheduleTask)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEvaluationScheduleTask(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EvaluationScheduleTask DeserializeEvaluationScheduleTask(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ScheduleTaskType @type = default; + IDictionary configuration = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string evalId = default; + EvaluationScheduleTaskEvalRun evalRun = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ScheduleTaskType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("configuration"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + configuration = dictionary; + continue; + } + if (prop.NameEquals("evalId"u8)) + { + evalId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("evalRun"u8)) + { + evalRun = EvaluationScheduleTaskEvalRun.DeserializeEvaluationScheduleTaskEvalRun(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new EvaluationScheduleTask(@type, configuration ?? new ChangeTrackingDictionary(), additionalBinaryDataProperties, evalId, evalRun); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(EvaluationScheduleTask)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + EvaluationScheduleTask IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (EvaluationScheduleTask)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override ScheduleTask PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEvaluationScheduleTask(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EvaluationScheduleTask)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationScheduleTask.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationScheduleTask.cs new file mode 100644 index 000000000000..2811b0c2ea4f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationScheduleTask.cs @@ -0,0 +1,44 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Evaluation task for the schedule. + public partial class EvaluationScheduleTask : ScheduleTask + { + /// Initializes a new instance of . + /// Identifier of the evaluation group. + /// The evaluation run payload. + /// or is null. + public EvaluationScheduleTask(string evalId, EvaluationScheduleTaskEvalRun evalRun) : base(ScheduleTaskType.Evaluation) + { + Argument.AssertNotNull(evalId, nameof(evalId)); + Argument.AssertNotNull(evalRun, nameof(evalRun)); + + EvalId = evalId; + EvalRun = evalRun; + } + + /// Initializes a new instance of . + /// Type of the task. + /// Configuration for the task. + /// Keeps track of any properties unknown to the library. + /// Identifier of the evaluation group. + /// The evaluation run payload. + internal EvaluationScheduleTask(ScheduleTaskType @type, IDictionary configuration, IDictionary additionalBinaryDataProperties, string evalId, EvaluationScheduleTaskEvalRun evalRun) : base(@type, configuration, additionalBinaryDataProperties) + { + EvalId = evalId; + EvalRun = evalRun; + } + + /// Identifier of the evaluation group. + public string EvalId { get; set; } + + /// The evaluation run payload. + public EvaluationScheduleTaskEvalRun EvalRun { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationScheduleTaskEvalRun.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationScheduleTaskEvalRun.Serialization.cs new file mode 100644 index 000000000000..31089eaeac1e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationScheduleTaskEvalRun.Serialization.cs @@ -0,0 +1,126 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The EvaluationScheduleTaskEvalRun. + public partial class EvaluationScheduleTaskEvalRun : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationScheduleTaskEvalRun)} does not support writing '{format}' format."); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + EvaluationScheduleTaskEvalRun IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual EvaluationScheduleTaskEvalRun JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationScheduleTaskEvalRun)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEvaluationScheduleTaskEvalRun(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EvaluationScheduleTaskEvalRun DeserializeEvaluationScheduleTaskEvalRun(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new EvaluationScheduleTaskEvalRun(additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(EvaluationScheduleTaskEvalRun)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + EvaluationScheduleTaskEvalRun IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual EvaluationScheduleTaskEvalRun PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEvaluationScheduleTaskEvalRun(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EvaluationScheduleTaskEvalRun)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationScheduleTaskEvalRun.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationScheduleTaskEvalRun.cs new file mode 100644 index 000000000000..f675a3d650ab --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationScheduleTaskEvalRun.cs @@ -0,0 +1,28 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// The EvaluationScheduleTaskEvalRun. + public partial class EvaluationScheduleTaskEvalRun + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public EvaluationScheduleTaskEvalRun() + { + } + + /// Initializes a new instance of . + /// Keeps track of any properties unknown to the library. + internal EvaluationScheduleTaskEvalRun(IDictionary additionalBinaryDataProperties) + { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTaxonomies.RestClient.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTaxonomies.RestClient.cs new file mode 100644 index 000000000000..49fd19092d4c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTaxonomies.RestClient.cs @@ -0,0 +1,119 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace Azure.AI.Projects +{ + /// + public partial class EvaluationTaxonomies + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier200201; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier200201 => _pipelineMessageClassifier200201 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200, 201 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 = PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateGetRequest(string name, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/evaluationtaxonomies/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + request.Headers.Set("x-ms-client-request-id", request.ClientRequestId); + return message; + } + + internal PipelineMessage CreateGetAllRequest(string inputName, string inputType, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/evaluationtaxonomies", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (inputName != null) + { + uri.AppendQuery("inputName", inputName, true); + } + if (inputType != null) + { + uri.AppendQuery("inputType", inputType, true); + } + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + request.Headers.Set("x-ms-client-request-id", request.ClientRequestId); + return message; + } + + internal PipelineMessage CreateNextGetAllRequest(Uri nextPage, string inputName, string inputType, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(nextPage); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + request.Headers.Set("x-ms-client-request-id", request.ClientRequestId); + return message; + } + + internal PipelineMessage CreateDeleteRequest(string name, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/evaluationtaxonomies/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "DELETE", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + message.Apply(options); + request.Headers.Set("x-ms-client-request-id", request.ClientRequestId); + return message; + } + + internal PipelineMessage CreateCreateRequest(string name, BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/evaluationtaxonomies/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "PUT", PipelineMessageClassifier200201); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Headers.Set("Accept", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal PipelineMessage CreateUpdateRequest(string name, BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/evaluationtaxonomies/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "PATCH", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Headers.Set("Accept", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTaxonomies.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTaxonomies.cs new file mode 100644 index 000000000000..76b314ffe012 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTaxonomies.cs @@ -0,0 +1,364 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; + +namespace Azure.AI.Projects +{ + /// The EvaluationTaxonomies sub-client. + public partial class EvaluationTaxonomies + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of EvaluationTaxonomies for mocking. + protected EvaluationTaxonomies() + { + } + + /// Initializes a new instance of EvaluationTaxonomies. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal EvaluationTaxonomies(ClientPipeline pipeline, Uri endpoint, string apiVersion) + { + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } + + /// + /// [Protocol Method] Get an evaluation run by name. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the resource. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(string name, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using PipelineMessage message = CreateGetRequest(name, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Get an evaluation run by name. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the resource. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(string name, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using PipelineMessage message = CreateGetRequest(name, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Get an evaluation run by name. + /// The name of the resource. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult Get(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + ClientResult result = Get(name, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((EvaluationTaxonomy)result, result.GetRawResponse()); + } + + /// Get an evaluation run by name. + /// The name of the resource. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + ClientResult result = await GetAsync(name, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((EvaluationTaxonomy)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] List evaluation taxonomies + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Filter by the evaluation input name. + /// Filter by taxonomy input type. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual CollectionResult GetAll(string inputName, string inputType, RequestOptions options) + { + return new EvaluationTaxonomiesGetAllCollectionResult(this, inputName, inputType, options); + } + + /// + /// [Protocol Method] List evaluation taxonomies + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Filter by the evaluation input name. + /// Filter by taxonomy input type. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual AsyncCollectionResult GetAllAsync(string inputName, string inputType, RequestOptions options) + { + return new EvaluationTaxonomiesGetAllAsyncCollectionResult(this, inputName, inputType, options); + } + + /// List evaluation taxonomies. + /// Filter by the evaluation input name. + /// Filter by taxonomy input type. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual CollectionResult GetAll(string inputName = default, string inputType = default, CancellationToken cancellationToken = default) + { + return new EvaluationTaxonomiesGetAllCollectionResultOfT(this, inputName, inputType, cancellationToken.ToRequestOptions()); + } + + /// List evaluation taxonomies. + /// Filter by the evaluation input name. + /// Filter by taxonomy input type. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual AsyncCollectionResult GetAllAsync(string inputName = default, string inputType = default, CancellationToken cancellationToken = default) + { + return new EvaluationTaxonomiesGetAllAsyncCollectionResultOfT(this, inputName, inputType, cancellationToken.ToRequestOptions()); + } + + /// + /// [Protocol Method] Delete an evaluation taxonomy by name. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the resource. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Delete(string name, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using PipelineMessage message = CreateDeleteRequest(name, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Delete an evaluation taxonomy by name. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the resource. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task DeleteAsync(string name, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using PipelineMessage message = CreateDeleteRequest(name, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Delete an evaluation taxonomy by name. + /// The name of the resource. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult Delete(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + return Delete(name, cancellationToken.ToRequestOptions()); + } + + /// Delete an evaluation taxonomy by name. + /// The name of the resource. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task DeleteAsync(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + return await DeleteAsync(name, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + + /// + /// [Protocol Method] Create an evaluation taxonomy. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the evaluation taxonomy. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Create(string name, BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateCreateRequest(name, content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Create an evaluation taxonomy. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the evaluation taxonomy. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task CreateAsync(string name, BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateCreateRequest(name, content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Create an evaluation taxonomy. + /// The name of the evaluation taxonomy. + /// The evaluation taxonomy. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult Create(string name, EvaluationTaxonomy body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(body, nameof(body)); + + ClientResult result = Create(name, body, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((EvaluationTaxonomy)result, result.GetRawResponse()); + } + + /// Create an evaluation taxonomy. + /// The name of the evaluation taxonomy. + /// The evaluation taxonomy. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> CreateAsync(string name, EvaluationTaxonomy body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(body, nameof(body)); + + ClientResult result = await CreateAsync(name, body, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((EvaluationTaxonomy)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] Update an evaluation taxonomy. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the evaluation taxonomy. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Update(string name, BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateUpdateRequest(name, content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Update an evaluation taxonomy. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the evaluation taxonomy. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task UpdateAsync(string name, BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateUpdateRequest(name, content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTaxonomy.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTaxonomy.Serialization.cs new file mode 100644 index 000000000000..351d3459a19f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTaxonomy.Serialization.cs @@ -0,0 +1,312 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Evaluation Taxonomy Definition. + public partial class EvaluationTaxonomy : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal EvaluationTaxonomy() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationTaxonomy)} does not support writing '{format}' format."); + } + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("taxonomyInput"u8); + writer.WriteObjectValue(TaxonomyInput, options); + if (Optional.IsCollectionDefined(TaxonomyCategories)) + { + writer.WritePropertyName("taxonomyCategories"u8); + writer.WriteStartArray(); + foreach (TaxonomyCategory item in TaxonomyCategories) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + foreach (var item in Properties) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + EvaluationTaxonomy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual EvaluationTaxonomy JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationTaxonomy)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEvaluationTaxonomy(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EvaluationTaxonomy DeserializeEvaluationTaxonomy(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string name = default; + string version = default; + string description = default; + IDictionary tags = default; + EvaluationTaxonomyInput taxonomyInput = default; + IList taxonomyCategories = default; + IDictionary properties = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("version"u8)) + { + version = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("tags"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + tags = dictionary; + continue; + } + if (prop.NameEquals("taxonomyInput"u8)) + { + taxonomyInput = EvaluationTaxonomyInput.DeserializeEvaluationTaxonomyInput(prop.Value, options); + continue; + } + if (prop.NameEquals("taxonomyCategories"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(TaxonomyCategory.DeserializeTaxonomyCategory(item, options)); + } + taxonomyCategories = array; + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + properties = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new EvaluationTaxonomy( + id, + name, + version, + description, + tags ?? new ChangeTrackingDictionary(), + taxonomyInput, + taxonomyCategories ?? new ChangeTrackingList(), + properties ?? new ChangeTrackingDictionary(), + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(EvaluationTaxonomy)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + EvaluationTaxonomy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual EvaluationTaxonomy PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEvaluationTaxonomy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EvaluationTaxonomy)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(EvaluationTaxonomy evaluationTaxonomy) + { + if (evaluationTaxonomy == null) + { + return null; + } + return BinaryContent.Create(evaluationTaxonomy, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + public static explicit operator EvaluationTaxonomy(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEvaluationTaxonomy(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTaxonomy.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTaxonomy.cs new file mode 100644 index 000000000000..408812213454 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTaxonomy.cs @@ -0,0 +1,76 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Evaluation Taxonomy Definition. + public partial class EvaluationTaxonomy + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Input configuration for the evaluation taxonomy. + /// is null. + public EvaluationTaxonomy(EvaluationTaxonomyInput taxonomyInput) + { + Argument.AssertNotNull(taxonomyInput, nameof(taxonomyInput)); + + Tags = new ChangeTrackingDictionary(); + TaxonomyInput = taxonomyInput; + TaxonomyCategories = new ChangeTrackingList(); + Properties = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Asset ID, a unique identifier for the asset. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Input configuration for the evaluation taxonomy. + /// List of taxonomy categories. + /// Additional properties for the evaluation taxonomy. + /// Keeps track of any properties unknown to the library. + internal EvaluationTaxonomy(string id, string name, string version, string description, IDictionary tags, EvaluationTaxonomyInput taxonomyInput, IList taxonomyCategories, IDictionary properties, IDictionary additionalBinaryDataProperties) + { + Id = id; + Name = name; + Version = version; + Description = description; + Tags = tags; + TaxonomyInput = taxonomyInput; + TaxonomyCategories = taxonomyCategories; + Properties = properties; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Asset ID, a unique identifier for the asset. + public string Id { get; } + + /// The name of the resource. + public string Name { get; } + + /// The version of the resource. + public string Version { get; } + + /// The asset description text. + public string Description { get; set; } + + /// Tag dictionary. Tags can be added, removed, and updated. + public IDictionary Tags { get; } + + /// Input configuration for the evaluation taxonomy. + public EvaluationTaxonomyInput TaxonomyInput { get; set; } + + /// List of taxonomy categories. + public IList TaxonomyCategories { get; } + + /// Additional properties for the evaluation taxonomy. + public IDictionary Properties { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTaxonomyInput.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTaxonomyInput.Serialization.cs new file mode 100644 index 000000000000..a7a6c9ef26ea --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTaxonomyInput.Serialization.cs @@ -0,0 +1,136 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// + /// Input configuration for the evaluation taxonomy. + /// Please note this is the abstract base class. The derived classes available for instantiation are: . + /// + [PersistableModelProxy(typeof(UnknownEvaluationTaxonomyInput))] + public abstract partial class EvaluationTaxonomyInput : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal EvaluationTaxonomyInput() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationTaxonomyInput)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + EvaluationTaxonomyInput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual EvaluationTaxonomyInput JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationTaxonomyInput)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEvaluationTaxonomyInput(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EvaluationTaxonomyInput DeserializeEvaluationTaxonomyInput(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "agent": + return AgentTaxonomyInput.DeserializeAgentTaxonomyInput(element, options); + } + } + return UnknownEvaluationTaxonomyInput.DeserializeUnknownEvaluationTaxonomyInput(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(EvaluationTaxonomyInput)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + EvaluationTaxonomyInput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual EvaluationTaxonomyInput PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEvaluationTaxonomyInput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EvaluationTaxonomyInput)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTaxonomyInput.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTaxonomyInput.cs new file mode 100644 index 000000000000..f5bcc940900b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTaxonomyInput.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// + /// Input configuration for the evaluation taxonomy. + /// Please note this is the abstract base class. The derived classes available for instantiation are: . + /// + public abstract partial class EvaluationTaxonomyInput + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Input type of the evaluation taxonomy. + private protected EvaluationTaxonomyInput(EvaluationTaxonomyInputType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// Input type of the evaluation taxonomy. + /// Keeps track of any properties unknown to the library. + internal EvaluationTaxonomyInput(EvaluationTaxonomyInputType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Input type of the evaluation taxonomy. + internal EvaluationTaxonomyInputType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTaxonomyInputType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTaxonomyInputType.cs new file mode 100644 index 000000000000..2bfc900569b7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluationTaxonomyInputType.cs @@ -0,0 +1,67 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// Type of the evaluation taxonomy input. + internal readonly partial struct EvaluationTaxonomyInputType : IEquatable + { + private readonly string _value; + /// Agent. + private const string AgentValue = "agent"; + /// Policy. + private const string PolicyValue = "policy"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public EvaluationTaxonomyInputType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Agent. + public static EvaluationTaxonomyInputType Agent { get; } = new EvaluationTaxonomyInputType(AgentValue); + + /// Policy. + public static EvaluationTaxonomyInputType Policy { get; } = new EvaluationTaxonomyInputType(PolicyValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(EvaluationTaxonomyInputType left, EvaluationTaxonomyInputType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(EvaluationTaxonomyInputType left, EvaluationTaxonomyInputType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator EvaluationTaxonomyInputType(string value) => new EvaluationTaxonomyInputType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator EvaluationTaxonomyInputType?(string value) => value == null ? null : new EvaluationTaxonomyInputType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is EvaluationTaxonomyInputType other && Equals(other); + + /// + public bool Equals(EvaluationTaxonomyInputType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorCategory.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorCategory.cs new file mode 100644 index 000000000000..c0b7047b27bc --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorCategory.cs @@ -0,0 +1,72 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// The category of the evaluator. + public readonly partial struct EvaluatorCategory : IEquatable + { + private readonly string _value; + /// Quality. + private const string QualityValue = "quality"; + /// Risk & Safety. + private const string SafetyValue = "safety"; + /// Agents. + private const string AgentsValue = "agents"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public EvaluatorCategory(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Quality. + public static EvaluatorCategory Quality { get; } = new EvaluatorCategory(QualityValue); + + /// Risk & Safety. + public static EvaluatorCategory Safety { get; } = new EvaluatorCategory(SafetyValue); + + /// Agents. + public static EvaluatorCategory Agents { get; } = new EvaluatorCategory(AgentsValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(EvaluatorCategory left, EvaluatorCategory right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(EvaluatorCategory left, EvaluatorCategory right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator EvaluatorCategory(string value) => new EvaluatorCategory(value); + + /// Converts a string to a . + /// The value. + public static implicit operator EvaluatorCategory?(string value) => value == null ? null : new EvaluatorCategory(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is EvaluatorCategory other && Equals(other); + + /// + public bool Equals(EvaluatorCategory other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorDefinition.Serialization.cs new file mode 100644 index 000000000000..356e7574747f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorDefinition.Serialization.cs @@ -0,0 +1,173 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// + /// Base evaluator configuration with discriminator + /// Please note this is the abstract base class. The derived classes available for instantiation are: and . + /// + [PersistableModelProxy(typeof(UnknownEvaluatorDefinition))] + public abstract partial class EvaluatorDefinition : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal EvaluatorDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluatorDefinition)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (Optional.IsDefined(InitParameters)) + { + writer.WritePropertyName("init_parameters"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(InitParameters); +#else + using (JsonDocument document = JsonDocument.Parse(InitParameters)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (Optional.IsDefined(DataSchema)) + { + writer.WritePropertyName("data_schema"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(DataSchema); +#else + using (JsonDocument document = JsonDocument.Parse(DataSchema)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (Optional.IsCollectionDefined(Metrics)) + { + writer.WritePropertyName("metrics"u8); + writer.WriteStartObject(); + foreach (var item in Metrics) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + EvaluatorDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual EvaluatorDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluatorDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEvaluatorDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EvaluatorDefinition DeserializeEvaluatorDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "code": + return CodeBasedEvaluatorDefinition.DeserializeCodeBasedEvaluatorDefinition(element, options); + case "prompt": + return PromptBasedEvaluatorDefinition.DeserializePromptBasedEvaluatorDefinition(element, options); + } + } + return UnknownEvaluatorDefinition.DeserializeUnknownEvaluatorDefinition(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(EvaluatorDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + EvaluatorDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual EvaluatorDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEvaluatorDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EvaluatorDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorDefinition.cs new file mode 100644 index 000000000000..e63642ee5d9c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorDefinition.cs @@ -0,0 +1,105 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// + /// Base evaluator configuration with discriminator + /// Please note this is the abstract base class. The derived classes available for instantiation are: and . + /// + public abstract partial class EvaluatorDefinition + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The type of evaluator definition. + private protected EvaluatorDefinition(EvaluatorDefinitionType @type) + { + Type = @type; + Metrics = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The type of evaluator definition. + /// The JSON schema (Draft 2020-12) for the evaluator's input parameters. This includes parameters like type, properties, required. + /// The JSON schema (Draft 2020-12) for the evaluator's input data. This includes parameters like type, properties, required. + /// List of output metrics produced by this evaluator. + /// Keeps track of any properties unknown to the library. + internal EvaluatorDefinition(EvaluatorDefinitionType @type, BinaryData initParameters, BinaryData dataSchema, IDictionary metrics, IDictionary additionalBinaryDataProperties) + { + Type = @type; + InitParameters = initParameters; + DataSchema = dataSchema; + Metrics = metrics; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The type of evaluator definition. + internal EvaluatorDefinitionType Type { get; set; } + + /// + /// The JSON schema (Draft 2020-12) for the evaluator's input parameters. This includes parameters like type, properties, required. + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData InitParameters { get; set; } + + /// + /// The JSON schema (Draft 2020-12) for the evaluator's input data. This includes parameters like type, properties, required. + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData DataSchema { get; set; } + + /// List of output metrics produced by this evaluator. + public IDictionary Metrics { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorDefinitionType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorDefinitionType.cs new file mode 100644 index 000000000000..852ad34b748c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorDefinitionType.cs @@ -0,0 +1,82 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// The type of evaluator definition. + internal readonly partial struct EvaluatorDefinitionType : IEquatable + { + private readonly string _value; + /// Prompt-based definition. + private const string PromptValue = "prompt"; + /// Code-based definition. + private const string CodeValue = "code"; + /// Prompt & Code Based definition. + private const string PromptAndCodeValue = "prompt_and_code"; + /// Service-based evaluator. + private const string ServiceValue = "service"; + /// OpenAI graders. + private const string OpenaiGradersValue = "openai_graders"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public EvaluatorDefinitionType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Prompt-based definition. + public static EvaluatorDefinitionType Prompt { get; } = new EvaluatorDefinitionType(PromptValue); + + /// Code-based definition. + public static EvaluatorDefinitionType Code { get; } = new EvaluatorDefinitionType(CodeValue); + + /// Prompt & Code Based definition. + public static EvaluatorDefinitionType PromptAndCode { get; } = new EvaluatorDefinitionType(PromptAndCodeValue); + + /// Service-based evaluator. + public static EvaluatorDefinitionType Service { get; } = new EvaluatorDefinitionType(ServiceValue); + + /// OpenAI graders. + public static EvaluatorDefinitionType OpenaiGraders { get; } = new EvaluatorDefinitionType(OpenaiGradersValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(EvaluatorDefinitionType left, EvaluatorDefinitionType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(EvaluatorDefinitionType left, EvaluatorDefinitionType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator EvaluatorDefinitionType(string value) => new EvaluatorDefinitionType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator EvaluatorDefinitionType?(string value) => value == null ? null : new EvaluatorDefinitionType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is EvaluatorDefinitionType other && Equals(other); + + /// + public bool Equals(EvaluatorDefinitionType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorMetric.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorMetric.Serialization.cs new file mode 100644 index 000000000000..075bfd8df9a6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorMetric.Serialization.cs @@ -0,0 +1,207 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Evaluator Metric. + public partial class EvaluatorMetric : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluatorMetric)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.Value.ToString()); + } + if (Optional.IsDefined(DesirableDirection)) + { + writer.WritePropertyName("desirable_direction"u8); + writer.WriteStringValue(DesirableDirection.Value.ToString()); + } + if (Optional.IsDefined(MinValue)) + { + writer.WritePropertyName("min_value"u8); + writer.WriteNumberValue(MinValue.Value); + } + if (Optional.IsDefined(MaxValue)) + { + writer.WritePropertyName("max_value"u8); + writer.WriteNumberValue(MaxValue.Value); + } + if (Optional.IsDefined(IsPrimary)) + { + writer.WritePropertyName("is_primary"u8); + writer.WriteBooleanValue(IsPrimary.Value); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + EvaluatorMetric IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual EvaluatorMetric JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluatorMetric)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEvaluatorMetric(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EvaluatorMetric DeserializeEvaluatorMetric(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + EvaluatorMetricType? @type = default; + EvaluatorMetricDirection? desirableDirection = default; + float? minValue = default; + float? maxValue = default; + bool? isPrimary = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + @type = new EvaluatorMetricType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("desirable_direction"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + desirableDirection = new EvaluatorMetricDirection(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("min_value"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + minValue = prop.Value.GetSingle(); + continue; + } + if (prop.NameEquals("max_value"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxValue = prop.Value.GetSingle(); + continue; + } + if (prop.NameEquals("is_primary"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isPrimary = prop.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new EvaluatorMetric( + @type, + desirableDirection, + minValue, + maxValue, + isPrimary, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(EvaluatorMetric)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + EvaluatorMetric IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual EvaluatorMetric PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEvaluatorMetric(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EvaluatorMetric)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorMetric.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorMetric.cs new file mode 100644 index 000000000000..383dcd26f232 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorMetric.cs @@ -0,0 +1,53 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Evaluator Metric. + public partial class EvaluatorMetric + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public EvaluatorMetric() + { + } + + /// Initializes a new instance of . + /// Type of the metric. + /// It indicates whether a higher value is better or a lower value is better for this metric. + /// Minimum value for the metric. + /// Maximum value for the metric. If not specified, it is assumed to be unbounded. + /// Indicates if this metric is primary when there are multiple metrics. + /// Keeps track of any properties unknown to the library. + internal EvaluatorMetric(EvaluatorMetricType? @type, EvaluatorMetricDirection? desirableDirection, float? minValue, float? maxValue, bool? isPrimary, IDictionary additionalBinaryDataProperties) + { + Type = @type; + DesirableDirection = desirableDirection; + MinValue = minValue; + MaxValue = maxValue; + IsPrimary = isPrimary; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Type of the metric. + public EvaluatorMetricType? Type { get; set; } + + /// It indicates whether a higher value is better or a lower value is better for this metric. + public EvaluatorMetricDirection? DesirableDirection { get; set; } + + /// Minimum value for the metric. + public float? MinValue { get; set; } + + /// Maximum value for the metric. If not specified, it is assumed to be unbounded. + public float? MaxValue { get; set; } + + /// Indicates if this metric is primary when there are multiple metrics. + public bool? IsPrimary { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorMetricDirection.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorMetricDirection.cs new file mode 100644 index 000000000000..48feeaea5cb5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorMetricDirection.cs @@ -0,0 +1,72 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// The direction of the metric indicating whether a higher value is better, a lower value is better, or neutral. + public readonly partial struct EvaluatorMetricDirection : IEquatable + { + private readonly string _value; + /// It indicates a higher value is better for this metric. + private const string IncreaseValue = "increase"; + /// It indicates a lower value is better for this metric. + private const string DecreaseValue = "decrease"; + /// It indicates no preference for this metric direction. + private const string NeutralValue = "neutral"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public EvaluatorMetricDirection(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// It indicates a higher value is better for this metric. + public static EvaluatorMetricDirection Increase { get; } = new EvaluatorMetricDirection(IncreaseValue); + + /// It indicates a lower value is better for this metric. + public static EvaluatorMetricDirection Decrease { get; } = new EvaluatorMetricDirection(DecreaseValue); + + /// It indicates no preference for this metric direction. + public static EvaluatorMetricDirection Neutral { get; } = new EvaluatorMetricDirection(NeutralValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(EvaluatorMetricDirection left, EvaluatorMetricDirection right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(EvaluatorMetricDirection left, EvaluatorMetricDirection right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator EvaluatorMetricDirection(string value) => new EvaluatorMetricDirection(value); + + /// Converts a string to a . + /// The value. + public static implicit operator EvaluatorMetricDirection?(string value) => value == null ? null : new EvaluatorMetricDirection(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is EvaluatorMetricDirection other && Equals(other); + + /// + public bool Equals(EvaluatorMetricDirection other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorMetricType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorMetricType.cs new file mode 100644 index 000000000000..1cc4a107dee4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorMetricType.cs @@ -0,0 +1,72 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// The type of the evaluator. + public readonly partial struct EvaluatorMetricType : IEquatable + { + private readonly string _value; + /// Ordinal metric representing categories that can be ordered or ranked. + private const string OrdinalValue = "ordinal"; + /// Continuous metric representing values in a continuous range. + private const string ContinuousValue = "continuous"; + /// Boolean metric representing true/false values. + private const string BooleanValue = "boolean"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public EvaluatorMetricType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Ordinal metric representing categories that can be ordered or ranked. + public static EvaluatorMetricType Ordinal { get; } = new EvaluatorMetricType(OrdinalValue); + + /// Continuous metric representing values in a continuous range. + public static EvaluatorMetricType Continuous { get; } = new EvaluatorMetricType(ContinuousValue); + + /// Boolean metric representing true/false values. + public static EvaluatorMetricType Boolean { get; } = new EvaluatorMetricType(BooleanValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(EvaluatorMetricType left, EvaluatorMetricType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(EvaluatorMetricType left, EvaluatorMetricType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator EvaluatorMetricType(string value) => new EvaluatorMetricType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator EvaluatorMetricType?(string value) => value == null ? null : new EvaluatorMetricType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is EvaluatorMetricType other && Equals(other); + + /// + public bool Equals(EvaluatorMetricType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorType.cs new file mode 100644 index 000000000000..6760d0899847 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorType.cs @@ -0,0 +1,67 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// The type of the evaluator. + public readonly partial struct EvaluatorType : IEquatable + { + private readonly string _value; + /// Built-in evaluator (Microsoft provided). + private const string BuiltInValue = "builtin"; + /// Custom evaluator. + private const string CustomValue = "custom"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public EvaluatorType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Built-in evaluator (Microsoft provided). + public static EvaluatorType BuiltIn { get; } = new EvaluatorType(BuiltInValue); + + /// Custom evaluator. + public static EvaluatorType Custom { get; } = new EvaluatorType(CustomValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(EvaluatorType left, EvaluatorType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(EvaluatorType left, EvaluatorType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator EvaluatorType(string value) => new EvaluatorType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator EvaluatorType?(string value) => value == null ? null : new EvaluatorType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is EvaluatorType other && Equals(other); + + /// + public bool Equals(EvaluatorType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorVersion.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorVersion.Serialization.cs new file mode 100644 index 000000000000..7e2e596e74c0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorVersion.Serialization.cs @@ -0,0 +1,362 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Evaluator Definition. + public partial class EvaluatorVersion : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal EvaluatorVersion() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluatorVersion)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("display_name"u8); + writer.WriteStringValue(DisplayName); + } + if (Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("evaluator_type"u8); + writer.WriteStringValue(EvaluatorType.ToString()); + writer.WritePropertyName("categories"u8); + writer.WriteStartArray(); + foreach (EvaluatorCategory item in Categories) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + writer.WritePropertyName("definition"u8); + writer.WriteObjectValue(Definition, options); + if (options.Format != "W") + { + writer.WritePropertyName("created_by"u8); + writer.WriteStringValue(CreatedBy); + } + if (options.Format != "W") + { + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt); + } + if (options.Format != "W") + { + writer.WritePropertyName("modified_at"u8); + writer.WriteNumberValue(ModifiedAt); + } + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + EvaluatorVersion IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual EvaluatorVersion JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluatorVersion)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEvaluatorVersion(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static EvaluatorVersion DeserializeEvaluatorVersion(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string displayName = default; + IDictionary metadata = default; + EvaluatorType evaluatorType = default; + IList categories = default; + EvaluatorDefinition definition = default; + string createdBy = default; + long createdAt = default; + long modifiedAt = default; + string id = default; + string name = default; + string version = default; + string description = default; + IDictionary tags = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("display_name"u8)) + { + displayName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("metadata"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + metadata = dictionary; + continue; + } + if (prop.NameEquals("evaluator_type"u8)) + { + evaluatorType = new EvaluatorType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("categories"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(new EvaluatorCategory(item.GetString())); + } + categories = array; + continue; + } + if (prop.NameEquals("definition"u8)) + { + definition = EvaluatorDefinition.DeserializeEvaluatorDefinition(prop.Value, options); + continue; + } + if (prop.NameEquals("created_by"u8)) + { + createdBy = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_at"u8)) + { + createdAt = prop.Value.GetInt64(); + continue; + } + if (prop.NameEquals("modified_at"u8)) + { + modifiedAt = prop.Value.GetInt64(); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("version"u8)) + { + version = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("tags"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + tags = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new EvaluatorVersion( + displayName, + metadata ?? new ChangeTrackingDictionary(), + evaluatorType, + categories, + definition, + createdBy, + createdAt, + modifiedAt, + id, + name, + version, + description, + tags ?? new ChangeTrackingDictionary(), + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(EvaluatorVersion)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + EvaluatorVersion IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual EvaluatorVersion PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEvaluatorVersion(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EvaluatorVersion)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(EvaluatorVersion evaluatorVersion) + { + if (evaluatorVersion == null) + { + return null; + } + return BinaryContent.Create(evaluatorVersion, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + public static explicit operator EvaluatorVersion(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeEvaluatorVersion(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorVersion.cs b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorVersion.cs new file mode 100644 index 000000000000..d95e0964f13d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/EvaluatorVersion.cs @@ -0,0 +1,106 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects +{ + /// Evaluator Definition. + public partial class EvaluatorVersion + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The type of the evaluator. + /// The categories of the evaluator. + /// Definition of the evaluator. + /// or is null. + public EvaluatorVersion(EvaluatorType evaluatorType, IEnumerable categories, EvaluatorDefinition definition) + { + Argument.AssertNotNull(categories, nameof(categories)); + Argument.AssertNotNull(definition, nameof(definition)); + + Metadata = new ChangeTrackingDictionary(); + EvaluatorType = evaluatorType; + Categories = categories.ToList(); + Definition = definition; + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Display Name for evaluator. It helps to find the evaluator easily in AI Foundry. It does not need to be unique. + /// Metadata about the evaluator. + /// The type of the evaluator. + /// The categories of the evaluator. + /// Definition of the evaluator. + /// Creator of the evaluator. + /// Creation date/time of the evaluator. + /// Last modified date/time of the evaluator. + /// Asset ID, a unique identifier for the asset. + /// The name of the resource. + /// The version of the resource. + /// The asset description text. + /// Tag dictionary. Tags can be added, removed, and updated. + /// Keeps track of any properties unknown to the library. + internal EvaluatorVersion(string displayName, IDictionary metadata, EvaluatorType evaluatorType, IList categories, EvaluatorDefinition definition, string createdBy, long createdAt, long modifiedAt, string id, string name, string version, string description, IDictionary tags, IDictionary additionalBinaryDataProperties) + { + DisplayName = displayName; + Metadata = metadata; + EvaluatorType = evaluatorType; + Categories = categories; + Definition = definition; + CreatedBy = createdBy; + CreatedAt = createdAt; + ModifiedAt = modifiedAt; + Id = id; + Name = name; + Version = version; + Description = description; + Tags = tags; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Display Name for evaluator. It helps to find the evaluator easily in AI Foundry. It does not need to be unique. + public string DisplayName { get; set; } + + /// Metadata about the evaluator. + public IDictionary Metadata { get; } + + /// The type of the evaluator. + public EvaluatorType EvaluatorType { get; set; } + + /// The categories of the evaluator. + public IList Categories { get; } + + /// Definition of the evaluator. + public EvaluatorDefinition Definition { get; set; } + + /// Creator of the evaluator. + public string CreatedBy { get; } + + /// Creation date/time of the evaluator. + public long CreatedAt { get; } + + /// Last modified date/time of the evaluator. + public long ModifiedAt { get; } + + /// Asset ID, a unique identifier for the asset. + public string Id { get; } + + /// The name of the resource. + public string Name { get; } + + /// The version of the resource. + public string Version { get; } + + /// The asset description text. + public string Description { get; set; } + + /// Tag dictionary. Tags can be added, removed, and updated. + public IDictionary Tags { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Evaluators.RestClient.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Evaluators.RestClient.cs new file mode 100644 index 000000000000..f13592d3bd85 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Evaluators.RestClient.cs @@ -0,0 +1,156 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace Azure.AI.Projects +{ + /// + public partial class Evaluators + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier201; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier201 => _pipelineMessageClassifier201 = PipelineMessageClassifier.Create(stackalloc ushort[] { 201 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 = PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateGetVersionsRequest(string name, string @type, int? limit, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/evaluators/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (@type != null) + { + uri.AppendQuery("type", @type, true); + } + if (limit != null) + { + uri.AppendQuery("limit", TypeFormatters.ConvertToString(limit), true); + } + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateNextGetVersionsRequest(Uri nextPage, string name, string @type, int? limit, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(nextPage); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateGetLatestVersionsRequest(string @type, int? limit, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/evaluators", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (@type != null) + { + uri.AppendQuery("type", @type, true); + } + if (limit != null) + { + uri.AppendQuery("limit", TypeFormatters.ConvertToString(limit), true); + } + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateNextGetLatestVersionsRequest(Uri nextPage, string @type, int? limit, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(nextPage); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateGetVersionRequest(string name, string version, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/evaluators/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions/", false); + uri.AppendPath(version, true); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateDeleteVersionRequest(string name, string version, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/evaluators/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions/", false); + uri.AppendPath(version, true); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "DELETE", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + message.Apply(options); + return message; + } + + internal PipelineMessage CreateCreateVersionRequest(string name, BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/evaluators/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions", false); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier201); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Headers.Set("Accept", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal PipelineMessage CreateUpdateVersionRequest(string name, string version, BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/evaluators/", false); + uri.AppendPath(name, true); + uri.AppendPath("/versions/", false); + uri.AppendPath(version, true); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "PATCH", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Headers.Set("Accept", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Evaluators.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Evaluators.cs new file mode 100644 index 000000000000..fc4b0df2fdfa --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Evaluators.cs @@ -0,0 +1,460 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; + +namespace Azure.AI.Projects +{ + /// The Evaluators sub-client. + public partial class Evaluators + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of Evaluators for mocking. + protected Evaluators() + { + } + + /// Initializes a new instance of Evaluators. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal Evaluators(ClientPipeline pipeline, Uri endpoint, string apiVersion) + { + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } + + /// + /// [Protocol Method] List all versions of the given evaluator + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the resource. + /// Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual CollectionResult GetVersions(string name, string @type, int? limit, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + return new EvaluatorsGetVersionsCollectionResult(this, name, @type, limit, options); + } + + /// + /// [Protocol Method] List all versions of the given evaluator + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the resource. + /// Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual AsyncCollectionResult GetVersionsAsync(string name, string @type, int? limit, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + return new EvaluatorsGetVersionsAsyncCollectionResult(this, name, @type, limit, options); + } + + /// List all versions of the given evaluator. + /// The name of the resource. + /// Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual CollectionResult GetVersions(string name, ListVersionsRequestType? @type = default, int? limit = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + return new EvaluatorsGetVersionsCollectionResultOfT(this, name, @type?.ToString(), limit, cancellationToken.ToRequestOptions()); + } + + /// List all versions of the given evaluator. + /// The name of the resource. + /// Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual AsyncCollectionResult GetVersionsAsync(string name, ListVersionsRequestType? @type = default, int? limit = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + return new EvaluatorsGetVersionsAsyncCollectionResultOfT(this, name, @type?.ToString(), limit, cancellationToken.ToRequestOptions()); + } + + /// + /// [Protocol Method] List the latest version of each evaluator + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual CollectionResult GetLatestVersions(string @type, int? limit, RequestOptions options) + { + return new EvaluatorsGetLatestVersionsCollectionResult(this, @type, limit, options); + } + + /// + /// [Protocol Method] List the latest version of each evaluator + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual AsyncCollectionResult GetLatestVersionsAsync(string @type, int? limit, RequestOptions options) + { + return new EvaluatorsGetLatestVersionsAsyncCollectionResult(this, @type, limit, options); + } + + /// List the latest version of each evaluator. + /// Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual CollectionResult GetLatestVersions(ListVersionsRequestType? @type = default, int? limit = default, CancellationToken cancellationToken = default) + { + return new EvaluatorsGetLatestVersionsCollectionResultOfT(this, @type?.ToString(), limit, cancellationToken.ToRequestOptions()); + } + + /// List the latest version of each evaluator. + /// Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual AsyncCollectionResult GetLatestVersionsAsync(ListVersionsRequestType? @type = default, int? limit = default, CancellationToken cancellationToken = default) + { + return new EvaluatorsGetLatestVersionsAsyncCollectionResultOfT(this, @type?.ToString(), limit, cancellationToken.ToRequestOptions()); + } + + /// + /// [Protocol Method] Get the specific version of the EvaluatorVersion. The service returns 404 Not Found error if the EvaluatorVersion does not exist. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the resource. + /// The specific version id of the EvaluatorVersion to retrieve. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult GetVersion(string name, string version, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + using PipelineMessage message = CreateGetVersionRequest(name, version, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Get the specific version of the EvaluatorVersion. The service returns 404 Not Found error if the EvaluatorVersion does not exist. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the resource. + /// The specific version id of the EvaluatorVersion to retrieve. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetVersionAsync(string name, string version, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + using PipelineMessage message = CreateGetVersionRequest(name, version, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Get the specific version of the EvaluatorVersion. The service returns 404 Not Found error if the EvaluatorVersion does not exist. + /// The name of the resource. + /// The specific version id of the EvaluatorVersion to retrieve. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult GetVersion(string name, string version, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + ClientResult result = GetVersion(name, version, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((EvaluatorVersion)result, result.GetRawResponse()); + } + + /// Get the specific version of the EvaluatorVersion. The service returns 404 Not Found error if the EvaluatorVersion does not exist. + /// The name of the resource. + /// The specific version id of the EvaluatorVersion to retrieve. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> GetVersionAsync(string name, string version, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + ClientResult result = await GetVersionAsync(name, version, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((EvaluatorVersion)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] Delete the specific version of the EvaluatorVersion. The service returns 204 No Content if the EvaluatorVersion was deleted successfully or if the EvaluatorVersion does not exist. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the resource. + /// The version of the EvaluatorVersion to delete. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult DeleteVersion(string name, string version, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + using PipelineMessage message = CreateDeleteVersionRequest(name, version, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Delete the specific version of the EvaluatorVersion. The service returns 204 No Content if the EvaluatorVersion was deleted successfully or if the EvaluatorVersion does not exist. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the resource. + /// The version of the EvaluatorVersion to delete. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task DeleteVersionAsync(string name, string version, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + using PipelineMessage message = CreateDeleteVersionRequest(name, version, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Delete the specific version of the EvaluatorVersion. The service returns 204 No Content if the EvaluatorVersion was deleted successfully or if the EvaluatorVersion does not exist. + /// The name of the resource. + /// The version of the EvaluatorVersion to delete. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult DeleteVersion(string name, string version, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + return DeleteVersion(name, version, cancellationToken.ToRequestOptions()); + } + + /// Delete the specific version of the EvaluatorVersion. The service returns 204 No Content if the EvaluatorVersion was deleted successfully or if the EvaluatorVersion does not exist. + /// The name of the resource. + /// The version of the EvaluatorVersion to delete. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task DeleteVersionAsync(string name, string version, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + + return await DeleteVersionAsync(name, version, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + + /// + /// [Protocol Method] Create a new EvaluatorVersion with auto incremented version id + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the resource. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult CreateVersion(string name, BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateCreateVersionRequest(name, content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Create a new EvaluatorVersion with auto incremented version id + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the resource. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task CreateVersionAsync(string name, BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateCreateVersionRequest(name, content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Create a new EvaluatorVersion with auto incremented version id. + /// The name of the resource. + /// Evaluator resource. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult CreateVersion(string name, EvaluatorVersion evaluatorVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(evaluatorVersion, nameof(evaluatorVersion)); + + ClientResult result = CreateVersion(name, evaluatorVersion, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((EvaluatorVersion)result, result.GetRawResponse()); + } + + /// Create a new EvaluatorVersion with auto incremented version id. + /// The name of the resource. + /// Evaluator resource. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> CreateVersionAsync(string name, EvaluatorVersion evaluatorVersion, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(evaluatorVersion, nameof(evaluatorVersion)); + + ClientResult result = await CreateVersionAsync(name, evaluatorVersion, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((EvaluatorVersion)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] Update an existing EvaluatorVersion with the given version id + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the resource. + /// The version of the EvaluatorVersion to update. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult UpdateVersion(string name, string version, BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateUpdateVersionRequest(name, version, content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Update an existing EvaluatorVersion with the given version id + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The name of the resource. + /// The version of the EvaluatorVersion to update. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task UpdateVersionAsync(string name, string version, BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNullOrEmpty(version, nameof(version)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateUpdateVersionRequest(name, version, content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/FabricDataAgentToolParameters.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FabricDataAgentToolParameters.Serialization.cs new file mode 100644 index 000000000000..6fb411e28aae --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/FabricDataAgentToolParameters.Serialization.cs @@ -0,0 +1,151 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The fabric data agent tool parameters. + internal partial class FabricDataAgentToolParameters : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FabricDataAgentToolParameters)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(ProjectConnections)) + { + writer.WritePropertyName("project_connections"u8); + writer.WriteStartArray(); + foreach (ToolProjectConnection item in ProjectConnections) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + FabricDataAgentToolParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual FabricDataAgentToolParameters JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FabricDataAgentToolParameters)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFabricDataAgentToolParameters(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static FabricDataAgentToolParameters DeserializeFabricDataAgentToolParameters(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList projectConnections = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("project_connections"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ToolProjectConnection.DeserializeToolProjectConnection(item, options)); + } + projectConnections = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new FabricDataAgentToolParameters(projectConnections ?? new ChangeTrackingList(), additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(FabricDataAgentToolParameters)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + FabricDataAgentToolParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual FabricDataAgentToolParameters PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeFabricDataAgentToolParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FabricDataAgentToolParameters)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/FabricDataAgentToolParameters.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FabricDataAgentToolParameters.cs new file mode 100644 index 000000000000..ed358f978621 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/FabricDataAgentToolParameters.cs @@ -0,0 +1,40 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// The fabric data agent tool parameters. + internal partial class FabricDataAgentToolParameters + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public FabricDataAgentToolParameters() + { + ProjectConnections = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// The project connections attached to this tool. There can be a maximum of 1 connection + /// resource attached to the tool. + /// + /// Keeps track of any properties unknown to the library. + internal FabricDataAgentToolParameters(IList projectConnections, IDictionary additionalBinaryDataProperties) + { + ProjectConnections = projectConnections; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// The project connections attached to this tool. There can be a maximum of 1 connection + /// resource attached to the tool. + /// + public IList ProjectConnections { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/FileDataset.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FileDataset.cs index c7ffd743d62d..fc02e2b27ad6 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/FileDataset.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/FileDataset.cs @@ -11,7 +11,7 @@ namespace Azure.AI.Projects public partial class FileDataset : AIProjectDataset { /// Initializes a new instance of . - /// URI of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// URI of the data ([example](https://go.microsoft.com/fwlink/?linkid=2202330)). /// is null. public FileDataset(Uri dataUri) : base(dataUri, DatasetType.UriFile) { @@ -20,7 +20,7 @@ public FileDataset(Uri dataUri) : base(dataUri, DatasetType.UriFile) } /// Initializes a new instance of . - /// URI of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// URI of the data ([example](https://go.microsoft.com/fwlink/?linkid=2202330)). /// Dataset type. /// Indicates if the dataset holds a reference to the storage, or the dataset manages storage itself. If true, the underlying data will not be deleted when the dataset version is deleted. /// The Azure Storage Account connection name. Required if startPendingUploadVersion was not called before creating the Dataset. diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/FolderDataset.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FolderDataset.cs index 87a1c2ecba2f..596afc36ae7a 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/FolderDataset.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/FolderDataset.cs @@ -11,7 +11,7 @@ namespace Azure.AI.Projects public partial class FolderDataset : AIProjectDataset { /// Initializes a new instance of . - /// URI of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// URI of the data ([example](https://go.microsoft.com/fwlink/?linkid=2202330)). /// is null. public FolderDataset(Uri dataUri) : base(dataUri, DatasetType.UriFolder) { @@ -20,7 +20,7 @@ public FolderDataset(Uri dataUri) : base(dataUri, DatasetType.UriFolder) } /// Initializes a new instance of . - /// URI of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// URI of the data ([example](https://go.microsoft.com/fwlink/?linkid=2202330)). /// Dataset type. /// Indicates if the dataset holds a reference to the storage, or the dataset manages storage itself. If true, the underlying data will not be deleted when the dataset version is deleted. /// The Azure Storage Account connection name. Required if startPendingUploadVersion was not called before creating the Dataset. diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/FoundryOpenAIError.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FoundryOpenAIError.Serialization.cs new file mode 100644 index 000000000000..7feca1cc51fe --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/FoundryOpenAIError.Serialization.cs @@ -0,0 +1,309 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + internal partial class FoundryOpenAIError : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal FoundryOpenAIError() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + this.JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FoundryOpenAIError)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Code)) + { + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code); + } + else + { + writer.WriteNull("code"u8); + } + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + if (Optional.IsDefined(Param)) + { + writer.WritePropertyName("param"u8); + writer.WriteStringValue(Param); + } + else + { + writer.WriteNull("param"u8); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (Optional.IsCollectionDefined(Details)) + { + writer.WritePropertyName("details"u8); + writer.WriteStartArray(); + foreach (FoundryOpenAIError item in Details) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(AdditionalInfo)) + { + writer.WritePropertyName("additionalInfo"u8); + writer.WriteStartObject(); + foreach (var item in AdditionalInfo) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#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(); + } + if (Optional.IsCollectionDefined(DebugInfo)) + { + writer.WritePropertyName("debugInfo"u8); + writer.WriteStartObject(); + foreach (var item in DebugInfo) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#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(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + FoundryOpenAIError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => this.JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual FoundryOpenAIError JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FoundryOpenAIError)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return FoundryOpenAIError.DeserializeFoundryOpenAIError(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static FoundryOpenAIError DeserializeFoundryOpenAIError(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string code = default; + string message = default; + string @param = default; + string @type = default; + IList details = default; + IDictionary additionalInfo = default; + IDictionary debugInfo = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("code"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + code = null; + continue; + } + code = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("message"u8)) + { + message = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("param"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + @param = null; + continue; + } + @param = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("details"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(FoundryOpenAIError.DeserializeFoundryOpenAIError(item, options)); + } + details = array; + continue; + } + if (prop.NameEquals("additionalInfo"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + additionalInfo = dictionary; + continue; + } + if (prop.NameEquals("debugInfo"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + debugInfo = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new FoundryOpenAIError( + code, + message, + @param, + @type, + details ?? new ChangeTrackingList(), + additionalInfo ?? new ChangeTrackingDictionary(), + debugInfo ?? new ChangeTrackingDictionary(), + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => this.PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(FoundryOpenAIError)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + FoundryOpenAIError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => this.PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual FoundryOpenAIError PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return FoundryOpenAIError.DeserializeFoundryOpenAIError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FoundryOpenAIError)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/FoundryOpenAIError.cs b/sdk/ai/Azure.AI.Projects/src/Generated/FoundryOpenAIError.cs new file mode 100644 index 000000000000..f9609be70df4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/FoundryOpenAIError.cs @@ -0,0 +1,124 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + internal partial class FoundryOpenAIError + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// + /// + /// + internal FoundryOpenAIError(string code, string message, string @param, string @type) + { + Code = code; + Message = message; + Param = @param; + Type = @type; + Details = new ChangeTrackingList(); + AdditionalInfo = new ChangeTrackingDictionary(); + DebugInfo = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// + /// + /// + /// + /// + /// + /// + /// Keeps track of any properties unknown to the library. + internal FoundryOpenAIError(string code, string message, string @param, string @type, IList details, IDictionary additionalInfo, IDictionary debugInfo, IDictionary additionalBinaryDataProperties) + { + Code = code; + Message = message; + Param = @param; + Type = @type; + Details = details; + AdditionalInfo = additionalInfo; + DebugInfo = debugInfo; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Code. + public string Code { get; } + + /// Gets the Message. + public string Message { get; } + + /// Gets the Param. + public string Param { get; } + + /// Gets the Type. + public string Type { get; } + + /// Gets the Details. + public IList Details { get; } + + /// + /// Gets the AdditionalInfo. + /// 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" }. + /// + /// + /// + /// + public IDictionary AdditionalInfo { get; } + + /// + /// Gets the DebugInfo. + /// 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" }. + /// + /// + /// + /// + public IDictionary DebugInfo { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/HostedAgentDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/HostedAgentDefinition.Serialization.cs new file mode 100644 index 000000000000..f4d5975b1a85 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/HostedAgentDefinition.Serialization.cs @@ -0,0 +1,145 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The hosted agent definition. + internal partial class HostedAgentDefinition : InternalAgentDefinition, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal HostedAgentDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(HostedAgentDefinition)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsCollectionDefined(Tools)) + { + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (InternalTool item in Tools) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + writer.WritePropertyName("container_protocol_versions"u8); + writer.WriteStartArray(); + foreach (ProtocolVersionRecord item in ContainerProtocolVersions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + writer.WritePropertyName("cpu"u8); + writer.WriteStringValue(Cpu); + writer.WritePropertyName("memory"u8); + writer.WriteStringValue(Memory); + if (Optional.IsCollectionDefined(EnvironmentVariables)) + { + writer.WritePropertyName("environment_variables"u8); + writer.WriteStartObject(); + foreach (var item in EnvironmentVariables) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + HostedAgentDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (HostedAgentDefinition)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalAgentDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(HostedAgentDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeHostedAgentDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static HostedAgentDefinition DeserializeHostedAgentDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + return UnknownHostedAgentDefinition.DeserializeUnknownHostedAgentDefinition(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(HostedAgentDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + HostedAgentDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (HostedAgentDefinition)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalAgentDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeHostedAgentDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(HostedAgentDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/HostedAgentDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/HostedAgentDefinition.cs new file mode 100644 index 000000000000..89b46ff9752f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/HostedAgentDefinition.cs @@ -0,0 +1,71 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects +{ + /// The hosted agent definition. + internal partial class HostedAgentDefinition : InternalAgentDefinition + { + /// Initializes a new instance of . + /// The protocols that the agent supports for ingress communication of the containers. + /// The CPU configuration for the hosted agent. + /// The memory configuration for the hosted agent. + /// , or is null. + public HostedAgentDefinition(IEnumerable containerProtocolVersions, string cpu, string memory) : base(AgentKind.Hosted) + { + Argument.AssertNotNull(containerProtocolVersions, nameof(containerProtocolVersions)); + Argument.AssertNotNull(cpu, nameof(cpu)); + Argument.AssertNotNull(memory, nameof(memory)); + + Tools = new ChangeTrackingList(); + ContainerProtocolVersions = containerProtocolVersions.ToList(); + Cpu = cpu; + Memory = memory; + EnvironmentVariables = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// + /// Configuration for Responsible AI (RAI) content filtering and safety features. + /// Keeps track of any properties unknown to the library. + /// + /// An array of tools the hosted agent's model may call while generating a response. You + /// can specify which tool to use by setting the `tool_choice` parameter. + /// + /// The protocols that the agent supports for ingress communication of the containers. + /// The CPU configuration for the hosted agent. + /// The memory configuration for the hosted agent. + /// Environment variables to set in the hosted agent container. + internal HostedAgentDefinition(AgentKind kind, RaiConfig raiConfig, IDictionary additionalBinaryDataProperties, IList tools, IList containerProtocolVersions, string cpu, string memory, IDictionary environmentVariables) : base(kind, raiConfig, additionalBinaryDataProperties) + { + Tools = tools; + ContainerProtocolVersions = containerProtocolVersions; + Cpu = cpu; + Memory = memory; + EnvironmentVariables = environmentVariables; + } + + /// + /// An array of tools the hosted agent's model may call while generating a response. You + /// can specify which tool to use by setting the `tool_choice` parameter. + /// + public IList Tools { get; } + + /// The protocols that the agent supports for ingress communication of the containers. + public IList ContainerProtocolVersions { get; } + + /// The CPU configuration for the hosted agent. + public string Cpu { get; set; } + + /// The memory configuration for the hosted agent. + public string Memory { get; set; } + + /// Environment variables to set in the hosted agent container. + public IDictionary EnvironmentVariables { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/HourlyRecurrenceSchedule.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/HourlyRecurrenceSchedule.Serialization.cs new file mode 100644 index 000000000000..6280ccede6df --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/HourlyRecurrenceSchedule.Serialization.cs @@ -0,0 +1,118 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Hourly recurrence schedule. + public partial class HourlyRecurrenceSchedule : RecurrenceSchedule, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(HourlyRecurrenceSchedule)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + HourlyRecurrenceSchedule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (HourlyRecurrenceSchedule)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override RecurrenceSchedule JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(HourlyRecurrenceSchedule)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeHourlyRecurrenceSchedule(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static HourlyRecurrenceSchedule DeserializeHourlyRecurrenceSchedule(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RecurrenceType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new RecurrenceType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new HourlyRecurrenceSchedule(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(HourlyRecurrenceSchedule)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + HourlyRecurrenceSchedule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (HourlyRecurrenceSchedule)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override RecurrenceSchedule PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeHourlyRecurrenceSchedule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(HourlyRecurrenceSchedule)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/HourlyRecurrenceSchedule.cs b/sdk/ai/Azure.AI.Projects/src/Generated/HourlyRecurrenceSchedule.cs new file mode 100644 index 000000000000..4a31b3c224d7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/HourlyRecurrenceSchedule.cs @@ -0,0 +1,25 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Hourly recurrence schedule. + public partial class HourlyRecurrenceSchedule : RecurrenceSchedule + { + /// Initializes a new instance of . + public HourlyRecurrenceSchedule() : base(RecurrenceType.Hourly) + { + } + + /// Initializes a new instance of . + /// Recurrence type for the recurrence schedule. + /// Keeps track of any properties unknown to the library. + internal HourlyRecurrenceSchedule(RecurrenceType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/HumanEvaluationRuleAction.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/HumanEvaluationRuleAction.Serialization.cs new file mode 100644 index 000000000000..04677753a342 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/HumanEvaluationRuleAction.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Evaluation rule action for human evaluation. + public partial class HumanEvaluationRuleAction : EvaluationRuleAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal HumanEvaluationRuleAction() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(HumanEvaluationRuleAction)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("templateId"u8); + writer.WriteStringValue(TemplateId); + } + + /// The JSON reader. + /// The client options for reading and writing models. + HumanEvaluationRuleAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (HumanEvaluationRuleAction)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override EvaluationRuleAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(HumanEvaluationRuleAction)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeHumanEvaluationRuleAction(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static HumanEvaluationRuleAction DeserializeHumanEvaluationRuleAction(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + EvaluationRuleActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string templateId = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new EvaluationRuleActionType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("templateId"u8)) + { + templateId = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new HumanEvaluationRuleAction(@type, additionalBinaryDataProperties, templateId); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(HumanEvaluationRuleAction)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + HumanEvaluationRuleAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (HumanEvaluationRuleAction)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override EvaluationRuleAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeHumanEvaluationRuleAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(HumanEvaluationRuleAction)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/HumanEvaluationRuleAction.cs b/sdk/ai/Azure.AI.Projects/src/Generated/HumanEvaluationRuleAction.cs new file mode 100644 index 000000000000..a37fc48ae999 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/HumanEvaluationRuleAction.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Evaluation rule action for human evaluation. + public partial class HumanEvaluationRuleAction : EvaluationRuleAction + { + /// Initializes a new instance of . + /// Human evaluation template Id. + /// is null. + public HumanEvaluationRuleAction(string templateId) : base(EvaluationRuleActionType.HumanEvaluation) + { + Argument.AssertNotNull(templateId, nameof(templateId)); + + TemplateId = templateId; + } + + /// Initializes a new instance of . + /// Type of the evaluation action. + /// Keeps track of any properties unknown to the library. + /// Human evaluation template Id. + internal HumanEvaluationRuleAction(EvaluationRuleActionType @type, IDictionary additionalBinaryDataProperties, string templateId) : base(@type, additionalBinaryDataProperties) + { + TemplateId = templateId; + } + + /// Human evaluation template Id. + public string TemplateId { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ImageBasedHostedAgentDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ImageBasedHostedAgentDefinition.Serialization.cs new file mode 100644 index 000000000000..97d051186bc6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ImageBasedHostedAgentDefinition.Serialization.cs @@ -0,0 +1,210 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The image-based deployment definition for a hosted agent. + internal partial class ImageBasedHostedAgentDefinition : HostedAgentDefinition, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ImageBasedHostedAgentDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ImageBasedHostedAgentDefinition)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("image"u8); + writer.WriteStringValue(Image); + } + + /// The JSON reader. + /// The client options for reading and writing models. + ImageBasedHostedAgentDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (ImageBasedHostedAgentDefinition)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalAgentDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ImageBasedHostedAgentDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeImageBasedHostedAgentDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ImageBasedHostedAgentDefinition DeserializeImageBasedHostedAgentDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentKind kind = default; + RaiConfig raiConfig = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList tools = default; + IList containerProtocolVersions = default; + string cpu = default; + string memory = default; + IDictionary environmentVariables = default; + string image = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("kind"u8)) + { + kind = new AgentKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("rai_config"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + raiConfig = RaiConfig.DeserializeRaiConfig(prop.Value, options); + continue; + } + if (prop.NameEquals("tools"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalTool.DeserializeInternalTool(item, options)); + } + tools = array; + continue; + } + if (prop.NameEquals("container_protocol_versions"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ProtocolVersionRecord.DeserializeProtocolVersionRecord(item, options)); + } + containerProtocolVersions = array; + continue; + } + if (prop.NameEquals("cpu"u8)) + { + cpu = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("memory"u8)) + { + memory = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("environment_variables"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + environmentVariables = dictionary; + continue; + } + if (prop.NameEquals("image"u8)) + { + image = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ImageBasedHostedAgentDefinition( + kind, + raiConfig, + additionalBinaryDataProperties, + tools ?? new ChangeTrackingList(), + containerProtocolVersions, + cpu, + memory, + environmentVariables ?? new ChangeTrackingDictionary(), + image); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(ImageBasedHostedAgentDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ImageBasedHostedAgentDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (ImageBasedHostedAgentDefinition)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalAgentDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeImageBasedHostedAgentDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ImageBasedHostedAgentDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ImageBasedHostedAgentDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ImageBasedHostedAgentDefinition.cs new file mode 100644 index 000000000000..003381fb1b1c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ImageBasedHostedAgentDefinition.cs @@ -0,0 +1,50 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// The image-based deployment definition for a hosted agent. + internal partial class ImageBasedHostedAgentDefinition : HostedAgentDefinition + { + /// Initializes a new instance of . + /// The protocols that the agent supports for ingress communication of the containers. + /// The CPU configuration for the hosted agent. + /// The memory configuration for the hosted agent. + /// The image for the hosted agent. + /// , , or is null. + public ImageBasedHostedAgentDefinition(IEnumerable containerProtocolVersions, string cpu, string memory, string image) : base(containerProtocolVersions, cpu, memory) + { + Argument.AssertNotNull(containerProtocolVersions, nameof(containerProtocolVersions)); + Argument.AssertNotNull(cpu, nameof(cpu)); + Argument.AssertNotNull(memory, nameof(memory)); + Argument.AssertNotNull(image, nameof(image)); + + Image = image; + } + + /// Initializes a new instance of . + /// + /// Configuration for Responsible AI (RAI) content filtering and safety features. + /// Keeps track of any properties unknown to the library. + /// + /// An array of tools the hosted agent's model may call while generating a response. You + /// can specify which tool to use by setting the `tool_choice` parameter. + /// + /// The protocols that the agent supports for ingress communication of the containers. + /// The CPU configuration for the hosted agent. + /// The memory configuration for the hosted agent. + /// Environment variables to set in the hosted agent container. + /// The image for the hosted agent. + internal ImageBasedHostedAgentDefinition(AgentKind kind, RaiConfig raiConfig, IDictionary additionalBinaryDataProperties, IList tools, IList containerProtocolVersions, string cpu, string memory, IDictionary environmentVariables, string image) : base(kind, raiConfig, additionalBinaryDataProperties, tools, containerProtocolVersions, cpu, memory, environmentVariables) + { + Image = image; + } + + /// The image for the hosted agent. + public string Image { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ImageGenToolBackground.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ImageGenToolBackground.cs new file mode 100644 index 000000000000..9ae56adcb857 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ImageGenToolBackground.cs @@ -0,0 +1,69 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal readonly partial struct ImageGenToolBackground : IEquatable + { + private readonly string _value; + private const string TransparentValue = "transparent"; + private const string OpaqueValue = "opaque"; + private const string AutoValue = "auto"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ImageGenToolBackground(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Transparent. + public static ImageGenToolBackground Transparent { get; } = new ImageGenToolBackground(TransparentValue); + + /// Gets the Opaque. + public static ImageGenToolBackground Opaque { get; } = new ImageGenToolBackground(OpaqueValue); + + /// Gets the Auto. + public static ImageGenToolBackground Auto { get; } = new ImageGenToolBackground(AutoValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ImageGenToolBackground left, ImageGenToolBackground right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ImageGenToolBackground left, ImageGenToolBackground right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolBackground(string value) => new ImageGenToolBackground(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolBackground?(string value) => value == null ? null : new ImageGenToolBackground(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ImageGenToolBackground other && Equals(other); + + /// + public bool Equals(ImageGenToolBackground other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ImageGenToolModel.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ImageGenToolModel.cs new file mode 100644 index 000000000000..4030bda581c9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ImageGenToolModel.cs @@ -0,0 +1,62 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects; + +namespace OpenAI +{ + /// + internal readonly partial struct ImageGenToolModel : IEquatable + { + private readonly string _value; + private const string GptImage1Value = "gpt-image-1"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ImageGenToolModel(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the GptImage1. + public static ImageGenToolModel GptImage1 { get; } = new ImageGenToolModel(GptImage1Value); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ImageGenToolModel left, ImageGenToolModel right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ImageGenToolModel left, ImageGenToolModel right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolModel(string value) => new ImageGenToolModel(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolModel?(string value) => value == null ? null : new ImageGenToolModel(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ImageGenToolModel other && Equals(other); + + /// + public bool Equals(ImageGenToolModel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ImageGenToolModeration.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ImageGenToolModeration.cs new file mode 100644 index 000000000000..db9149a03d14 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ImageGenToolModeration.cs @@ -0,0 +1,65 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal readonly partial struct ImageGenToolModeration : IEquatable + { + private readonly string _value; + private const string AutoValue = "auto"; + private const string LowValue = "low"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ImageGenToolModeration(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Auto. + public static ImageGenToolModeration Auto { get; } = new ImageGenToolModeration(AutoValue); + + /// Gets the Low. + public static ImageGenToolModeration Low { get; } = new ImageGenToolModeration(LowValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ImageGenToolModeration left, ImageGenToolModeration right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ImageGenToolModeration left, ImageGenToolModeration right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolModeration(string value) => new ImageGenToolModeration(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolModeration?(string value) => value == null ? null : new ImageGenToolModeration(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ImageGenToolModeration other && Equals(other); + + /// + public bool Equals(ImageGenToolModeration other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ImageGenToolOutputFormat.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ImageGenToolOutputFormat.cs new file mode 100644 index 000000000000..e60de0cceceb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ImageGenToolOutputFormat.cs @@ -0,0 +1,69 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal readonly partial struct ImageGenToolOutputFormat : IEquatable + { + private readonly string _value; + private const string PngValue = "png"; + private const string WebpValue = "webp"; + private const string JpegValue = "jpeg"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ImageGenToolOutputFormat(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Png. + public static ImageGenToolOutputFormat Png { get; } = new ImageGenToolOutputFormat(PngValue); + + /// Gets the Webp. + public static ImageGenToolOutputFormat Webp { get; } = new ImageGenToolOutputFormat(WebpValue); + + /// Gets the Jpeg. + public static ImageGenToolOutputFormat Jpeg { get; } = new ImageGenToolOutputFormat(JpegValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ImageGenToolOutputFormat left, ImageGenToolOutputFormat right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ImageGenToolOutputFormat left, ImageGenToolOutputFormat right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolOutputFormat(string value) => new ImageGenToolOutputFormat(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolOutputFormat?(string value) => value == null ? null : new ImageGenToolOutputFormat(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ImageGenToolOutputFormat other && Equals(other); + + /// + public bool Equals(ImageGenToolOutputFormat other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ImageGenToolQuality.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ImageGenToolQuality.cs new file mode 100644 index 000000000000..f51eba7ecf88 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ImageGenToolQuality.cs @@ -0,0 +1,73 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal readonly partial struct ImageGenToolQuality : IEquatable + { + private readonly string _value; + private const string LowValue = "low"; + private const string MediumValue = "medium"; + private const string HighValue = "high"; + private const string AutoValue = "auto"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ImageGenToolQuality(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Low. + public static ImageGenToolQuality Low { get; } = new ImageGenToolQuality(LowValue); + + /// Gets the Medium. + public static ImageGenToolQuality Medium { get; } = new ImageGenToolQuality(MediumValue); + + /// Gets the High. + public static ImageGenToolQuality High { get; } = new ImageGenToolQuality(HighValue); + + /// Gets the Auto. + public static ImageGenToolQuality Auto { get; } = new ImageGenToolQuality(AutoValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ImageGenToolQuality left, ImageGenToolQuality right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ImageGenToolQuality left, ImageGenToolQuality right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolQuality(string value) => new ImageGenToolQuality(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolQuality?(string value) => value == null ? null : new ImageGenToolQuality(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ImageGenToolQuality other && Equals(other); + + /// + public bool Equals(ImageGenToolQuality other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ImageGenToolSize.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ImageGenToolSize.cs new file mode 100644 index 000000000000..0d755001eed0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ImageGenToolSize.cs @@ -0,0 +1,73 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal readonly partial struct ImageGenToolSize : IEquatable + { + private readonly string _value; + private const string _1024x1024Value = "1024x1024"; + private const string _1024x1536Value = "1024x1536"; + private const string _1536x1024Value = "1536x1024"; + private const string AutoValue = "auto"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ImageGenToolSize(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the _1024x1024. + public static ImageGenToolSize _1024x1024 { get; } = new ImageGenToolSize(_1024x1024Value); + + /// Gets the _1024x1536. + public static ImageGenToolSize _1024x1536 { get; } = new ImageGenToolSize(_1024x1536Value); + + /// Gets the _1536x1024. + public static ImageGenToolSize _1536x1024 { get; } = new ImageGenToolSize(_1536x1024Value); + + /// Gets the Auto. + public static ImageGenToolSize Auto { get; } = new ImageGenToolSize(AutoValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ImageGenToolSize left, ImageGenToolSize right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ImageGenToolSize left, ImageGenToolSize right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolSize(string value) => new ImageGenToolSize(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ImageGenToolSize?(string value) => value == null ? null : new ImageGenToolSize(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ImageGenToolSize other && Equals(other); + + /// + public bool Equals(ImageGenToolSize other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InnerError.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InnerError.Serialization.cs new file mode 100644 index 000000000000..288515eb888c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InnerError.Serialization.cs @@ -0,0 +1,153 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace Azure.Core.Foundations +{ + /// An object containing more specific information about the error. As per Azure REST API guidelines - https://aka.ms/AzureRestApiGuidelines#handling-errors. + internal partial class InnerError : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InnerError)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Code)) + { + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code); + } + if (Optional.IsDefined(Innererror)) + { + writer.WritePropertyName("innererror"u8); + writer.WriteObjectValue(Innererror, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InnerError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InnerError JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InnerError)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInnerError(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InnerError DeserializeInnerError(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string code = default; + InnerError innererror = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("code"u8)) + { + code = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("innererror"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + innererror = DeserializeInnerError(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InnerError(code, innererror, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InnerError)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InnerError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InnerError PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInnerError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InnerError)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InnerError.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InnerError.cs new file mode 100644 index 000000000000..b377fc38f5ff --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InnerError.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Core.Foundations +{ + /// An object containing more specific information about the error. As per Azure REST API guidelines - https://aka.ms/AzureRestApiGuidelines#handling-errors. + internal partial class InnerError + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal InnerError() + { + } + + /// Initializes a new instance of . + /// One of a server-defined set of error codes. + /// Inner error. + /// Keeps track of any properties unknown to the library. + internal InnerError(string code, InnerError innererror, IDictionary additionalBinaryDataProperties) + { + Code = code; + Innererror = innererror; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// One of a server-defined set of error codes. + public string Code { get; } + + /// Inner error. + public InnerError Innererror { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Insight.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Insight.Serialization.cs new file mode 100644 index 000000000000..44e020be3170 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Insight.Serialization.cs @@ -0,0 +1,222 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + /// The response body for cluster insights. + public partial class Insight : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal Insight() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Insight)} does not support writing '{format}' format."); + } + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("metadata"u8); + writer.WriteObjectValue(Metadata, options); + } + if (options.Format != "W") + { + writer.WritePropertyName("state"u8); + writer.WriteStringValue(State.ToString()); + } + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + writer.WritePropertyName("request"u8); + writer.WriteObjectValue(Request, options); + if (options.Format != "W" && Optional.IsDefined(Result)) + { + writer.WritePropertyName("result"u8); + writer.WriteObjectValue(Result, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + Insight IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual Insight JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Insight)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInsight(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static Insight DeserializeInsight(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + InsightsMetadata metadata = default; + OperationStatus state = default; + string displayName = default; + InsightRequest request = default; + InsightResult result = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("metadata"u8)) + { + metadata = InsightsMetadata.DeserializeInsightsMetadata(prop.Value, options); + continue; + } + if (prop.NameEquals("state"u8)) + { + state = new OperationStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("displayName"u8)) + { + displayName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("request"u8)) + { + request = InsightRequest.DeserializeInsightRequest(prop.Value, options); + continue; + } + if (prop.NameEquals("result"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + result = InsightResult.DeserializeInsightResult(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new Insight( + id, + metadata, + state, + displayName, + request, + result, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(Insight)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + Insight IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual Insight PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInsight(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Insight)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(Insight insight) + { + if (insight == null) + { + return null; + } + return BinaryContent.Create(insight, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + public static explicit operator Insight(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInsight(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Insight.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Insight.cs new file mode 100644 index 000000000000..3108b7dc3be3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Insight.cs @@ -0,0 +1,67 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core.Foundations; + +namespace Azure.AI.Projects +{ + /// The response body for cluster insights. + public partial class Insight + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// User friendly display name for the insight. + /// Request for the insights analysis. + /// or is null. + public Insight(string displayName, InsightRequest request) + { + Argument.AssertNotNull(displayName, nameof(displayName)); + Argument.AssertNotNull(request, nameof(request)); + + DisplayName = displayName; + Request = request; + } + + /// Initializes a new instance of . + /// The unique identifier for the insights report. + /// Metadata about the insights report. + /// The current state of the insights. + /// User friendly display name for the insight. + /// Request for the insights analysis. + /// The result of the insights report. + /// Keeps track of any properties unknown to the library. + internal Insight(string id, InsightsMetadata metadata, OperationStatus state, string displayName, InsightRequest request, InsightResult result, IDictionary additionalBinaryDataProperties) + { + Id = id; + Metadata = metadata; + State = state; + DisplayName = displayName; + Request = request; + Result = result; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The unique identifier for the insights report. + public string Id { get; } + + /// Metadata about the insights report. + public InsightsMetadata Metadata { get; } + + /// The current state of the insights. + public OperationStatus State { get; } + + /// User friendly display name for the insight. + public string DisplayName { get; set; } + + /// Request for the insights analysis. + public InsightRequest Request { get; set; } + + /// The result of the insights report. + public InsightResult Result { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InsightCluster.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InsightCluster.Serialization.cs new file mode 100644 index 000000000000..5f4284e7aa19 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InsightCluster.Serialization.cs @@ -0,0 +1,238 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// A cluster of analysis samples. + public partial class InsightCluster : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InsightCluster() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InsightCluster)} does not support writing '{format}' format."); + } + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("label"u8); + writer.WriteStringValue(Label); + writer.WritePropertyName("suggestion"u8); + writer.WriteStringValue(Suggestion); + writer.WritePropertyName("suggestionTitle"u8); + writer.WriteStringValue(SuggestionTitle); + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + writer.WritePropertyName("weight"u8); + writer.WriteNumberValue(Weight); + if (Optional.IsCollectionDefined(SubClusters)) + { + writer.WritePropertyName("subClusters"u8); + writer.WriteStartArray(); + foreach (InsightCluster item in SubClusters) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Samples)) + { + writer.WritePropertyName("samples"u8); + writer.WriteStartArray(); + foreach (InsightSample item in Samples) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InsightCluster IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InsightCluster JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InsightCluster)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInsightCluster(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InsightCluster DeserializeInsightCluster(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string label = default; + string suggestion = default; + string suggestionTitle = default; + string description = default; + int weight = default; + IList subClusters = default; + IList samples = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("label"u8)) + { + label = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("suggestion"u8)) + { + suggestion = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("suggestionTitle"u8)) + { + suggestionTitle = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("weight"u8)) + { + weight = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("subClusters"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(DeserializeInsightCluster(item, options)); + } + subClusters = array; + continue; + } + if (prop.NameEquals("samples"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InsightSample.DeserializeInsightSample(item, options)); + } + samples = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InsightCluster( + id, + label, + suggestion, + suggestionTitle, + description, + weight, + subClusters ?? new ChangeTrackingList(), + samples ?? new ChangeTrackingList(), + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InsightCluster)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InsightCluster IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InsightCluster PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInsightCluster(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InsightCluster)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InsightCluster.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InsightCluster.cs new file mode 100644 index 000000000000..34242fa9540e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InsightCluster.cs @@ -0,0 +1,82 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// A cluster of analysis samples. + public partial class InsightCluster + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The id of the analysis cluster. + /// Label for the cluster. + /// Suggestion for the cluster. + /// The title of the suggestion for the cluster. + /// Description of the analysis cluster. + /// The weight of the analysis cluster. This indicate number of samples in the cluster. + internal InsightCluster(string id, string label, string suggestion, string suggestionTitle, string description, int weight) + { + Id = id; + Label = label; + Suggestion = suggestion; + SuggestionTitle = suggestionTitle; + Description = description; + Weight = weight; + SubClusters = new ChangeTrackingList(); + Samples = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The id of the analysis cluster. + /// Label for the cluster. + /// Suggestion for the cluster. + /// The title of the suggestion for the cluster. + /// Description of the analysis cluster. + /// The weight of the analysis cluster. This indicate number of samples in the cluster. + /// List of subclusters within this cluster. Empty if no subclusters exist. + /// List of samples that belong to this cluster. Empty if samples are part of subclusters. + /// Keeps track of any properties unknown to the library. + internal InsightCluster(string id, string label, string suggestion, string suggestionTitle, string description, int weight, IList subClusters, IList samples, IDictionary additionalBinaryDataProperties) + { + Id = id; + Label = label; + Suggestion = suggestion; + SuggestionTitle = suggestionTitle; + Description = description; + Weight = weight; + SubClusters = subClusters; + Samples = samples; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The id of the analysis cluster. + public string Id { get; } + + /// Label for the cluster. + public string Label { get; } + + /// Suggestion for the cluster. + public string Suggestion { get; } + + /// The title of the suggestion for the cluster. + public string SuggestionTitle { get; } + + /// Description of the analysis cluster. + public string Description { get; } + + /// The weight of the analysis cluster. This indicate number of samples in the cluster. + public int Weight { get; } + + /// List of subclusters within this cluster. Empty if no subclusters exist. + public IList SubClusters { get; } + + /// List of samples that belong to this cluster. Empty if samples are part of subclusters. + public IList Samples { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InsightModelConfiguration.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InsightModelConfiguration.Serialization.cs new file mode 100644 index 000000000000..402d8b47c49d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InsightModelConfiguration.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Configuration of the model used in the insight generation. + public partial class InsightModelConfiguration : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InsightModelConfiguration() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InsightModelConfiguration)} does not support writing '{format}' format."); + } + writer.WritePropertyName("modelDeploymentName"u8); + writer.WriteStringValue(ModelDeploymentName); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InsightModelConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InsightModelConfiguration JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InsightModelConfiguration)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInsightModelConfiguration(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InsightModelConfiguration DeserializeInsightModelConfiguration(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string modelDeploymentName = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("modelDeploymentName"u8)) + { + modelDeploymentName = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InsightModelConfiguration(modelDeploymentName, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InsightModelConfiguration)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InsightModelConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InsightModelConfiguration PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInsightModelConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InsightModelConfiguration)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InsightModelConfiguration.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InsightModelConfiguration.cs new file mode 100644 index 000000000000..18e2bd85e235 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InsightModelConfiguration.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Configuration of the model used in the insight generation. + public partial class InsightModelConfiguration + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The model deployment to be evaluated. Accepts either the deployment name alone or with the connection name as '{connectionName}/<modelDeploymentName>'. + /// is null. + public InsightModelConfiguration(string modelDeploymentName) + { + Argument.AssertNotNull(modelDeploymentName, nameof(modelDeploymentName)); + + ModelDeploymentName = modelDeploymentName; + } + + /// Initializes a new instance of . + /// The model deployment to be evaluated. Accepts either the deployment name alone or with the connection name as '{connectionName}/<modelDeploymentName>'. + /// Keeps track of any properties unknown to the library. + internal InsightModelConfiguration(string modelDeploymentName, IDictionary additionalBinaryDataProperties) + { + ModelDeploymentName = modelDeploymentName; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The model deployment to be evaluated. Accepts either the deployment name alone or with the connection name as '{connectionName}/<modelDeploymentName>'. + public string ModelDeploymentName { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InsightRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InsightRequest.Serialization.cs new file mode 100644 index 000000000000..ec620b3dfe52 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InsightRequest.Serialization.cs @@ -0,0 +1,140 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// + /// The request of the insights report. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// + [PersistableModelProxy(typeof(UnknownInsightRequest))] + public abstract partial class InsightRequest : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InsightRequest() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InsightRequest)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InsightRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InsightRequest JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InsightRequest)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInsightRequest(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InsightRequest DeserializeInsightRequest(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "EvaluationRunClusterInsight": + return EvaluationRunClusterInsightsRequest.DeserializeEvaluationRunClusterInsightsRequest(element, options); + case "AgentClusterInsight": + return AgentClusterInsightsRequest.DeserializeAgentClusterInsightsRequest(element, options); + case "EvaluationComparison": + return EvaluationComparisonRequest.DeserializeEvaluationComparisonRequest(element, options); + } + } + return UnknownInsightRequest.DeserializeUnknownInsightRequest(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InsightRequest)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InsightRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InsightRequest PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInsightRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InsightRequest)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InsightRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InsightRequest.cs new file mode 100644 index 000000000000..7f61b4ce1c45 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InsightRequest.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// + /// The request of the insights report. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// + public abstract partial class InsightRequest + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The type of request. + private protected InsightRequest(InsightType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// The type of request. + /// Keeps track of any properties unknown to the library. + internal InsightRequest(InsightType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The type of request. + internal InsightType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InsightResult.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InsightResult.Serialization.cs new file mode 100644 index 000000000000..06c2e766b9ba --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InsightResult.Serialization.cs @@ -0,0 +1,140 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// + /// The result of the insights. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// + [PersistableModelProxy(typeof(UnknownInsightResult))] + public abstract partial class InsightResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InsightResult() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InsightResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InsightResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InsightResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InsightResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInsightResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InsightResult DeserializeInsightResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "EvaluationComparison": + return EvalCompareReport.DeserializeEvalCompareReport(element, options); + case "EvaluationRunClusterInsight": + return EvaluationRunClusterInsightResult.DeserializeEvaluationRunClusterInsightResult(element, options); + case "AgentClusterInsight": + return AgentClusterInsightResult.DeserializeAgentClusterInsightResult(element, options); + } + } + return UnknownInsightResult.DeserializeUnknownInsightResult(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InsightResult)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InsightResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InsightResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInsightResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InsightResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InsightResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InsightResult.cs new file mode 100644 index 000000000000..308757d9665a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InsightResult.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// + /// The result of the insights. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// + public abstract partial class InsightResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The type of insights result. + private protected InsightResult(InsightType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// The type of insights result. + /// Keeps track of any properties unknown to the library. + internal InsightResult(InsightType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The type of insights result. + internal InsightType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InsightSample.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InsightSample.Serialization.cs new file mode 100644 index 000000000000..92ef5eb8de75 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InsightSample.Serialization.cs @@ -0,0 +1,178 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// + /// A sample from the analysis. + /// Please note this is the abstract base class. The derived classes available for instantiation are: . + /// + [PersistableModelProxy(typeof(UnknownInsightSample))] + public abstract partial class InsightSample : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InsightSample() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InsightSample)} does not support writing '{format}' format."); + } + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + writer.WritePropertyName("features"u8); + writer.WriteStartObject(); + foreach (var item in Features) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#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(); + writer.WritePropertyName("correlationInfo"u8); + writer.WriteStartObject(); + foreach (var item in CorrelationInfo) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#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(); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InsightSample IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InsightSample JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InsightSample)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInsightSample(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InsightSample DeserializeInsightSample(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "EvaluationResultSample": + return EvaluationResultSample.DeserializeEvaluationResultSample(element, options); + } + } + return UnknownInsightSample.DeserializeUnknownInsightSample(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InsightSample)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InsightSample IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InsightSample PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInsightSample(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InsightSample)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InsightSample.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InsightSample.cs new file mode 100644 index 000000000000..4a309a144677 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InsightSample.cs @@ -0,0 +1,110 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// + /// A sample from the analysis. + /// Please note this is the abstract base class. The derived classes available for instantiation are: . + /// + public abstract partial class InsightSample + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The unique identifier for the analysis sample. + /// Sample type. + /// Features to help with additional filtering of data in UX. + /// Info about the correlation for the analysis sample. + private protected InsightSample(string id, SampleType @type, IDictionary features, IDictionary correlationInfo) + { + Id = id; + Type = @type; + Features = features; + CorrelationInfo = correlationInfo; + } + + /// Initializes a new instance of . + /// The unique identifier for the analysis sample. + /// Sample type. + /// Features to help with additional filtering of data in UX. + /// Info about the correlation for the analysis sample. + /// Keeps track of any properties unknown to the library. + internal InsightSample(string id, SampleType @type, IDictionary features, IDictionary correlationInfo, IDictionary additionalBinaryDataProperties) + { + Id = id; + Type = @type; + Features = features; + CorrelationInfo = correlationInfo; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The unique identifier for the analysis sample. + public string Id { get; } + + /// Sample type. + internal SampleType Type { get; set; } + + /// + /// Features to help with additional filtering of data in UX. + /// 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" }. + /// + /// + /// + /// + public IDictionary Features { get; } + + /// + /// Info about the correlation for the analysis sample. + /// 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" }. + /// + /// + /// + /// + public IDictionary CorrelationInfo { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InsightScheduleTask.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InsightScheduleTask.Serialization.cs new file mode 100644 index 000000000000..1a3eda6abc8f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InsightScheduleTask.Serialization.cs @@ -0,0 +1,153 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Insight task for the schedule. + public partial class InsightScheduleTask : ScheduleTask, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InsightScheduleTask() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InsightScheduleTask)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("insight"u8); + writer.WriteObjectValue(Insight, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InsightScheduleTask IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InsightScheduleTask)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override ScheduleTask JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InsightScheduleTask)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInsightScheduleTask(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InsightScheduleTask DeserializeInsightScheduleTask(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ScheduleTaskType @type = default; + IDictionary configuration = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + Insight insight = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ScheduleTaskType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("configuration"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + configuration = dictionary; + continue; + } + if (prop.NameEquals("insight"u8)) + { + insight = Insight.DeserializeInsight(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InsightScheduleTask(@type, configuration ?? new ChangeTrackingDictionary(), additionalBinaryDataProperties, insight); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InsightScheduleTask)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InsightScheduleTask IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InsightScheduleTask)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override ScheduleTask PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInsightScheduleTask(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InsightScheduleTask)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InsightScheduleTask.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InsightScheduleTask.cs new file mode 100644 index 000000000000..2851ace2de6d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InsightScheduleTask.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Insight task for the schedule. + public partial class InsightScheduleTask : ScheduleTask + { + /// Initializes a new instance of . + /// The insight payload. + /// is null. + public InsightScheduleTask(Insight insight) : base(ScheduleTaskType.Insight) + { + Argument.AssertNotNull(insight, nameof(insight)); + + Insight = insight; + } + + /// Initializes a new instance of . + /// Type of the task. + /// Configuration for the task. + /// Keeps track of any properties unknown to the library. + /// The insight payload. + internal InsightScheduleTask(ScheduleTaskType @type, IDictionary configuration, IDictionary additionalBinaryDataProperties, Insight insight) : base(@type, configuration, additionalBinaryDataProperties) + { + Insight = insight; + } + + /// The insight payload. + public Insight Insight { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InsightSummary.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InsightSummary.Serialization.cs new file mode 100644 index 000000000000..c033b0ff9fcb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InsightSummary.Serialization.cs @@ -0,0 +1,177 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Summary of the error cluster analysis. + public partial class InsightSummary : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InsightSummary() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InsightSummary)} does not support writing '{format}' format."); + } + writer.WritePropertyName("sampleCount"u8); + writer.WriteNumberValue(SampleCount); + writer.WritePropertyName("uniqueSubclusterCount"u8); + writer.WriteNumberValue(UniqueSubclusterCount); + writer.WritePropertyName("uniqueClusterCount"u8); + writer.WriteNumberValue(UniqueClusterCount); + writer.WritePropertyName("method"u8); + writer.WriteStringValue(Method); + writer.WritePropertyName("usage"u8); + writer.WriteObjectValue(Usage, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InsightSummary IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InsightSummary JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InsightSummary)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInsightSummary(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InsightSummary DeserializeInsightSummary(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int sampleCount = default; + int uniqueSubclusterCount = default; + int uniqueClusterCount = default; + string @method = default; + ClusterTokenUsage usage = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("sampleCount"u8)) + { + sampleCount = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("uniqueSubclusterCount"u8)) + { + uniqueSubclusterCount = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("uniqueClusterCount"u8)) + { + uniqueClusterCount = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("method"u8)) + { + @method = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("usage"u8)) + { + usage = ClusterTokenUsage.DeserializeClusterTokenUsage(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InsightSummary( + sampleCount, + uniqueSubclusterCount, + uniqueClusterCount, + @method, + usage, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InsightSummary)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InsightSummary IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InsightSummary PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInsightSummary(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InsightSummary)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InsightSummary.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InsightSummary.cs new file mode 100644 index 000000000000..61260d9eecb9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InsightSummary.cs @@ -0,0 +1,63 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Summary of the error cluster analysis. + public partial class InsightSummary + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Total number of samples analyzed. + /// Total number of unique subcluster labels. + /// Total number of unique clusters. + /// Method used for clustering. + /// Token usage while performing clustering analysis. + internal InsightSummary(int sampleCount, int uniqueSubclusterCount, int uniqueClusterCount, string @method, ClusterTokenUsage usage) + { + SampleCount = sampleCount; + UniqueSubclusterCount = uniqueSubclusterCount; + UniqueClusterCount = uniqueClusterCount; + Method = @method; + Usage = usage; + } + + /// Initializes a new instance of . + /// Total number of samples analyzed. + /// Total number of unique subcluster labels. + /// Total number of unique clusters. + /// Method used for clustering. + /// Token usage while performing clustering analysis. + /// Keeps track of any properties unknown to the library. + internal InsightSummary(int sampleCount, int uniqueSubclusterCount, int uniqueClusterCount, string @method, ClusterTokenUsage usage, IDictionary additionalBinaryDataProperties) + { + SampleCount = sampleCount; + UniqueSubclusterCount = uniqueSubclusterCount; + UniqueClusterCount = uniqueClusterCount; + Method = @method; + Usage = usage; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Total number of samples analyzed. + public int SampleCount { get; } + + /// Total number of unique subcluster labels. + public int UniqueSubclusterCount { get; } + + /// Total number of unique clusters. + public int UniqueClusterCount { get; } + + /// Method used for clustering. + public string Method { get; } + + /// Token usage while performing clustering analysis. + public ClusterTokenUsage Usage { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InsightType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InsightType.cs new file mode 100644 index 000000000000..7c64ccc05ed5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InsightType.cs @@ -0,0 +1,72 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// The request of the insights. + public readonly partial struct InsightType : IEquatable + { + private readonly string _value; + /// Insights on an Evaluation run result. + private const string EvaluationRunClusterInsightValue = "EvaluationRunClusterInsight"; + /// Cluster Insight on an Agent. + private const string AgentClusterInsightValue = "AgentClusterInsight"; + /// Evaluation Comparison. + private const string EvaluationComparisonValue = "EvaluationComparison"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public InsightType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Insights on an Evaluation run result. + public static InsightType EvaluationRunClusterInsight { get; } = new InsightType(EvaluationRunClusterInsightValue); + + /// Cluster Insight on an Agent. + public static InsightType AgentClusterInsight { get; } = new InsightType(AgentClusterInsightValue); + + /// Evaluation Comparison. + public static InsightType EvaluationComparison { get; } = new InsightType(EvaluationComparisonValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(InsightType left, InsightType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(InsightType left, InsightType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator InsightType(string value) => new InsightType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator InsightType?(string value) => value == null ? null : new InsightType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InsightType other && Equals(other); + + /// + public bool Equals(InsightType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Insights.RestClient.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Insights.RestClient.cs new file mode 100644 index 000000000000..550f78d364ad --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Insights.RestClient.cs @@ -0,0 +1,103 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace Azure.AI.Projects +{ + /// + public partial class Insights + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier201; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier201 => _pipelineMessageClassifier201 = PipelineMessageClassifier.Create(stackalloc ushort[] { 201 }); + + internal PipelineMessage CreateGenerateRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/insights", false); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier201); + PipelineRequest request = message.Request; + request.Headers.Set("Repeatability-Request-ID", Guid.NewGuid().ToString()); + request.Headers.Set("Repeatability-First-Sent", TypeFormatters.ConvertToString(DateTimeOffset.Now, SerializationFormat.DateTime_RFC7231)); + request.Headers.Set("Content-Type", "application/json"); + request.Headers.Set("Accept", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal PipelineMessage CreateGetRequest(string id, bool? includeCoordinates, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/insights/", false); + uri.AppendPath(id, true); + uri.AppendQuery("api-version", _apiVersion, true); + if (includeCoordinates != null) + { + uri.AppendQuery("includeCoordinates", TypeFormatters.ConvertToString(includeCoordinates), true); + } + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + request.Headers.Set("x-ms-client-request-id", request.ClientRequestId); + return message; + } + + internal PipelineMessage CreateGetAllRequest(string @type, string evalId, string runId, string agentName, bool? includeCoordinates, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/insights", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (@type != null) + { + uri.AppendQuery("type", @type, true); + } + if (evalId != null) + { + uri.AppendQuery("evalId", evalId, true); + } + if (runId != null) + { + uri.AppendQuery("runId", runId, true); + } + if (agentName != null) + { + uri.AppendQuery("agentName", agentName, true); + } + if (includeCoordinates != null) + { + uri.AppendQuery("includeCoordinates", TypeFormatters.ConvertToString(includeCoordinates), true); + } + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + request.Headers.Set("x-ms-client-request-id", request.ClientRequestId); + return message; + } + + internal PipelineMessage CreateNextGetAllRequest(Uri nextPage, string @type, string evalId, string runId, string agentName, bool? includeCoordinates, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(nextPage); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + request.Headers.Set("x-ms-client-request-id", request.ClientRequestId); + return message; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Insights.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Insights.cs new file mode 100644 index 000000000000..f0188e43dad5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Insights.cs @@ -0,0 +1,278 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; + +namespace Azure.AI.Projects +{ + /// The Insights sub-client. + public partial class Insights + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of Insights for mocking. + protected Insights() + { + } + + /// Initializes a new instance of Insights. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal Insights(ClientPipeline pipeline, Uri endpoint, string apiVersion) + { + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } + + /// + /// [Protocol Method] Generate Insights + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Generate(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateGenerateRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Generate Insights + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GenerateAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateGenerateRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Generate Insights. + /// Complete evaluation configuration including data source, evaluators, and result settings. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual ClientResult Generate(Insight insight, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(insight, nameof(insight)); + + ClientResult result = Generate(insight, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Insight)result, result.GetRawResponse()); + } + + /// Generate Insights. + /// Complete evaluation configuration including data source, evaluators, and result settings. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual async Task> GenerateAsync(Insight insight, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(insight, nameof(insight)); + + ClientResult result = await GenerateAsync(insight, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Insight)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] Get a specific insight by Id. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The unique identifier for the insights report. + /// Whether to include coordinates for visualization in the response. Defaults to false. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(string id, bool? includeCoordinates, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + using PipelineMessage message = CreateGetRequest(id, includeCoordinates, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Get a specific insight by Id. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The unique identifier for the insights report. + /// Whether to include coordinates for visualization in the response. Defaults to false. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(string id, bool? includeCoordinates, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + using PipelineMessage message = CreateGetRequest(id, includeCoordinates, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Get a specific insight by Id. + /// The unique identifier for the insights report. + /// Whether to include coordinates for visualization in the response. Defaults to false. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult Get(string id, bool? includeCoordinates = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + ClientResult result = Get(id, includeCoordinates, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Insight)result, result.GetRawResponse()); + } + + /// Get a specific insight by Id. + /// The unique identifier for the insights report. + /// Whether to include coordinates for visualization in the response. Defaults to false. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(string id, bool? includeCoordinates = default, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + ClientResult result = await GetAsync(id, includeCoordinates, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Insight)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] List all insights in reverse chronological order (newest first). + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Filter by the type of analysis. + /// Filter by the evaluation ID. + /// Filter by the evaluation run ID. + /// Filter by the agent name. + /// Whether to include coordinates for visualization in the response. Defaults to false. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual CollectionResult GetAll(string @type, string evalId, string runId, string agentName, bool? includeCoordinates, RequestOptions options) + { + return new InsightsGetAllCollectionResult( + this, + @type, + evalId, + runId, + agentName, + includeCoordinates, + options); + } + + /// + /// [Protocol Method] List all insights in reverse chronological order (newest first). + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Filter by the type of analysis. + /// Filter by the evaluation ID. + /// Filter by the evaluation run ID. + /// Filter by the agent name. + /// Whether to include coordinates for visualization in the response. Defaults to false. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual AsyncCollectionResult GetAllAsync(string @type, string evalId, string runId, string agentName, bool? includeCoordinates, RequestOptions options) + { + return new InsightsGetAllAsyncCollectionResult( + this, + @type, + evalId, + runId, + agentName, + includeCoordinates, + options); + } + + /// List all insights in reverse chronological order (newest first). + /// Filter by the type of analysis. + /// Filter by the evaluation ID. + /// Filter by the evaluation run ID. + /// Filter by the agent name. + /// Whether to include coordinates for visualization in the response. Defaults to false. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual CollectionResult GetAll(InsightType? @type = default, string evalId = default, string runId = default, string agentName = default, bool? includeCoordinates = default, CancellationToken cancellationToken = default) + { + return new InsightsGetAllCollectionResultOfT( + this, + @type?.ToString(), + evalId, + runId, + agentName, + includeCoordinates, + cancellationToken.ToRequestOptions()); + } + + /// List all insights in reverse chronological order (newest first). + /// Filter by the type of analysis. + /// Filter by the evaluation ID. + /// Filter by the evaluation run ID. + /// Filter by the agent name. + /// Whether to include coordinates for visualization in the response. Defaults to false. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual AsyncCollectionResult GetAllAsync(InsightType? @type = default, string evalId = default, string runId = default, string agentName = default, bool? includeCoordinates = default, CancellationToken cancellationToken = default) + { + return new InsightsGetAllAsyncCollectionResultOfT( + this, + @type?.ToString(), + evalId, + runId, + agentName, + includeCoordinates, + cancellationToken.ToRequestOptions()); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InsightsMetadata.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InsightsMetadata.Serialization.cs new file mode 100644 index 000000000000..57d56f7290b1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InsightsMetadata.Serialization.cs @@ -0,0 +1,154 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Metadata about the insights. + public partial class InsightsMetadata : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InsightsMetadata() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InsightsMetadata)} does not support writing '{format}' format."); + } + writer.WritePropertyName("createdAt"u8); + writer.WriteStringValue(CreatedAt, "O"); + if (Optional.IsDefined(CompletedAt)) + { + writer.WritePropertyName("completedAt"u8); + writer.WriteStringValue(CompletedAt.Value, "O"); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InsightsMetadata IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InsightsMetadata JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InsightsMetadata)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInsightsMetadata(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InsightsMetadata DeserializeInsightsMetadata(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DateTimeOffset createdAt = default; + DateTimeOffset? completedAt = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("createdAt"u8)) + { + createdAt = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (prop.NameEquals("completedAt"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + completedAt = prop.Value.GetDateTimeOffset("O"); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InsightsMetadata(createdAt, completedAt, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InsightsMetadata)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InsightsMetadata IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InsightsMetadata PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInsightsMetadata(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InsightsMetadata)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InsightsMetadata.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InsightsMetadata.cs new file mode 100644 index 000000000000..aa61b904f8ec --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InsightsMetadata.cs @@ -0,0 +1,40 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Metadata about the insights. + public partial class InsightsMetadata + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The timestamp when the insights were created. + internal InsightsMetadata(DateTimeOffset createdAt) + { + CreatedAt = createdAt; + } + + /// Initializes a new instance of . + /// The timestamp when the insights were created. + /// The timestamp when the insights were completed. + /// Keeps track of any properties unknown to the library. + internal InsightsMetadata(DateTimeOffset createdAt, DateTimeOffset? completedAt, IDictionary additionalBinaryDataProperties) + { + CreatedAt = createdAt; + CompletedAt = completedAt; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The timestamp when the insights were created. + public DateTimeOffset CreatedAt { get; } + + /// The timestamp when the insights were completed. + public DateTimeOffset? CompletedAt { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Internal/ClientPipelineExtensions.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Internal/ClientPipelineExtensions.cs index 2bfc7431ad61..99467d2cdb8a 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/Internal/ClientPipelineExtensions.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Internal/ClientPipelineExtensions.cs @@ -10,32 +10,6 @@ namespace Azure.AI.Projects { internal static partial class ClientPipelineExtensions { - public static async ValueTask ProcessMessageAsync(this ClientPipeline pipeline, PipelineMessage message, RequestOptions options) - { - await pipeline.SendAsync(message).ConfigureAwait(false); - - if (message.Response.IsError && (options?.ErrorOptions & ClientErrorBehaviors.NoThrow) != ClientErrorBehaviors.NoThrow) - { - throw await ClientResultException.CreateAsync(message.Response).ConfigureAwait(false); - } - - PipelineResponse response = message.BufferResponse ? message.Response : message.ExtractResponse(); - return response; - } - - public static PipelineResponse ProcessMessage(this ClientPipeline pipeline, PipelineMessage message, RequestOptions options) - { - pipeline.Send(message); - - if (message.Response.IsError && (options?.ErrorOptions & ClientErrorBehaviors.NoThrow) != ClientErrorBehaviors.NoThrow) - { - throw new ClientResultException(message.Response); - } - - PipelineResponse response = message.BufferResponse ? message.Response : message.ExtractResponse(); - return response; - } - public static async ValueTask> ProcessHeadAsBoolMessageAsync(this ClientPipeline pipeline, PipelineMessage message, RequestOptions options) { PipelineResponse response = await pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false); diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentDefinition.Serialization.cs new file mode 100644 index 000000000000..3d5fca65ee68 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentDefinition.Serialization.cs @@ -0,0 +1,143 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + [PersistableModelProxy(typeof(UnknownAgentDefinition))] + internal abstract partial class InternalAgentDefinition : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalAgentDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAgentDefinition)} does not support writing '{format}' format."); + } + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind.ToString()); + if (Optional.IsDefined(RaiConfig)) + { + writer.WritePropertyName("rai_config"u8); + writer.WriteObjectValue(RaiConfig, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalAgentDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalAgentDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAgentDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAgentDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalAgentDefinition DeserializeInternalAgentDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("kind"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "workflow": + return WorkflowAgentDefinition.DeserializeWorkflowAgentDefinition(element, options); + case "hosted": + return HostedAgentDefinition.DeserializeHostedAgentDefinition(element, options); + case "container_app": + return ContainerAppAgentDefinition.DeserializeContainerAppAgentDefinition(element, options); + case "prompt": + return InternalPromptAgentDefinition.DeserializeInternalPromptAgentDefinition(element, options); + } + } + return UnknownAgentDefinition.DeserializeUnknownAgentDefinition(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalAgentDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalAgentDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalAgentDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalAgentDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAgentDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentDefinition.cs new file mode 100644 index 000000000000..7acb108bae57 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentDefinition.cs @@ -0,0 +1,39 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + internal abstract partial class InternalAgentDefinition + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + private protected InternalAgentDefinition(AgentKind kind) + { + Kind = kind; + } + + /// Initializes a new instance of . + /// + /// Configuration for Responsible AI (RAI) content filtering and safety features. + /// Keeps track of any properties unknown to the library. + internal InternalAgentDefinition(AgentKind kind, RaiConfig raiConfig, IDictionary additionalBinaryDataProperties) + { + Kind = kind; + RaiConfig = raiConfig; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Kind. + internal AgentKind Kind { get; set; } + + /// Configuration for Responsible AI (RAI) content filtering and safety features. + public RaiConfig RaiConfig { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentObject.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentObject.Serialization.cs new file mode 100644 index 000000000000..8b74cd8ebeaa --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentObject.Serialization.cs @@ -0,0 +1,171 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + internal partial class InternalAgentObject : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalAgentObject() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAgentObject)} does not support writing '{format}' format."); + } + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("versions"u8); + writer.WriteObjectValue(Versions, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalAgentObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalAgentObject JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAgentObject)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAgentObject(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalAgentObject DeserializeInternalAgentObject(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @object = default; + string id = default; + string name = default; + AgentObjectVersions versions = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("object"u8)) + { + @object = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("versions"u8)) + { + versions = AgentObjectVersions.DeserializeAgentObjectVersions(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalAgentObject(@object, id, name, versions, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalAgentObject)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalAgentObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalAgentObject PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalAgentObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAgentObject)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator InternalAgentObject(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalAgentObject(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentObject.cs new file mode 100644 index 000000000000..93a116ddd961 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentObject.cs @@ -0,0 +1,53 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + internal partial class InternalAgentObject + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The unique identifier of the agent. + /// The name of the agent. + /// The latest version of the agent. + internal InternalAgentObject(string id, string name, AgentObjectVersions versions) + { + Id = id; + Name = name; + Versions = versions; + } + + /// Initializes a new instance of . + /// The object type, which is always 'agent'. + /// The unique identifier of the agent. + /// The name of the agent. + /// The latest version of the agent. + /// Keeps track of any properties unknown to the library. + internal InternalAgentObject(string @object, string id, string name, AgentObjectVersions versions, IDictionary additionalBinaryDataProperties) + { + Object = @object; + Id = id; + Name = name; + Versions = versions; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The object type, which is always 'agent'. + public string Object { get; } = "agent"; + + /// The unique identifier of the agent. + public string Id { get; } + + /// The name of the agent. + public string Name { get; } + + /// The latest version of the agent. + public AgentObjectVersions Versions { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentProtocol.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentProtocol.cs new file mode 100644 index 000000000000..313d9a3997a1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentProtocol.cs @@ -0,0 +1,64 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + internal readonly partial struct InternalAgentProtocol : IEquatable + { + private readonly string _value; + private const string ActivityProtocolValue = "activity_protocol"; + private const string ResponsesValue = "responses"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public InternalAgentProtocol(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the ActivityProtocol. + public static InternalAgentProtocol ActivityProtocol { get; } = new InternalAgentProtocol(ActivityProtocolValue); + + /// Gets the Responses. + public static InternalAgentProtocol Responses { get; } = new InternalAgentProtocol(ResponsesValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(InternalAgentProtocol left, InternalAgentProtocol right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(InternalAgentProtocol left, InternalAgentProtocol right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator InternalAgentProtocol(string value) => new InternalAgentProtocol(value); + + /// Converts a string to a . + /// The value. + public static implicit operator InternalAgentProtocol?(string value) => value == null ? null : new InternalAgentProtocol(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is InternalAgentProtocol other && Equals(other); + + /// + public bool Equals(InternalAgentProtocol other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentVersionObject.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentVersionObject.Serialization.cs new file mode 100644 index 000000000000..b473919c4d78 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentVersionObject.Serialization.cs @@ -0,0 +1,250 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + internal partial class InternalAgentVersionObject : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalAgentVersionObject() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAgentVersionObject)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"u8); + } + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + writer.WritePropertyName("definition"u8); + writer.WriteObjectValue(Definition, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalAgentVersionObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalAgentVersionObject JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAgentVersionObject)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAgentVersionObject(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalAgentVersionObject DeserializeInternalAgentVersionObject(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary metadata = default; + string @object = default; + string id = default; + string name = default; + string version = default; + string description = default; + DateTimeOffset createdAt = default; + InternalAgentDefinition definition = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("metadata"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + metadata = new ChangeTrackingDictionary(); + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + metadata = dictionary; + continue; + } + if (prop.NameEquals("object"u8)) + { + @object = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("version"u8)) + { + version = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_at"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64()); + continue; + } + if (prop.NameEquals("definition"u8)) + { + definition = InternalAgentDefinition.DeserializeInternalAgentDefinition(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalAgentVersionObject( + metadata, + @object, + id, + name, + version, + description, + createdAt, + definition, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalAgentVersionObject)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalAgentVersionObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalAgentVersionObject PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalAgentVersionObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAgentVersionObject)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator InternalAgentVersionObject(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeInternalAgentVersionObject(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentVersionObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentVersionObject.cs new file mode 100644 index 000000000000..a03ad80a9056 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAgentVersionObject.cs @@ -0,0 +1,100 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + internal partial class InternalAgentVersionObject + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + /// The unique identifier of the agent version. + /// The name of the agent. Name can be used to retrieve/update/delete the agent. + /// The version identifier of the agent. Agents are immutable and every update creates a new version while keeping the name same. + /// The Unix timestamp (seconds) when the agent was created. + /// + internal InternalAgentVersionObject(IDictionary metadata, string id, string name, string version, DateTimeOffset createdAt, InternalAgentDefinition definition) + { + Metadata = metadata; + Id = id; + Name = name; + Version = version; + CreatedAt = createdAt; + Definition = definition; + } + + /// Initializes a new instance of . + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + /// The object type, which is always 'agent.version'. + /// The unique identifier of the agent version. + /// The name of the agent. Name can be used to retrieve/update/delete the agent. + /// The version identifier of the agent. Agents are immutable and every update creates a new version while keeping the name same. + /// A human-readable description of the agent. + /// The Unix timestamp (seconds) when the agent was created. + /// + /// Keeps track of any properties unknown to the library. + internal InternalAgentVersionObject(IDictionary metadata, string @object, string id, string name, string version, string description, DateTimeOffset createdAt, InternalAgentDefinition definition, IDictionary additionalBinaryDataProperties) + { + Metadata = metadata; + Object = @object; + Id = id; + Name = name; + Version = version; + Description = description; + CreatedAt = createdAt; + Definition = definition; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + public IDictionary Metadata { get; } + + /// The object type, which is always 'agent.version'. + public string Object { get; } = "agent.version"; + + /// The unique identifier of the agent version. + public string Id { get; } + + /// The name of the agent. Name can be used to retrieve/update/delete the agent. + public string Name { get; } + + /// The version identifier of the agent. Agents are immutable and every update creates a new version while keeping the name same. + public string Version { get; } + + /// A human-readable description of the agent. + public string Description { get; } + + /// The Unix timestamp (seconds) when the agent was created. + public DateTimeOffset CreatedAt { get; } + + /// Gets the Definition. + public InternalAgentDefinition Definition { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalAnnotation.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAnnotation.Serialization.cs new file mode 100644 index 000000000000..f6c053d4b286 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAnnotation.Serialization.cs @@ -0,0 +1,137 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + [PersistableModelProxy(typeof(UnknownAnnotation))] + internal abstract partial class InternalAnnotation : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalAnnotation() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAnnotation)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalAnnotation JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAnnotation)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAnnotation(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalAnnotation DeserializeInternalAnnotation(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "file_citation": + return InternalAnnotationFileCitation.DeserializeInternalAnnotationFileCitation(element, options); + case "url_citation": + return InternalAnnotationUrlCitation.DeserializeInternalAnnotationUrlCitation(element, options); + case "file_path": + return InternalAnnotationFilePath.DeserializeInternalAnnotationFilePath(element, options); + } + } + return UnknownAnnotation.DeserializeUnknownAnnotation(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalAnnotation)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalAnnotation PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAnnotation)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalAnnotation.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAnnotation.cs new file mode 100644 index 000000000000..74f39a9c6058 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAnnotation.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal abstract partial class InternalAnnotation + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + private protected InternalAnnotation(AnnotationType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalAnnotation(AnnotationType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Type. + internal AnnotationType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalAnnotationFileCitation.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAnnotationFileCitation.Serialization.cs new file mode 100644 index 000000000000..e221eb1f3e82 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAnnotationFileCitation.Serialization.cs @@ -0,0 +1,147 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalAnnotationFileCitation : InternalAnnotation, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalAnnotationFileCitation() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAnnotationFileCitation)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("filename"u8); + writer.WriteStringValue(Filename); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalAnnotationFileCitation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalAnnotationFileCitation)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalAnnotation JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAnnotationFileCitation)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAnnotationFileCitation(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalAnnotationFileCitation DeserializeInternalAnnotationFileCitation(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AnnotationType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string fileId = default; + int index = default; + string filename = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AnnotationType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("file_id"u8)) + { + fileId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("index"u8)) + { + index = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("filename"u8)) + { + filename = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalAnnotationFileCitation(@type, additionalBinaryDataProperties, fileId, index, filename); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalAnnotationFileCitation)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalAnnotationFileCitation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalAnnotationFileCitation)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalAnnotation PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalAnnotationFileCitation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAnnotationFileCitation)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalAnnotationFileCitation.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAnnotationFileCitation.cs new file mode 100644 index 000000000000..7acb67063136 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAnnotationFileCitation.cs @@ -0,0 +1,50 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalAnnotationFileCitation : InternalAnnotation + { + /// Initializes a new instance of . + /// The ID of the file. + /// The index of the file in the list of files. + /// The filename of the file cited. + /// or is null. + public InternalAnnotationFileCitation(string fileId, int index, string filename) : base(AnnotationType.FileCitation) + { + Argument.AssertNotNull(fileId, nameof(fileId)); + Argument.AssertNotNull(filename, nameof(filename)); + + FileId = fileId; + Index = index; + Filename = filename; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The ID of the file. + /// The index of the file in the list of files. + /// The filename of the file cited. + internal InternalAnnotationFileCitation(AnnotationType @type, IDictionary additionalBinaryDataProperties, string fileId, int index, string filename) : base(@type, additionalBinaryDataProperties) + { + FileId = fileId; + Index = index; + Filename = filename; + } + + /// The ID of the file. + public string FileId { get; } + + /// The index of the file in the list of files. + public int Index { get; } + + /// The filename of the file cited. + public string Filename { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalAnnotationFilePath.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAnnotationFilePath.Serialization.cs new file mode 100644 index 000000000000..85f30970c975 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAnnotationFilePath.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalAnnotationFilePath : InternalAnnotation, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalAnnotationFilePath() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAnnotationFilePath)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalAnnotationFilePath IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalAnnotationFilePath)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalAnnotation JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAnnotationFilePath)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAnnotationFilePath(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalAnnotationFilePath DeserializeInternalAnnotationFilePath(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AnnotationType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string fileId = default; + int index = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AnnotationType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("file_id"u8)) + { + fileId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("index"u8)) + { + index = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalAnnotationFilePath(@type, additionalBinaryDataProperties, fileId, index); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalAnnotationFilePath)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalAnnotationFilePath IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalAnnotationFilePath)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalAnnotation PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalAnnotationFilePath(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAnnotationFilePath)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalAnnotationFilePath.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAnnotationFilePath.cs new file mode 100644 index 000000000000..0494b235ff66 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAnnotationFilePath.cs @@ -0,0 +1,42 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalAnnotationFilePath : InternalAnnotation + { + /// Initializes a new instance of . + /// The ID of the file. + /// The index of the file in the list of files. + /// is null. + public InternalAnnotationFilePath(string fileId, int index) : base(AnnotationType.FilePath) + { + Argument.AssertNotNull(fileId, nameof(fileId)); + + FileId = fileId; + Index = index; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The ID of the file. + /// The index of the file in the list of files. + internal InternalAnnotationFilePath(AnnotationType @type, IDictionary additionalBinaryDataProperties, string fileId, int index) : base(@type, additionalBinaryDataProperties) + { + FileId = fileId; + Index = index; + } + + /// The ID of the file. + public string FileId { get; } + + /// The index of the file in the list of files. + public int Index { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalAnnotationUrlCitation.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAnnotationUrlCitation.Serialization.cs new file mode 100644 index 000000000000..5aad5772b023 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAnnotationUrlCitation.Serialization.cs @@ -0,0 +1,161 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalAnnotationUrlCitation : InternalAnnotation, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalAnnotationUrlCitation() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAnnotationUrlCitation)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Url.AbsoluteUri); + writer.WritePropertyName("start_index"u8); + writer.WriteNumberValue(StartIndex); + writer.WritePropertyName("end_index"u8); + writer.WriteNumberValue(EndIndex); + writer.WritePropertyName("title"u8); + writer.WriteStringValue(Title); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalAnnotationUrlCitation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalAnnotationUrlCitation)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalAnnotation JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAnnotationUrlCitation)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAnnotationUrlCitation(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalAnnotationUrlCitation DeserializeInternalAnnotationUrlCitation(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AnnotationType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + Uri url = default; + int startIndex = default; + int endIndex = default; + string title = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AnnotationType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("url"u8)) + { + url = new Uri(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("start_index"u8)) + { + startIndex = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("end_index"u8)) + { + endIndex = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("title"u8)) + { + title = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalAnnotationUrlCitation( + @type, + additionalBinaryDataProperties, + url, + startIndex, + endIndex, + title); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalAnnotationUrlCitation)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalAnnotationUrlCitation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalAnnotationUrlCitation)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalAnnotation PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalAnnotationUrlCitation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAnnotationUrlCitation)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalAnnotationUrlCitation.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAnnotationUrlCitation.cs new file mode 100644 index 000000000000..fe90f85dc522 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalAnnotationUrlCitation.cs @@ -0,0 +1,57 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalAnnotationUrlCitation : InternalAnnotation + { + /// Initializes a new instance of . + /// The URL of the web resource. + /// The index of the first character of the URL citation in the message. + /// The index of the last character of the URL citation in the message. + /// The title of the web resource. + /// or is null. + public InternalAnnotationUrlCitation(Uri url, int startIndex, int endIndex, string title) : base(AnnotationType.UrlCitation) + { + Argument.AssertNotNull(url, nameof(url)); + Argument.AssertNotNull(title, nameof(title)); + + Url = url; + StartIndex = startIndex; + EndIndex = endIndex; + Title = title; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The URL of the web resource. + /// The index of the first character of the URL citation in the message. + /// The index of the last character of the URL citation in the message. + /// The title of the web resource. + internal InternalAnnotationUrlCitation(AnnotationType @type, IDictionary additionalBinaryDataProperties, Uri url, int startIndex, int endIndex, string title) : base(@type, additionalBinaryDataProperties) + { + Url = url; + StartIndex = startIndex; + EndIndex = endIndex; + Title = title; + } + + /// The URL of the web resource. + public Uri Url { get; } + + /// The index of the first character of the URL citation in the message. + public int StartIndex { get; } + + /// The index of the last character of the URL citation in the message. + public int EndIndex { get; } + + /// The title of the web resource. + public string Title { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalApproximateLocation.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalApproximateLocation.Serialization.cs new file mode 100644 index 000000000000..53bd4e3a5722 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalApproximateLocation.Serialization.cs @@ -0,0 +1,188 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalApproximateLocation : InternalLocation, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalApproximateLocation)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Country)) + { + writer.WritePropertyName("country"u8); + writer.WriteStringValue(Country); + } + if (Optional.IsDefined(Region)) + { + writer.WritePropertyName("region"u8); + writer.WriteStringValue(Region); + } + if (Optional.IsDefined(City)) + { + writer.WritePropertyName("city"u8); + writer.WriteStringValue(City); + } + if (Optional.IsDefined(Timezone)) + { + writer.WritePropertyName("timezone"u8); + writer.WriteStringValue(Timezone); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalApproximateLocation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalApproximateLocation)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalLocation JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalApproximateLocation)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalApproximateLocation(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalApproximateLocation DeserializeInternalApproximateLocation(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + LocationType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string country = default; + string region = default; + string city = default; + string timezone = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new LocationType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("country"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + country = null; + continue; + } + country = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("region"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + region = null; + continue; + } + region = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("city"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + city = null; + continue; + } + city = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("timezone"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + timezone = null; + continue; + } + timezone = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalApproximateLocation( + @type, + additionalBinaryDataProperties, + country, + region, + city, + timezone); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalApproximateLocation)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalApproximateLocation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalApproximateLocation)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalLocation PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalApproximateLocation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalApproximateLocation)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalApproximateLocation.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalApproximateLocation.cs new file mode 100644 index 000000000000..c7622fa98475 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalApproximateLocation.cs @@ -0,0 +1,44 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalApproximateLocation : InternalLocation + { + /// Initializes a new instance of . + public InternalApproximateLocation() : base(LocationType.Approximate) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// + /// + /// + /// + internal InternalApproximateLocation(LocationType @type, IDictionary additionalBinaryDataProperties, string country, string region, string city, string timezone) : base(@type, additionalBinaryDataProperties) + { + Country = country; + Region = region; + City = city; + Timezone = timezone; + } + + /// Gets or sets the Country. + public string Country { get; set; } + + /// Gets or sets the Region. + public string Region { get; set; } + + /// Gets or sets the City. + public string City { get; set; } + + /// Gets or sets the Timezone. + public string Timezone { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterOutput.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterOutput.Serialization.cs new file mode 100644 index 000000000000..6c9365a3ed50 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterOutput.Serialization.cs @@ -0,0 +1,135 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + [PersistableModelProxy(typeof(UnknownCodeInterpreterOutput))] + internal abstract partial class InternalCodeInterpreterOutput : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalCodeInterpreterOutput() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutput)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToSerialString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalCodeInterpreterOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalCodeInterpreterOutput JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutput)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCodeInterpreterOutput(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalCodeInterpreterOutput DeserializeInternalCodeInterpreterOutput(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "image": + return InternalCodeInterpreterOutputImage.DeserializeInternalCodeInterpreterOutputImage(element, options); + case "logs": + return InternalCodeInterpreterOutputLogs.DeserializeInternalCodeInterpreterOutputLogs(element, options); + } + } + return UnknownCodeInterpreterOutput.DeserializeUnknownCodeInterpreterOutput(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutput)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalCodeInterpreterOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalCodeInterpreterOutput PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalCodeInterpreterOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutput)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterOutput.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterOutput.cs new file mode 100644 index 000000000000..2765697f41dd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterOutput.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal abstract partial class InternalCodeInterpreterOutput + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + private protected InternalCodeInterpreterOutput(CodeInterpreterOutputType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalCodeInterpreterOutput(CodeInterpreterOutputType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Type. + internal CodeInterpreterOutputType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterOutputImage.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterOutputImage.Serialization.cs new file mode 100644 index 000000000000..a97ccebdec70 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterOutputImage.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalCodeInterpreterOutputImage : InternalCodeInterpreterOutput, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalCodeInterpreterOutputImage() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutputImage)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Url.AbsoluteUri); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalCodeInterpreterOutputImage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalCodeInterpreterOutputImage)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalCodeInterpreterOutput JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutputImage)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCodeInterpreterOutputImage(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalCodeInterpreterOutputImage DeserializeInternalCodeInterpreterOutputImage(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CodeInterpreterOutputType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + Uri url = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToCodeInterpreterOutputType(); + continue; + } + if (prop.NameEquals("url"u8)) + { + url = new Uri(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalCodeInterpreterOutputImage(@type, additionalBinaryDataProperties, url); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutputImage)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalCodeInterpreterOutputImage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalCodeInterpreterOutputImage)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalCodeInterpreterOutput PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalCodeInterpreterOutputImage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutputImage)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterOutputImage.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterOutputImage.cs new file mode 100644 index 000000000000..d865a9330e98 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterOutputImage.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalCodeInterpreterOutputImage : InternalCodeInterpreterOutput + { + /// Initializes a new instance of . + /// The URL of the image output from the code interpreter. + /// is null. + public InternalCodeInterpreterOutputImage(Uri url) : base(CodeInterpreterOutputType.Image) + { + Argument.AssertNotNull(url, nameof(url)); + + Url = url; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The URL of the image output from the code interpreter. + internal InternalCodeInterpreterOutputImage(CodeInterpreterOutputType @type, IDictionary additionalBinaryDataProperties, Uri url) : base(@type, additionalBinaryDataProperties) + { + Url = url; + } + + /// The URL of the image output from the code interpreter. + public Uri Url { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterOutputLogs.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterOutputLogs.Serialization.cs new file mode 100644 index 000000000000..af3afe7469fb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterOutputLogs.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalCodeInterpreterOutputLogs : InternalCodeInterpreterOutput, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalCodeInterpreterOutputLogs() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutputLogs)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("logs"u8); + writer.WriteStringValue(Logs); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalCodeInterpreterOutputLogs IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalCodeInterpreterOutputLogs)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalCodeInterpreterOutput JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutputLogs)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCodeInterpreterOutputLogs(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalCodeInterpreterOutputLogs DeserializeInternalCodeInterpreterOutputLogs(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CodeInterpreterOutputType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string logs = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToCodeInterpreterOutputType(); + continue; + } + if (prop.NameEquals("logs"u8)) + { + logs = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalCodeInterpreterOutputLogs(@type, additionalBinaryDataProperties, logs); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutputLogs)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalCodeInterpreterOutputLogs IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalCodeInterpreterOutputLogs)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalCodeInterpreterOutput PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalCodeInterpreterOutputLogs(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutputLogs)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterOutputLogs.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterOutputLogs.cs new file mode 100644 index 000000000000..42fd01cd1dfe --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterOutputLogs.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalCodeInterpreterOutputLogs : InternalCodeInterpreterOutput + { + /// Initializes a new instance of . + /// The logs output from the code interpreter. + /// is null. + public InternalCodeInterpreterOutputLogs(string logs) : base(CodeInterpreterOutputType.Logs) + { + Argument.AssertNotNull(logs, nameof(logs)); + + Logs = logs; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The logs output from the code interpreter. + internal InternalCodeInterpreterOutputLogs(CodeInterpreterOutputType @type, IDictionary additionalBinaryDataProperties, string logs) : base(@type, additionalBinaryDataProperties) + { + Logs = logs; + } + + /// The logs output from the code interpreter. + public string Logs { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterTool.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterTool.Serialization.cs new file mode 100644 index 000000000000..fd383e0c747b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterTool.Serialization.cs @@ -0,0 +1,138 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalCodeInterpreterTool : InternalTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalCodeInterpreterTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("container"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Container); +#else + using (JsonDocument document = JsonDocument.Parse(Container)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalCodeInterpreterTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalCodeInterpreterTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCodeInterpreterTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalCodeInterpreterTool DeserializeInternalCodeInterpreterTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + BinaryData container = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("container"u8)) + { + container = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalCodeInterpreterTool(@type, additionalBinaryDataProperties, container); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalCodeInterpreterTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalCodeInterpreterTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalCodeInterpreterTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterTool.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterTool.cs new file mode 100644 index 000000000000..ed1f83938e86 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterTool.cs @@ -0,0 +1,81 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalCodeInterpreterTool : InternalTool + { + /// Initializes a new instance of . + /// + /// The code interpreter container. Can be a container ID or an object that + /// specifies uploaded file IDs to make available to your code. + /// + /// is null. + public InternalCodeInterpreterTool(BinaryData container) : base(ToolType.CodeInterpreter) + { + Argument.AssertNotNull(container, nameof(container)); + + Container = container; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// + /// The code interpreter container. Can be a container ID or an object that + /// specifies uploaded file IDs to make available to your code. + /// + internal InternalCodeInterpreterTool(ToolType @type, IDictionary additionalBinaryDataProperties, BinaryData container) : base(@type, additionalBinaryDataProperties) + { + Container = container; + } + + /// + /// The code interpreter container. Can be a container ID or an object that + /// specifies uploaded file IDs to make available to your code. + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// . + /// + /// + /// + /// + /// + /// 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" }. + /// + /// + /// + /// + public BinaryData Container { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterToolAuto.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterToolAuto.Serialization.cs new file mode 100644 index 000000000000..4a3d04fa591f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterToolAuto.Serialization.cs @@ -0,0 +1,171 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalCodeInterpreterToolAuto : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolAuto)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (Optional.IsCollectionDefined(FileIds)) + { + writer.WritePropertyName("file_ids"u8); + writer.WriteStartArray(); + foreach (string item in FileIds) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalCodeInterpreterToolAuto IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalCodeInterpreterToolAuto JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolAuto)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCodeInterpreterToolAuto(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalCodeInterpreterToolAuto DeserializeInternalCodeInterpreterToolAuto(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = default; + IList fileIds = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("file_ids"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + fileIds = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalCodeInterpreterToolAuto(@type, fileIds ?? new ChangeTrackingList(), additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolAuto)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalCodeInterpreterToolAuto IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalCodeInterpreterToolAuto PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalCodeInterpreterToolAuto(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolAuto)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterToolAuto.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterToolAuto.cs new file mode 100644 index 000000000000..829e7db8bb58 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterToolAuto.cs @@ -0,0 +1,39 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalCodeInterpreterToolAuto + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public InternalCodeInterpreterToolAuto() + { + FileIds = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Always `auto`. + /// An optional list of uploaded files to make available to your code. + /// Keeps track of any properties unknown to the library. + internal InternalCodeInterpreterToolAuto(string @type, IList fileIds, IDictionary additionalBinaryDataProperties) + { + Type = @type; + FileIds = fileIds; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Always `auto`. + public string Type { get; } = "auto"; + + /// An optional list of uploaded files to make available to your code. + public IList FileIds { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterToolCallItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterToolCallItemParam.Serialization.cs new file mode 100644 index 000000000000..d56090d5ab64 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterToolCallItemParam.Serialization.cs @@ -0,0 +1,181 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalCodeInterpreterToolCallItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalCodeInterpreterToolCallItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolCallItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("container_id"u8); + writer.WriteStringValue(ContainerId); + if (Optional.IsDefined(Code)) + { + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code); + } + else + { + writer.WriteNull("code"u8); + } + if (Optional.IsCollectionDefined(Outputs)) + { + writer.WritePropertyName("outputs"u8); + writer.WriteStartArray(); + foreach (InternalCodeInterpreterOutput item in Outputs) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + else + { + writer.WriteNull("outputs"u8); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalCodeInterpreterToolCallItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalCodeInterpreterToolCallItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolCallItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCodeInterpreterToolCallItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalCodeInterpreterToolCallItemParam DeserializeInternalCodeInterpreterToolCallItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string containerId = default; + string code = default; + IList outputs = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ItemType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("container_id"u8)) + { + containerId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("code"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + code = null; + continue; + } + code = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("outputs"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + outputs = new ChangeTrackingList(); + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalCodeInterpreterOutput.DeserializeInternalCodeInterpreterOutput(item, options)); + } + outputs = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalCodeInterpreterToolCallItemParam(@type, additionalBinaryDataProperties, containerId, code, outputs); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolCallItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalCodeInterpreterToolCallItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalCodeInterpreterToolCallItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalCodeInterpreterToolCallItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterToolCallItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterToolCallItemParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterToolCallItemParam.cs new file mode 100644 index 000000000000..fbb4719c2fcd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCodeInterpreterToolCallItemParam.cs @@ -0,0 +1,59 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalCodeInterpreterToolCallItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The ID of the container used to run the code. + /// The code to run, or null if not available. + /// + /// The outputs generated by the code interpreter, such as logs or images. + /// Can be null if no outputs are available. + /// + /// is null. + public InternalCodeInterpreterToolCallItemParam(string containerId, string code, IEnumerable outputs) : base(ItemType.CodeInterpreterCall) + { + Argument.AssertNotNull(containerId, nameof(containerId)); + + ContainerId = containerId; + Code = code; + Outputs = outputs?.ToList(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The ID of the container used to run the code. + /// The code to run, or null if not available. + /// + /// The outputs generated by the code interpreter, such as logs or images. + /// Can be null if no outputs are available. + /// + internal InternalCodeInterpreterToolCallItemParam(ItemType @type, IDictionary additionalBinaryDataProperties, string containerId, string code, IList outputs) : base(@type, additionalBinaryDataProperties) + { + ContainerId = containerId; + Code = code; + Outputs = outputs; + } + + /// The ID of the container used to run the code. + public string ContainerId { get; } + + /// The code to run, or null if not available. + public string Code { get; } + + /// + /// The outputs generated by the code interpreter, such as logs or images. + /// Can be null if no outputs are available. + /// + public IList Outputs { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComparisonFilter.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComparisonFilter.Serialization.cs new file mode 100644 index 000000000000..9e74f80f4c7c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComparisonFilter.Serialization.cs @@ -0,0 +1,162 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalComparisonFilter : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComparisonFilter() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComparisonFilter)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + writer.WritePropertyName("key"u8); + writer.WriteStringValue(Key); + writer.WritePropertyName("value"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Value); +#else + using (JsonDocument document = JsonDocument.Parse(Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComparisonFilter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalComparisonFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComparisonFilter)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComparisonFilter(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComparisonFilter DeserializeInternalComparisonFilter(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComparisonFilterType @type = default; + string key = default; + BinaryData value = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ComparisonFilterType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("key"u8)) + { + key = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("value"u8)) + { + value = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComparisonFilter(@type, key, value, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComparisonFilter)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComparisonFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalComparisonFilter PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComparisonFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComparisonFilter)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComparisonFilter.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComparisonFilter.cs new file mode 100644 index 000000000000..38534b0f7d40 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComparisonFilter.cs @@ -0,0 +1,104 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalComparisonFilter + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// Specifies the comparison operator: + /// `eq` (equal), `ne` (not equal), `gt` (greater than), `gte` (greater than or equal), `lt` (less than), `lte` (less than or equal). + /// + /// The key to compare against the value. + /// The value to compare against the attribute key; supports string, number, or boolean types. + /// or is null. + public InternalComparisonFilter(ComparisonFilterType @type, string key, BinaryData value) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + Type = @type; + Key = key; + Value = value; + } + + /// Initializes a new instance of . + /// + /// Specifies the comparison operator: + /// `eq` (equal), `ne` (not equal), `gt` (greater than), `gte` (greater than or equal), `lt` (less than), `lte` (less than or equal). + /// + /// The key to compare against the value. + /// The value to compare against the attribute key; supports string, number, or boolean types. + /// Keeps track of any properties unknown to the library. + internal InternalComparisonFilter(ComparisonFilterType @type, string key, BinaryData value, IDictionary additionalBinaryDataProperties) + { + Type = @type; + Key = key; + Value = value; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// Specifies the comparison operator: + /// `eq` (equal), `ne` (not equal), `gt` (greater than), `gte` (greater than or equal), `lt` (less than), `lte` (less than or equal). + /// + public ComparisonFilterType Type { get; set; } + + /// The key to compare against the value. + public string Key { get; set; } + + /// + /// The value to compare against the attribute key; supports string, number, or boolean types. + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// . + /// + /// + /// . + /// + /// + /// + /// + /// + /// 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" }. + /// + /// + /// + /// + public BinaryData Value { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalCompoundFilter.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCompoundFilter.Serialization.cs new file mode 100644 index 000000000000..2cbb66e07c5f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCompoundFilter.Serialization.cs @@ -0,0 +1,176 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalCompoundFilter : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalCompoundFilter() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCompoundFilter)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + writer.WritePropertyName("filters"u8); + writer.WriteStartArray(); + foreach (BinaryData item in Filters) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item); +#else + using (JsonDocument document = JsonDocument.Parse(item)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndArray(); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalCompoundFilter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalCompoundFilter JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCompoundFilter)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCompoundFilter(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalCompoundFilter DeserializeInternalCompoundFilter(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CompoundFilterType @type = default; + IList filters = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new CompoundFilterType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("filters"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(BinaryData.FromString(item.GetRawText())); + } + } + filters = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalCompoundFilter(@type, filters, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalCompoundFilter)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalCompoundFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalCompoundFilter PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalCompoundFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCompoundFilter)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalCompoundFilter.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCompoundFilter.cs new file mode 100644 index 000000000000..c1872c354198 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCompoundFilter.cs @@ -0,0 +1,85 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalCompoundFilter + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Type of operation: `and` or `or`. + /// Array of filters to combine. Items can be `ComparisonFilter` or `CompoundFilter`. + /// is null. + public InternalCompoundFilter(CompoundFilterType @type, IEnumerable filters) + { + Argument.AssertNotNull(filters, nameof(filters)); + + Type = @type; + Filters = filters.ToList(); + } + + /// Initializes a new instance of . + /// Type of operation: `and` or `or`. + /// Array of filters to combine. Items can be `ComparisonFilter` or `CompoundFilter`. + /// Keeps track of any properties unknown to the library. + internal InternalCompoundFilter(CompoundFilterType @type, IList filters, IDictionary additionalBinaryDataProperties) + { + Type = @type; + Filters = filters; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Type of operation: `and` or `or`. + public CompoundFilterType Type { get; set; } + + /// + /// Array of filters to combine. Items can be `ComparisonFilter` or `CompoundFilter`. + /// To assign an object to the element of this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// . + /// + /// + /// + /// + /// + /// 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" }. + /// + /// + /// + /// + public IList Filters { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerAction.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerAction.Serialization.cs new file mode 100644 index 000000000000..3de4eb1db53e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerAction.Serialization.cs @@ -0,0 +1,149 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + [PersistableModelProxy(typeof(UnknownComputerAction))] + internal abstract partial class InternalComputerAction : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerAction() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerAction)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToSerialString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalComputerAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerAction)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerAction(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerAction DeserializeInternalComputerAction(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "click": + return InternalComputerActionClick.DeserializeInternalComputerActionClick(element, options); + case "double_click": + return InternalComputerActionDoubleClick.DeserializeInternalComputerActionDoubleClick(element, options); + case "drag": + return InternalComputerActionDrag.DeserializeInternalComputerActionDrag(element, options); + case "move": + return InternalComputerActionMove.DeserializeInternalComputerActionMove(element, options); + case "screenshot": + return InternalComputerActionScreenshot.DeserializeInternalComputerActionScreenshot(element, options); + case "scroll": + return InternalComputerActionScroll.DeserializeInternalComputerActionScroll(element, options); + case "type": + return InternalComputerActionTypeKeys.DeserializeInternalComputerActionTypeKeys(element, options); + case "wait": + return InternalComputerActionWait.DeserializeInternalComputerActionWait(element, options); + case "keypress": + return InternalComputerActionKeyPress.DeserializeInternalComputerActionKeyPress(element, options); + } + } + return UnknownComputerAction.DeserializeUnknownComputerAction(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerAction)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalComputerAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerAction)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerAction.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerAction.cs new file mode 100644 index 000000000000..d1d1c81c85b4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerAction.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal abstract partial class InternalComputerAction + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + private protected InternalComputerAction(ComputerActionType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalComputerAction(ComputerActionType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Type. + internal ComputerActionType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionClick.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionClick.Serialization.cs new file mode 100644 index 000000000000..e324526d08c7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionClick.Serialization.cs @@ -0,0 +1,147 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalComputerActionClick : InternalComputerAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerActionClick() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionClick)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("button"u8); + writer.WriteStringValue(Button.ToString()); + writer.WritePropertyName("x"u8); + writer.WriteNumberValue(X); + writer.WritePropertyName("y"u8); + writer.WriteNumberValue(Y); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerActionClick IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerActionClick)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalComputerAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionClick)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerActionClick(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerActionClick DeserializeInternalComputerActionClick(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComputerActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ComputerActionClickButton button = default; + int x = default; + int y = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToComputerActionType(); + continue; + } + if (prop.NameEquals("button"u8)) + { + button = new ComputerActionClickButton(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("x"u8)) + { + x = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("y"u8)) + { + y = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerActionClick(@type, additionalBinaryDataProperties, button, x, y); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerActionClick)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerActionClick IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerActionClick)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalComputerAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerActionClick(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerActionClick)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionClick.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionClick.cs new file mode 100644 index 000000000000..a5d8f0b777aa --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionClick.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalComputerActionClick : InternalComputerAction + { + /// Initializes a new instance of . + /// Indicates which mouse button was pressed during the click. One of `left`, `right`, `wheel`, `back`, or `forward`. + /// The x-coordinate where the click occurred. + /// The y-coordinate where the click occurred. + public InternalComputerActionClick(ComputerActionClickButton button, int x, int y) : base(ComputerActionType.Click) + { + Button = button; + X = x; + Y = y; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// Indicates which mouse button was pressed during the click. One of `left`, `right`, `wheel`, `back`, or `forward`. + /// The x-coordinate where the click occurred. + /// The y-coordinate where the click occurred. + internal InternalComputerActionClick(ComputerActionType @type, IDictionary additionalBinaryDataProperties, ComputerActionClickButton button, int x, int y) : base(@type, additionalBinaryDataProperties) + { + Button = button; + X = x; + Y = y; + } + + /// Indicates which mouse button was pressed during the click. One of `left`, `right`, `wheel`, `back`, or `forward`. + public ComputerActionClickButton Button { get; } + + /// The x-coordinate where the click occurred. + public int X { get; } + + /// The y-coordinate where the click occurred. + public int Y { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionDoubleClick.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionDoubleClick.Serialization.cs new file mode 100644 index 000000000000..ac8632da1796 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionDoubleClick.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalComputerActionDoubleClick : InternalComputerAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerActionDoubleClick() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionDoubleClick)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("x"u8); + writer.WriteNumberValue(X); + writer.WritePropertyName("y"u8); + writer.WriteNumberValue(Y); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerActionDoubleClick IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerActionDoubleClick)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalComputerAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionDoubleClick)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerActionDoubleClick(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerActionDoubleClick DeserializeInternalComputerActionDoubleClick(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComputerActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + int x = default; + int y = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToComputerActionType(); + continue; + } + if (prop.NameEquals("x"u8)) + { + x = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("y"u8)) + { + y = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerActionDoubleClick(@type, additionalBinaryDataProperties, x, y); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerActionDoubleClick)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerActionDoubleClick IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerActionDoubleClick)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalComputerAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerActionDoubleClick(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerActionDoubleClick)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionDoubleClick.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionDoubleClick.cs new file mode 100644 index 000000000000..4d83bf7a0125 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionDoubleClick.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalComputerActionDoubleClick : InternalComputerAction + { + /// Initializes a new instance of . + /// The x-coordinate where the double click occurred. + /// The y-coordinate where the double click occurred. + public InternalComputerActionDoubleClick(int x, int y) : base(ComputerActionType.DoubleClick) + { + X = x; + Y = y; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The x-coordinate where the double click occurred. + /// The y-coordinate where the double click occurred. + internal InternalComputerActionDoubleClick(ComputerActionType @type, IDictionary additionalBinaryDataProperties, int x, int y) : base(@type, additionalBinaryDataProperties) + { + X = x; + Y = y; + } + + /// The x-coordinate where the double click occurred. + public int X { get; } + + /// The y-coordinate where the double click occurred. + public int Y { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionDrag.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionDrag.Serialization.cs new file mode 100644 index 000000000000..b62ebe4af943 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionDrag.Serialization.cs @@ -0,0 +1,141 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalComputerActionDrag : InternalComputerAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerActionDrag() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionDrag)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("path"u8); + writer.WriteStartArray(); + foreach (InternalCoordinate item in Path) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerActionDrag IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerActionDrag)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalComputerAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionDrag)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerActionDrag(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerActionDrag DeserializeInternalComputerActionDrag(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComputerActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList path = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToComputerActionType(); + continue; + } + if (prop.NameEquals("path"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalCoordinate.DeserializeInternalCoordinate(item, options)); + } + path = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerActionDrag(@type, additionalBinaryDataProperties, path); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerActionDrag)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerActionDrag IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerActionDrag)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalComputerAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerActionDrag(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerActionDrag)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionDrag.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionDrag.cs new file mode 100644 index 000000000000..6f2a494ceea5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionDrag.cs @@ -0,0 +1,63 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalComputerActionDrag : InternalComputerAction + { + /// Initializes a new instance of . + /// + /// An array of coordinates representing the path of the drag action. Coordinates will appear as an array + /// of objects, eg + /// ``` + /// [ + /// { x: 100, y: 200 }, + /// { x: 200, y: 300 } + /// ] + /// ``` + /// + /// is null. + public InternalComputerActionDrag(IEnumerable path) : base(ComputerActionType.Drag) + { + Argument.AssertNotNull(path, nameof(path)); + + Path = path.ToList(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// + /// An array of coordinates representing the path of the drag action. Coordinates will appear as an array + /// of objects, eg + /// ``` + /// [ + /// { x: 100, y: 200 }, + /// { x: 200, y: 300 } + /// ] + /// ``` + /// + internal InternalComputerActionDrag(ComputerActionType @type, IDictionary additionalBinaryDataProperties, IList path) : base(@type, additionalBinaryDataProperties) + { + Path = path; + } + + /// + /// An array of coordinates representing the path of the drag action. Coordinates will appear as an array + /// of objects, eg + /// ``` + /// [ + /// { x: 100, y: 200 }, + /// { x: 200, y: 300 } + /// ] + /// ``` + /// + public IList Path { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionKeyPress.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionKeyPress.Serialization.cs new file mode 100644 index 000000000000..28b15250a6c8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionKeyPress.Serialization.cs @@ -0,0 +1,153 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalComputerActionKeyPress : InternalComputerAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerActionKeyPress() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionKeyPress)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("keys"u8); + writer.WriteStartArray(); + foreach (string item in Keys) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerActionKeyPress IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerActionKeyPress)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalComputerAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionKeyPress)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerActionKeyPress(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerActionKeyPress DeserializeInternalComputerActionKeyPress(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComputerActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList keys = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToComputerActionType(); + continue; + } + if (prop.NameEquals("keys"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + keys = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerActionKeyPress(@type, additionalBinaryDataProperties, keys); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerActionKeyPress)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerActionKeyPress IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerActionKeyPress)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalComputerAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerActionKeyPress(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerActionKeyPress)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionKeyPress.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionKeyPress.cs new file mode 100644 index 000000000000..a8a00530f342 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionKeyPress.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalComputerActionKeyPress : InternalComputerAction + { + /// Initializes a new instance of . + /// + /// The combination of keys the model is requesting to be pressed. This is an + /// array of strings, each representing a key. + /// + /// is null. + public InternalComputerActionKeyPress(IEnumerable keys) : base(ComputerActionType.Keypress) + { + Argument.AssertNotNull(keys, nameof(keys)); + + Keys = keys.ToList(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// + /// The combination of keys the model is requesting to be pressed. This is an + /// array of strings, each representing a key. + /// + internal InternalComputerActionKeyPress(ComputerActionType @type, IDictionary additionalBinaryDataProperties, IList keys) : base(@type, additionalBinaryDataProperties) + { + Keys = keys; + } + + /// + /// The combination of keys the model is requesting to be pressed. This is an + /// array of strings, each representing a key. + /// + public IList Keys { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionMove.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionMove.Serialization.cs new file mode 100644 index 000000000000..500a9e532ade --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionMove.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalComputerActionMove : InternalComputerAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerActionMove() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionMove)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("x"u8); + writer.WriteNumberValue(X); + writer.WritePropertyName("y"u8); + writer.WriteNumberValue(Y); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerActionMove IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerActionMove)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalComputerAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionMove)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerActionMove(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerActionMove DeserializeInternalComputerActionMove(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComputerActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + int x = default; + int y = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToComputerActionType(); + continue; + } + if (prop.NameEquals("x"u8)) + { + x = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("y"u8)) + { + y = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerActionMove(@type, additionalBinaryDataProperties, x, y); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerActionMove)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerActionMove IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerActionMove)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalComputerAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerActionMove(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerActionMove)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionMove.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionMove.cs new file mode 100644 index 000000000000..657fdc975cc4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionMove.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalComputerActionMove : InternalComputerAction + { + /// Initializes a new instance of . + /// The x-coordinate to move to. + /// The y-coordinate to move to. + public InternalComputerActionMove(int x, int y) : base(ComputerActionType.Move) + { + X = x; + Y = y; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The x-coordinate to move to. + /// The y-coordinate to move to. + internal InternalComputerActionMove(ComputerActionType @type, IDictionary additionalBinaryDataProperties, int x, int y) : base(@type, additionalBinaryDataProperties) + { + X = x; + Y = y; + } + + /// The x-coordinate to move to. + public int X { get; } + + /// The y-coordinate to move to. + public int Y { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionScreenshot.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionScreenshot.Serialization.cs new file mode 100644 index 000000000000..4bcabdeba347 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionScreenshot.Serialization.cs @@ -0,0 +1,118 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalComputerActionScreenshot : InternalComputerAction, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionScreenshot)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerActionScreenshot IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerActionScreenshot)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalComputerAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionScreenshot)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerActionScreenshot(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerActionScreenshot DeserializeInternalComputerActionScreenshot(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComputerActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToComputerActionType(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerActionScreenshot(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerActionScreenshot)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerActionScreenshot IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerActionScreenshot)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalComputerAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerActionScreenshot(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerActionScreenshot)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionScreenshot.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionScreenshot.cs new file mode 100644 index 000000000000..844dbc5dc7b0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionScreenshot.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalComputerActionScreenshot : InternalComputerAction + { + /// Initializes a new instance of . + public InternalComputerActionScreenshot() : base(ComputerActionType.Screenshot) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalComputerActionScreenshot(ComputerActionType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionScroll.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionScroll.Serialization.cs new file mode 100644 index 000000000000..64e9d0fcc865 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionScroll.Serialization.cs @@ -0,0 +1,161 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalComputerActionScroll : InternalComputerAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerActionScroll() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionScroll)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("x"u8); + writer.WriteNumberValue(X); + writer.WritePropertyName("y"u8); + writer.WriteNumberValue(Y); + writer.WritePropertyName("scroll_x"u8); + writer.WriteNumberValue(ScrollX); + writer.WritePropertyName("scroll_y"u8); + writer.WriteNumberValue(ScrollY); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerActionScroll IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerActionScroll)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalComputerAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionScroll)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerActionScroll(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerActionScroll DeserializeInternalComputerActionScroll(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComputerActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + int x = default; + int y = default; + int scrollX = default; + int scrollY = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToComputerActionType(); + continue; + } + if (prop.NameEquals("x"u8)) + { + x = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("y"u8)) + { + y = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("scroll_x"u8)) + { + scrollX = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("scroll_y"u8)) + { + scrollY = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerActionScroll( + @type, + additionalBinaryDataProperties, + x, + y, + scrollX, + scrollY); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerActionScroll)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerActionScroll IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerActionScroll)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalComputerAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerActionScroll(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerActionScroll)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionScroll.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionScroll.cs new file mode 100644 index 000000000000..2babaf589794 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionScroll.cs @@ -0,0 +1,52 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalComputerActionScroll : InternalComputerAction + { + /// Initializes a new instance of . + /// The x-coordinate where the scroll occurred. + /// The y-coordinate where the scroll occurred. + /// The horizontal scroll distance. + /// The vertical scroll distance. + public InternalComputerActionScroll(int x, int y, int scrollX, int scrollY) : base(ComputerActionType.Scroll) + { + X = x; + Y = y; + ScrollX = scrollX; + ScrollY = scrollY; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The x-coordinate where the scroll occurred. + /// The y-coordinate where the scroll occurred. + /// The horizontal scroll distance. + /// The vertical scroll distance. + internal InternalComputerActionScroll(ComputerActionType @type, IDictionary additionalBinaryDataProperties, int x, int y, int scrollX, int scrollY) : base(@type, additionalBinaryDataProperties) + { + X = x; + Y = y; + ScrollX = scrollX; + ScrollY = scrollY; + } + + /// The x-coordinate where the scroll occurred. + public int X { get; } + + /// The y-coordinate where the scroll occurred. + public int Y { get; } + + /// The horizontal scroll distance. + public int ScrollX { get; } + + /// The vertical scroll distance. + public int ScrollY { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionTypeKeys.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionTypeKeys.Serialization.cs new file mode 100644 index 000000000000..52d8aeaa5582 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionTypeKeys.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalComputerActionTypeKeys : InternalComputerAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerActionTypeKeys() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionTypeKeys)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerActionTypeKeys IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerActionTypeKeys)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalComputerAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionTypeKeys)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerActionTypeKeys(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerActionTypeKeys DeserializeInternalComputerActionTypeKeys(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComputerActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string text = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToComputerActionType(); + continue; + } + if (prop.NameEquals("text"u8)) + { + text = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerActionTypeKeys(@type, additionalBinaryDataProperties, text); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerActionTypeKeys)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerActionTypeKeys IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerActionTypeKeys)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalComputerAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerActionTypeKeys(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerActionTypeKeys)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionTypeKeys.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionTypeKeys.cs new file mode 100644 index 000000000000..a802b90ef1b1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionTypeKeys.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalComputerActionTypeKeys : InternalComputerAction + { + /// Initializes a new instance of . + /// The text to type. + /// is null. + public InternalComputerActionTypeKeys(string text) : base(ComputerActionType.Type) + { + Argument.AssertNotNull(text, nameof(text)); + + Text = text; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The text to type. + internal InternalComputerActionTypeKeys(ComputerActionType @type, IDictionary additionalBinaryDataProperties, string text) : base(@type, additionalBinaryDataProperties) + { + Text = text; + } + + /// The text to type. + public string Text { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionWait.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionWait.Serialization.cs new file mode 100644 index 000000000000..3418cf544c75 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionWait.Serialization.cs @@ -0,0 +1,118 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalComputerActionWait : InternalComputerAction, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionWait)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerActionWait IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerActionWait)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalComputerAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerActionWait)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerActionWait(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerActionWait DeserializeInternalComputerActionWait(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComputerActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToComputerActionType(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerActionWait(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerActionWait)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerActionWait IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerActionWait)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalComputerAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerActionWait(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerActionWait)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionWait.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionWait.cs new file mode 100644 index 000000000000..f465b777fdc1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerActionWait.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalComputerActionWait : InternalComputerAction + { + /// Initializes a new instance of . + public InternalComputerActionWait() : base(ComputerActionType.Wait) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalComputerActionWait(ComputerActionType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallItemParam.Serialization.cs new file mode 100644 index 000000000000..147a0dc5e133 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallItemParam.Serialization.cs @@ -0,0 +1,157 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalComputerToolCallItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerToolCallItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("call_id"u8); + writer.WriteStringValue(CallId); + writer.WritePropertyName("action"u8); + writer.WriteObjectValue(Action, options); + writer.WritePropertyName("pending_safety_checks"u8); + writer.WriteStartArray(); + foreach (InternalComputerToolCallSafetyCheck item in PendingSafetyChecks) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerToolCallItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerToolCallItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerToolCallItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerToolCallItemParam DeserializeInternalComputerToolCallItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string callId = default; + InternalComputerAction action = default; + IList pendingSafetyChecks = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ItemType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("call_id"u8)) + { + callId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("action"u8)) + { + action = InternalComputerAction.DeserializeInternalComputerAction(prop.Value, options); + continue; + } + if (prop.NameEquals("pending_safety_checks"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalComputerToolCallSafetyCheck.DeserializeInternalComputerToolCallSafetyCheck(item, options)); + } + pendingSafetyChecks = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerToolCallItemParam(@type, additionalBinaryDataProperties, callId, action, pendingSafetyChecks); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerToolCallItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerToolCallItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerToolCallItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallItemParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallItemParam.cs new file mode 100644 index 000000000000..ca8b7f2f0f23 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallItemParam.cs @@ -0,0 +1,52 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalComputerToolCallItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// An identifier used when responding to the tool call with output. + /// + /// The pending safety checks for the computer call. + /// , or is null. + public InternalComputerToolCallItemParam(string callId, InternalComputerAction action, IEnumerable pendingSafetyChecks) : base(ItemType.ComputerCall) + { + Argument.AssertNotNull(callId, nameof(callId)); + Argument.AssertNotNull(action, nameof(action)); + Argument.AssertNotNull(pendingSafetyChecks, nameof(pendingSafetyChecks)); + + CallId = callId; + Action = action; + PendingSafetyChecks = pendingSafetyChecks.ToList(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// An identifier used when responding to the tool call with output. + /// + /// The pending safety checks for the computer call. + internal InternalComputerToolCallItemParam(ItemType @type, IDictionary additionalBinaryDataProperties, string callId, InternalComputerAction action, IList pendingSafetyChecks) : base(@type, additionalBinaryDataProperties) + { + CallId = callId; + Action = action; + PendingSafetyChecks = pendingSafetyChecks; + } + + /// An identifier used when responding to the tool call with output. + public string CallId { get; } + + /// Gets the Action. + public InternalComputerAction Action { get; } + + /// The pending safety checks for the computer call. + public IList PendingSafetyChecks { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallOutputItemOutput.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallOutputItemOutput.Serialization.cs new file mode 100644 index 000000000000..794b781be566 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallOutputItemOutput.Serialization.cs @@ -0,0 +1,133 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + [PersistableModelProxy(typeof(UnknownComputerToolCallOutputItemOutput))] + internal abstract partial class InternalComputerToolCallOutputItemOutput : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerToolCallOutputItemOutput() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemOutput)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerToolCallOutputItemOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalComputerToolCallOutputItemOutput JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemOutput)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerToolCallOutputItemOutput(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerToolCallOutputItemOutput DeserializeInternalComputerToolCallOutputItemOutput(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "computer_screenshot": + return InternalComputerToolCallOutputItemOutputComputerScreenshot.DeserializeInternalComputerToolCallOutputItemOutputComputerScreenshot(element, options); + } + } + return UnknownComputerToolCallOutputItemOutput.DeserializeUnknownComputerToolCallOutputItemOutput(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemOutput)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerToolCallOutputItemOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalComputerToolCallOutputItemOutput PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerToolCallOutputItemOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemOutput)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallOutputItemOutput.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallOutputItemOutput.cs new file mode 100644 index 000000000000..31524a00f895 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallOutputItemOutput.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal abstract partial class InternalComputerToolCallOutputItemOutput + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + private protected InternalComputerToolCallOutputItemOutput(ComputerToolCallOutputItemOutputType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalComputerToolCallOutputItemOutput(ComputerToolCallOutputItemOutputType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Type. + internal ComputerToolCallOutputItemOutputType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallOutputItemOutputComputerScreenshot.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallOutputItemOutputComputerScreenshot.Serialization.cs new file mode 100644 index 000000000000..6af82cc1694d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallOutputItemOutputComputerScreenshot.Serialization.cs @@ -0,0 +1,140 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalComputerToolCallOutputItemOutputComputerScreenshot : InternalComputerToolCallOutputItemOutput, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemOutputComputerScreenshot)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(ImageUrl)) + { + writer.WritePropertyName("image_url"u8); + writer.WriteStringValue(ImageUrl); + } + if (Optional.IsDefined(FileId)) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerToolCallOutputItemOutputComputerScreenshot IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerToolCallOutputItemOutputComputerScreenshot)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalComputerToolCallOutputItemOutput JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemOutputComputerScreenshot)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerToolCallOutputItemOutputComputerScreenshot(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerToolCallOutputItemOutputComputerScreenshot DeserializeInternalComputerToolCallOutputItemOutputComputerScreenshot(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComputerToolCallOutputItemOutputType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string imageUrl = default; + string fileId = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ComputerToolCallOutputItemOutputType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("image_url"u8)) + { + imageUrl = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("file_id"u8)) + { + fileId = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerToolCallOutputItemOutputComputerScreenshot(@type, additionalBinaryDataProperties, imageUrl, fileId); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemOutputComputerScreenshot)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerToolCallOutputItemOutputComputerScreenshot IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerToolCallOutputItemOutputComputerScreenshot)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalComputerToolCallOutputItemOutput PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerToolCallOutputItemOutputComputerScreenshot(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemOutputComputerScreenshot)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallOutputItemOutputComputerScreenshot.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallOutputItemOutputComputerScreenshot.cs new file mode 100644 index 000000000000..4ef6b0c3511c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallOutputItemOutputComputerScreenshot.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalComputerToolCallOutputItemOutputComputerScreenshot : InternalComputerToolCallOutputItemOutput + { + /// Initializes a new instance of . + public InternalComputerToolCallOutputItemOutputComputerScreenshot() : base(ComputerToolCallOutputItemOutputType.Screenshot) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// + /// + internal InternalComputerToolCallOutputItemOutputComputerScreenshot(ComputerToolCallOutputItemOutputType @type, IDictionary additionalBinaryDataProperties, string imageUrl, string fileId) : base(@type, additionalBinaryDataProperties) + { + ImageUrl = imageUrl; + FileId = fileId; + } + + /// Gets or sets the ImageUrl. + public string ImageUrl { get; set; } + + /// Gets or sets the FileId. + public string FileId { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallOutputItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallOutputItemParam.Serialization.cs new file mode 100644 index 000000000000..c94a6b7e2268 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallOutputItemParam.Serialization.cs @@ -0,0 +1,164 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalComputerToolCallOutputItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerToolCallOutputItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("call_id"u8); + writer.WriteStringValue(CallId); + if (Optional.IsCollectionDefined(AcknowledgedSafetyChecks)) + { + writer.WritePropertyName("acknowledged_safety_checks"u8); + writer.WriteStartArray(); + foreach (InternalComputerToolCallSafetyCheck item in AcknowledgedSafetyChecks) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + writer.WritePropertyName("output"u8); + writer.WriteObjectValue(Output, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerToolCallOutputItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerToolCallOutputItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerToolCallOutputItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerToolCallOutputItemParam DeserializeInternalComputerToolCallOutputItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string callId = default; + IList acknowledgedSafetyChecks = default; + InternalComputerToolCallOutputItemOutput output = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ItemType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("call_id"u8)) + { + callId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("acknowledged_safety_checks"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalComputerToolCallSafetyCheck.DeserializeInternalComputerToolCallSafetyCheck(item, options)); + } + acknowledgedSafetyChecks = array; + continue; + } + if (prop.NameEquals("output"u8)) + { + output = InternalComputerToolCallOutputItemOutput.DeserializeInternalComputerToolCallOutputItemOutput(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerToolCallOutputItemParam(@type, additionalBinaryDataProperties, callId, acknowledgedSafetyChecks ?? new ChangeTrackingList(), output); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerToolCallOutputItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerToolCallOutputItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerToolCallOutputItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallOutputItemParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallOutputItemParam.cs new file mode 100644 index 000000000000..e630c42744d1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallOutputItemParam.cs @@ -0,0 +1,55 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalComputerToolCallOutputItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The ID of the computer tool call that produced the output. + /// + /// or is null. + public InternalComputerToolCallOutputItemParam(string callId, InternalComputerToolCallOutputItemOutput output) : base(ItemType.ComputerCallOutput) + { + Argument.AssertNotNull(callId, nameof(callId)); + Argument.AssertNotNull(output, nameof(output)); + + CallId = callId; + AcknowledgedSafetyChecks = new ChangeTrackingList(); + Output = output; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The ID of the computer tool call that produced the output. + /// + /// The safety checks reported by the API that have been acknowledged by the + /// developer. + /// + /// + internal InternalComputerToolCallOutputItemParam(ItemType @type, IDictionary additionalBinaryDataProperties, string callId, IList acknowledgedSafetyChecks, InternalComputerToolCallOutputItemOutput output) : base(@type, additionalBinaryDataProperties) + { + CallId = callId; + AcknowledgedSafetyChecks = acknowledgedSafetyChecks; + Output = output; + } + + /// The ID of the computer tool call that produced the output. + public string CallId { get; } + + /// + /// The safety checks reported by the API that have been acknowledged by the + /// developer. + /// + public IList AcknowledgedSafetyChecks { get; } + + /// Gets the Output. + public InternalComputerToolCallOutputItemOutput Output { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallSafetyCheck.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallSafetyCheck.Serialization.cs new file mode 100644 index 000000000000..04fd6da4c10f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallSafetyCheck.Serialization.cs @@ -0,0 +1,155 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalComputerToolCallSafetyCheck : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerToolCallSafetyCheck() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallSafetyCheck)} does not support writing '{format}' format."); + } + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code); + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerToolCallSafetyCheck IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalComputerToolCallSafetyCheck JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallSafetyCheck)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerToolCallSafetyCheck(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerToolCallSafetyCheck DeserializeInternalComputerToolCallSafetyCheck(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string code = default; + string message = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("code"u8)) + { + code = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("message"u8)) + { + message = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerToolCallSafetyCheck(id, code, message, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallSafetyCheck)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerToolCallSafetyCheck IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalComputerToolCallSafetyCheck PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerToolCallSafetyCheck(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallSafetyCheck)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallSafetyCheck.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallSafetyCheck.cs new file mode 100644 index 000000000000..02fee24bc262 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerToolCallSafetyCheck.cs @@ -0,0 +1,54 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalComputerToolCallSafetyCheck + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The ID of the pending safety check. + /// The type of the pending safety check. + /// Details about the pending safety check. + /// , or is null. + public InternalComputerToolCallSafetyCheck(string id, string code, string message) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(code, nameof(code)); + Argument.AssertNotNull(message, nameof(message)); + + Id = id; + Code = code; + Message = message; + } + + /// Initializes a new instance of . + /// The ID of the pending safety check. + /// The type of the pending safety check. + /// Details about the pending safety check. + /// Keeps track of any properties unknown to the library. + internal InternalComputerToolCallSafetyCheck(string id, string code, string message, IDictionary additionalBinaryDataProperties) + { + Id = id; + Code = code; + Message = message; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The ID of the pending safety check. + public string Id { get; } + + /// The type of the pending safety check. + public string Code { get; } + + /// Details about the pending safety check. + public string Message { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerUsePreviewTool.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerUsePreviewTool.Serialization.cs new file mode 100644 index 000000000000..2a6005e133a2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerUsePreviewTool.Serialization.cs @@ -0,0 +1,147 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalComputerUsePreviewTool : InternalTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalComputerUsePreviewTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerUsePreviewTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("environment"u8); + writer.WriteStringValue(Environment.ToString()); + writer.WritePropertyName("display_width"u8); + writer.WriteNumberValue(DisplayWidth); + writer.WritePropertyName("display_height"u8); + writer.WriteNumberValue(DisplayHeight); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerUsePreviewTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalComputerUsePreviewTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerUsePreviewTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerUsePreviewTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalComputerUsePreviewTool DeserializeInternalComputerUsePreviewTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ComputerUsePreviewToolEnvironment environment = default; + int displayWidth = default; + int displayHeight = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("environment"u8)) + { + environment = new ComputerUsePreviewToolEnvironment(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("display_width"u8)) + { + displayWidth = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("display_height"u8)) + { + displayHeight = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalComputerUsePreviewTool(@type, additionalBinaryDataProperties, environment, displayWidth, displayHeight); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerUsePreviewTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerUsePreviewTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalComputerUsePreviewTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerUsePreviewTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerUsePreviewTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerUsePreviewTool.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerUsePreviewTool.cs new file mode 100644 index 000000000000..52af25f8cd9a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalComputerUsePreviewTool.cs @@ -0,0 +1,46 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalComputerUsePreviewTool : InternalTool + { + /// Initializes a new instance of . + /// The type of computer environment to control. + /// The width of the computer display. + /// The height of the computer display. + public InternalComputerUsePreviewTool(ComputerUsePreviewToolEnvironment environment, int displayWidth, int displayHeight) : base(ToolType.ComputerUsePreview) + { + Environment = environment; + DisplayWidth = displayWidth; + DisplayHeight = displayHeight; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The type of computer environment to control. + /// The width of the computer display. + /// The height of the computer display. + internal InternalComputerUsePreviewTool(ToolType @type, IDictionary additionalBinaryDataProperties, ComputerUsePreviewToolEnvironment environment, int displayWidth, int displayHeight) : base(@type, additionalBinaryDataProperties) + { + Environment = environment; + DisplayWidth = displayWidth; + DisplayHeight = displayHeight; + } + + /// The type of computer environment to control. + public ComputerUsePreviewToolEnvironment Environment { get; set; } + + /// The width of the computer display. + public int DisplayWidth { get; set; } + + /// The height of the computer display. + public int DisplayHeight { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalCoordinate.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCoordinate.Serialization.cs new file mode 100644 index 000000000000..0764393439a0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCoordinate.Serialization.cs @@ -0,0 +1,147 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalCoordinate : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalCoordinate() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCoordinate)} does not support writing '{format}' format."); + } + writer.WritePropertyName("x"u8); + writer.WriteNumberValue(X); + writer.WritePropertyName("y"u8); + writer.WriteNumberValue(Y); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalCoordinate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalCoordinate JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCoordinate)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCoordinate(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalCoordinate DeserializeInternalCoordinate(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int x = default; + int y = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("x"u8)) + { + x = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("y"u8)) + { + y = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalCoordinate(x, y, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalCoordinate)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalCoordinate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalCoordinate PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalCoordinate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCoordinate)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalCoordinate.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCoordinate.cs new file mode 100644 index 000000000000..57ffeb0aa353 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCoordinate.cs @@ -0,0 +1,41 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalCoordinate + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The x-coordinate. + /// The y-coordinate. + public InternalCoordinate(int x, int y) + { + X = x; + Y = y; + } + + /// Initializes a new instance of . + /// The x-coordinate. + /// The y-coordinate. + /// Keeps track of any properties unknown to the library. + internal InternalCoordinate(int x, int y, IDictionary additionalBinaryDataProperties) + { + X = x; + Y = y; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The x-coordinate. + public int X { get; } + + /// The y-coordinate. + public int Y { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalCreateAgentRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCreateAgentRequest.Serialization.cs new file mode 100644 index 000000000000..0b022ba2e78a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCreateAgentRequest.Serialization.cs @@ -0,0 +1,195 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + internal partial class InternalCreateAgentRequest : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalCreateAgentRequest() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCreateAgentRequest)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("definition"u8); + writer.WriteObjectValue(Definition, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalCreateAgentRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalCreateAgentRequest JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCreateAgentRequest)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateAgentRequest(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalCreateAgentRequest DeserializeInternalCreateAgentRequest(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + IDictionary metadata = default; + string description = default; + Projects.OpenAI.AgentDefinition definition = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("metadata"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + metadata = dictionary; + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("definition"u8)) + { + DeserializeDefinitionValue(prop, ref definition); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalCreateAgentRequest(name, metadata ?? new ChangeTrackingDictionary(), description, definition, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalCreateAgentRequest)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalCreateAgentRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalCreateAgentRequest PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalCreateAgentRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateAgentRequest)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalCreateAgentRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCreateAgentRequest.cs new file mode 100644 index 000000000000..0dd3179ed907 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCreateAgentRequest.cs @@ -0,0 +1,82 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + internal partial class InternalCreateAgentRequest + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// The unique name that identifies the agent. Name can be used to retrieve/update/delete the agent. + /// - Must start and end with alphanumeric characters, + /// - Can contain hyphens in the middle + /// - Must not exceed 63 characters. + /// + /// The agent definition. This can be a workflow, hosted agent, or a simple agent definition. + /// or is null. + public InternalCreateAgentRequest(string name, Projects.OpenAI.AgentDefinition definition) + { + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(definition, nameof(definition)); + + Name = name; + Metadata = new ChangeTrackingDictionary(); + Definition = definition; + } + + /// Initializes a new instance of . + /// + /// The unique name that identifies the agent. Name can be used to retrieve/update/delete the agent. + /// - Must start and end with alphanumeric characters, + /// - Can contain hyphens in the middle + /// - Must not exceed 63 characters. + /// + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + /// A human-readable description of the agent. + /// The agent definition. This can be a workflow, hosted agent, or a simple agent definition. + /// Keeps track of any properties unknown to the library. + internal InternalCreateAgentRequest(string name, IDictionary metadata, string description, Projects.OpenAI.AgentDefinition definition, IDictionary additionalBinaryDataProperties) + { + Name = name; + Metadata = metadata; + Description = description; + Definition = definition; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// The unique name that identifies the agent. Name can be used to retrieve/update/delete the agent. + /// - Must start and end with alphanumeric characters, + /// - Can contain hyphens in the middle + /// - Must not exceed 63 characters. + /// + public string Name { get; } + + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + public IDictionary Metadata { get; } + + /// A human-readable description of the agent. + public string Description { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalCreateMemoryStoreRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCreateMemoryStoreRequest.Serialization.cs new file mode 100644 index 000000000000..c93b2a2740e2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCreateMemoryStoreRequest.Serialization.cs @@ -0,0 +1,206 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + internal partial class InternalCreateMemoryStoreRequest : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalCreateMemoryStoreRequest() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCreateMemoryStoreRequest)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("definition"u8); + writer.WriteObjectValue(Definition, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalCreateMemoryStoreRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalCreateMemoryStoreRequest JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCreateMemoryStoreRequest)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCreateMemoryStoreRequest(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalCreateMemoryStoreRequest DeserializeInternalCreateMemoryStoreRequest(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string description = default; + IDictionary metadata = default; + MemoryStoreDefinition definition = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("metadata"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + metadata = dictionary; + continue; + } + if (prop.NameEquals("definition"u8)) + { + definition = MemoryStoreDefinition.DeserializeMemoryStoreDefinition(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalCreateMemoryStoreRequest(name, description, metadata ?? new ChangeTrackingDictionary(), definition, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalCreateMemoryStoreRequest)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalCreateMemoryStoreRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalCreateMemoryStoreRequest PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalCreateMemoryStoreRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCreateMemoryStoreRequest)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(InternalCreateMemoryStoreRequest internalCreateMemoryStoreRequest) + { + if (internalCreateMemoryStoreRequest == null) + { + return null; + } + return BinaryContent.Create(internalCreateMemoryStoreRequest, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalCreateMemoryStoreRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCreateMemoryStoreRequest.cs new file mode 100644 index 000000000000..a675f94c29be --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalCreateMemoryStoreRequest.cs @@ -0,0 +1,37 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + internal partial class InternalCreateMemoryStoreRequest + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The name of the memory store. + /// The memory store definition. + internal InternalCreateMemoryStoreRequest(string name, MemoryStoreDefinition definition) + { + Name = name; + Metadata = new ChangeTrackingDictionary(); + Definition = definition; + } + + /// The name of the memory store. + public string Name { get; } + + /// A human-readable description of the memory store. + public string Description { get; } + + /// Arbitrary key-value metadata to associate with the memory store. + public IDictionary Metadata { get; } + + /// The memory store definition. + public MemoryStoreDefinition Definition { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileSearchTool.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileSearchTool.Serialization.cs new file mode 100644 index 000000000000..bc03d9749867 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileSearchTool.Serialization.cs @@ -0,0 +1,212 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalFileSearchTool : InternalTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalFileSearchTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFileSearchTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("vector_store_ids"u8); + writer.WriteStartArray(); + foreach (string item in VectorStoreIds) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + if (Optional.IsDefined(MaxNumResults)) + { + writer.WritePropertyName("max_num_results"u8); + writer.WriteNumberValue(MaxNumResults.Value); + } + if (Optional.IsDefined(RankingOptions)) + { + writer.WritePropertyName("ranking_options"u8); + writer.WriteObjectValue(RankingOptions, options); + } + if (Optional.IsDefined(Filters)) + { + writer.WritePropertyName("filters"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Filters); +#else + using (JsonDocument document = JsonDocument.Parse(Filters)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalFileSearchTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalFileSearchTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFileSearchTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFileSearchTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalFileSearchTool DeserializeInternalFileSearchTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList vectorStoreIds = default; + int? maxNumResults = default; + InternalRankingOptions rankingOptions = default; + BinaryData filters = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("vector_store_ids"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + vectorStoreIds = array; + continue; + } + if (prop.NameEquals("max_num_results"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxNumResults = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("ranking_options"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + rankingOptions = InternalRankingOptions.DeserializeInternalRankingOptions(prop.Value, options); + continue; + } + if (prop.NameEquals("filters"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + filters = null; + continue; + } + filters = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalFileSearchTool( + @type, + additionalBinaryDataProperties, + vectorStoreIds, + maxNumResults, + rankingOptions, + filters); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalFileSearchTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalFileSearchTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalFileSearchTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalFileSearchTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFileSearchTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileSearchTool.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileSearchTool.cs new file mode 100644 index 000000000000..be3b76beae25 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileSearchTool.cs @@ -0,0 +1,90 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalFileSearchTool : InternalTool + { + /// Initializes a new instance of . + /// The IDs of the vector stores to search. + /// is null. + public InternalFileSearchTool(IEnumerable vectorStoreIds) : base(ToolType.FileSearch) + { + Argument.AssertNotNull(vectorStoreIds, nameof(vectorStoreIds)); + + VectorStoreIds = vectorStoreIds.ToList(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The IDs of the vector stores to search. + /// The maximum number of results to return. This number should be between 1 and 50 inclusive. + /// Ranking options for search. + /// A filter to apply. + internal InternalFileSearchTool(ToolType @type, IDictionary additionalBinaryDataProperties, IList vectorStoreIds, int? maxNumResults, InternalRankingOptions rankingOptions, BinaryData filters) : base(@type, additionalBinaryDataProperties) + { + VectorStoreIds = vectorStoreIds; + MaxNumResults = maxNumResults; + RankingOptions = rankingOptions; + Filters = filters; + } + + /// The IDs of the vector stores to search. + public IList VectorStoreIds { get; } + + /// The maximum number of results to return. This number should be between 1 and 50 inclusive. + public int? MaxNumResults { get; set; } + + /// Ranking options for search. + public InternalRankingOptions RankingOptions { get; set; } + + /// + /// A filter to apply. + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// . + /// + /// + /// + /// + /// + /// 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" }. + /// + /// + /// + /// + public BinaryData Filters { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileSearchToolCallItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileSearchToolCallItemParam.Serialization.cs new file mode 100644 index 000000000000..a32957afdf12 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileSearchToolCallItemParam.Serialization.cs @@ -0,0 +1,178 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalFileSearchToolCallItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalFileSearchToolCallItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFileSearchToolCallItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("queries"u8); + writer.WriteStartArray(); + foreach (string item in Queries) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + if (Optional.IsCollectionDefined(Results)) + { + writer.WritePropertyName("results"u8); + writer.WriteStartArray(); + foreach (InternalFileSearchToolCallItemParamResult item in Results) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalFileSearchToolCallItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalFileSearchToolCallItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFileSearchToolCallItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFileSearchToolCallItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalFileSearchToolCallItemParam DeserializeInternalFileSearchToolCallItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList queries = default; + IList results = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ItemType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("queries"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + queries = array; + continue; + } + if (prop.NameEquals("results"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalFileSearchToolCallItemParamResult.DeserializeInternalFileSearchToolCallItemParamResult(item, options)); + } + results = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalFileSearchToolCallItemParam(@type, additionalBinaryDataProperties, queries, results ?? new ChangeTrackingList()); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalFileSearchToolCallItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalFileSearchToolCallItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalFileSearchToolCallItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalFileSearchToolCallItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFileSearchToolCallItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileSearchToolCallItemParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileSearchToolCallItemParam.cs new file mode 100644 index 000000000000..208fbde584ff --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileSearchToolCallItemParam.cs @@ -0,0 +1,42 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalFileSearchToolCallItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The queries used to search for files. + /// is null. + public InternalFileSearchToolCallItemParam(IEnumerable queries) : base(ItemType.FileSearchCall) + { + Argument.AssertNotNull(queries, nameof(queries)); + + Queries = queries.ToList(); + Results = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The queries used to search for files. + /// The results of the file search tool call. + internal InternalFileSearchToolCallItemParam(ItemType @type, IDictionary additionalBinaryDataProperties, IList queries, IList results) : base(@type, additionalBinaryDataProperties) + { + Queries = queries; + Results = results; + } + + /// The queries used to search for files. + public IList Queries { get; } + + /// The results of the file search tool call. + public IList Results { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileSearchToolCallItemParamResult.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileSearchToolCallItemParamResult.Serialization.cs new file mode 100644 index 000000000000..615fa035c4a6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileSearchToolCallItemParamResult.Serialization.cs @@ -0,0 +1,195 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalFileSearchToolCallItemParamResult : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFileSearchToolCallItemParamResult)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(FileId)) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + if (Optional.IsDefined(Text)) + { + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + if (Optional.IsDefined(Filename)) + { + writer.WritePropertyName("filename"u8); + writer.WriteStringValue(Filename); + } + if (Optional.IsDefined(Attributes)) + { + writer.WritePropertyName("attributes"u8); + writer.WriteObjectValue(Attributes, options); + } + if (Optional.IsDefined(Score)) + { + writer.WritePropertyName("score"u8); + writer.WriteNumberValue(Score.Value); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalFileSearchToolCallItemParamResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalFileSearchToolCallItemParamResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFileSearchToolCallItemParamResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFileSearchToolCallItemParamResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalFileSearchToolCallItemParamResult DeserializeInternalFileSearchToolCallItemParamResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + string text = default; + string filename = default; + InternalVectorStoreFileAttributes attributes = default; + float? score = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("file_id"u8)) + { + fileId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("text"u8)) + { + text = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("filename"u8)) + { + filename = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("attributes"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + attributes = InternalVectorStoreFileAttributes.DeserializeInternalVectorStoreFileAttributes(prop.Value, options); + continue; + } + if (prop.NameEquals("score"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + score = prop.Value.GetSingle(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalFileSearchToolCallItemParamResult( + fileId, + text, + filename, + attributes, + score, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalFileSearchToolCallItemParamResult)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalFileSearchToolCallItemParamResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalFileSearchToolCallItemParamResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalFileSearchToolCallItemParamResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFileSearchToolCallItemParamResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileSearchToolCallItemParamResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileSearchToolCallItemParamResult.cs new file mode 100644 index 000000000000..b2408da8496a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFileSearchToolCallItemParamResult.cs @@ -0,0 +1,52 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalFileSearchToolCallItemParamResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public InternalFileSearchToolCallItemParamResult() + { + } + + /// Initializes a new instance of . + /// The unique ID of the file. + /// The text that was retrieved from the file. + /// The name of the file. + /// + /// The relevance score of the file - a value between 0 and 1. + /// Keeps track of any properties unknown to the library. + internal InternalFileSearchToolCallItemParamResult(string fileId, string text, string filename, InternalVectorStoreFileAttributes attributes, float? score, IDictionary additionalBinaryDataProperties) + { + FileId = fileId; + Text = text; + Filename = filename; + Attributes = attributes; + Score = score; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The unique ID of the file. + public string FileId { get; set; } + + /// The text that was retrieved from the file. + public string Text { get; set; } + + /// The name of the file. + public string Filename { get; set; } + + /// Gets or sets the Attributes. + public InternalVectorStoreFileAttributes Attributes { get; set; } + + /// The relevance score of the file - a value between 0 and 1. + public float? Score { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalFunctionTool.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFunctionTool.Serialization.cs new file mode 100644 index 000000000000..bcc92660f1ac --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFunctionTool.Serialization.cs @@ -0,0 +1,200 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalFunctionTool : InternalTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalFunctionTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFunctionTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(Parameters)) + { + writer.WritePropertyName("parameters"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Parameters); +#else + using (JsonDocument document = JsonDocument.Parse(Parameters)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + else + { + writer.WriteNull("parameters"u8); + } + if (Optional.IsDefined(Strict)) + { + writer.WritePropertyName("strict"u8); + writer.WriteBooleanValue(Strict.Value); + } + else + { + writer.WriteNull("strict"u8); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalFunctionTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalFunctionTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFunctionTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFunctionTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalFunctionTool DeserializeInternalFunctionTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string name = default; + string description = default; + BinaryData parameters = default; + bool? strict = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("description"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + description = null; + continue; + } + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("parameters"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + parameters = null; + continue; + } + parameters = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("strict"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + strict = null; + continue; + } + strict = prop.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalFunctionTool( + @type, + additionalBinaryDataProperties, + name, + description, + parameters, + strict); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalFunctionTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalFunctionTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalFunctionTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalFunctionTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFunctionTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalFunctionTool.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFunctionTool.cs new file mode 100644 index 000000000000..ae08aa4a3010 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFunctionTool.cs @@ -0,0 +1,80 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalFunctionTool : InternalTool + { + /// Initializes a new instance of . + /// The name of the function to call. + /// A JSON schema object describing the parameters of the function. + /// Whether to enforce strict parameter validation. Default `true`. + /// is null. + public InternalFunctionTool(string name, BinaryData parameters, bool? strict) : base(ToolType.Function) + { + Argument.AssertNotNull(name, nameof(name)); + + Name = name; + Parameters = parameters; + Strict = strict; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The name of the function to call. + /// A description of the function. Used by the model to determine whether or not to call the function. + /// A JSON schema object describing the parameters of the function. + /// Whether to enforce strict parameter validation. Default `true`. + internal InternalFunctionTool(ToolType @type, IDictionary additionalBinaryDataProperties, string name, string description, BinaryData parameters, bool? strict) : base(@type, additionalBinaryDataProperties) + { + Name = name; + Description = description; + Parameters = parameters; + Strict = strict; + } + + /// The name of the function to call. + public string Name { get; set; } + + /// A description of the function. Used by the model to determine whether or not to call the function. + public string Description { get; set; } + + /// + /// A JSON schema object describing the parameters of the function. + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData Parameters { get; set; } + + /// Whether to enforce strict parameter validation. Default `true`. + public bool? Strict { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalFunctionToolCallItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFunctionToolCallItemParam.Serialization.cs new file mode 100644 index 000000000000..b37b681c1112 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFunctionToolCallItemParam.Serialization.cs @@ -0,0 +1,147 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalFunctionToolCallItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalFunctionToolCallItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFunctionToolCallItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("call_id"u8); + writer.WriteStringValue(CallId); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("arguments"u8); + writer.WriteStringValue(Arguments); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalFunctionToolCallItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalFunctionToolCallItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFunctionToolCallItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFunctionToolCallItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalFunctionToolCallItemParam DeserializeInternalFunctionToolCallItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string callId = default; + string name = default; + string arguments = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ItemType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("call_id"u8)) + { + callId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("arguments"u8)) + { + arguments = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalFunctionToolCallItemParam(@type, additionalBinaryDataProperties, callId, name, arguments); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalFunctionToolCallItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalFunctionToolCallItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalFunctionToolCallItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalFunctionToolCallItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFunctionToolCallItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalFunctionToolCallItemParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFunctionToolCallItemParam.cs new file mode 100644 index 000000000000..9790c2eedeb4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFunctionToolCallItemParam.cs @@ -0,0 +1,51 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalFunctionToolCallItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The unique ID of the function tool call generated by the model. + /// The name of the function to run. + /// A JSON string of the arguments to pass to the function. + /// , or is null. + public InternalFunctionToolCallItemParam(string callId, string name, string arguments) : base(ItemType.FunctionCall) + { + Argument.AssertNotNull(callId, nameof(callId)); + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(arguments, nameof(arguments)); + + CallId = callId; + Name = name; + Arguments = arguments; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The unique ID of the function tool call generated by the model. + /// The name of the function to run. + /// A JSON string of the arguments to pass to the function. + internal InternalFunctionToolCallItemParam(ItemType @type, IDictionary additionalBinaryDataProperties, string callId, string name, string arguments) : base(@type, additionalBinaryDataProperties) + { + CallId = callId; + Name = name; + Arguments = arguments; + } + + /// The unique ID of the function tool call generated by the model. + public string CallId { get; } + + /// The name of the function to run. + public string Name { get; } + + /// A JSON string of the arguments to pass to the function. + public string Arguments { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalFunctionToolCallOutputItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFunctionToolCallOutputItemParam.Serialization.cs new file mode 100644 index 000000000000..710a0411fe71 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFunctionToolCallOutputItemParam.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalFunctionToolCallOutputItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalFunctionToolCallOutputItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFunctionToolCallOutputItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("call_id"u8); + writer.WriteStringValue(CallId); + writer.WritePropertyName("output"u8); + writer.WriteStringValue(Output); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalFunctionToolCallOutputItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalFunctionToolCallOutputItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalFunctionToolCallOutputItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalFunctionToolCallOutputItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalFunctionToolCallOutputItemParam DeserializeInternalFunctionToolCallOutputItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string callId = default; + string output = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ItemType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("call_id"u8)) + { + callId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("output"u8)) + { + output = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalFunctionToolCallOutputItemParam(@type, additionalBinaryDataProperties, callId, output); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalFunctionToolCallOutputItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalFunctionToolCallOutputItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalFunctionToolCallOutputItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalFunctionToolCallOutputItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalFunctionToolCallOutputItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalFunctionToolCallOutputItemParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFunctionToolCallOutputItemParam.cs new file mode 100644 index 000000000000..1a28fd899b7e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalFunctionToolCallOutputItemParam.cs @@ -0,0 +1,43 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalFunctionToolCallOutputItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The unique ID of the function tool call generated by the model. + /// A JSON string of the output of the function tool call. + /// or is null. + public InternalFunctionToolCallOutputItemParam(string callId, string output) : base(ItemType.FunctionCallOutput) + { + Argument.AssertNotNull(callId, nameof(callId)); + Argument.AssertNotNull(output, nameof(output)); + + CallId = callId; + Output = output; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The unique ID of the function tool call generated by the model. + /// A JSON string of the output of the function tool call. + internal InternalFunctionToolCallOutputItemParam(ItemType @type, IDictionary additionalBinaryDataProperties, string callId, string output) : base(@type, additionalBinaryDataProperties) + { + CallId = callId; + Output = output; + } + + /// The unique ID of the function tool call generated by the model. + public string CallId { get; } + + /// A JSON string of the output of the function tool call. + public string Output { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalImageGenTool.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalImageGenTool.Serialization.cs new file mode 100644 index 000000000000..2a6d1fe0ba8a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalImageGenTool.Serialization.cs @@ -0,0 +1,264 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalImageGenTool : InternalTool, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalImageGenTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Model)) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model.Value.ToString()); + } + if (Optional.IsDefined(Quality)) + { + writer.WritePropertyName("quality"u8); + writer.WriteStringValue(Quality.Value.ToString()); + } + if (Optional.IsDefined(Size)) + { + writer.WritePropertyName("size"u8); + writer.WriteStringValue(Size.Value.ToString()); + } + if (Optional.IsDefined(OutputFormat)) + { + writer.WritePropertyName("output_format"u8); + writer.WriteStringValue(OutputFormat.Value.ToString()); + } + if (Optional.IsDefined(OutputCompression)) + { + writer.WritePropertyName("output_compression"u8); + writer.WriteNumberValue(OutputCompression.Value); + } + if (Optional.IsDefined(Moderation)) + { + writer.WritePropertyName("moderation"u8); + writer.WriteStringValue(Moderation.Value.ToString()); + } + if (Optional.IsDefined(Background)) + { + writer.WritePropertyName("background"u8); + writer.WriteStringValue(Background.Value.ToString()); + } + if (Optional.IsDefined(InputImageMask)) + { + writer.WritePropertyName("input_image_mask"u8); + writer.WriteObjectValue(InputImageMask, options); + } + if (Optional.IsDefined(PartialImages)) + { + writer.WritePropertyName("partial_images"u8); + writer.WriteNumberValue(PartialImages.Value); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalImageGenTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalImageGenTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalImageGenTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalImageGenTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalImageGenTool DeserializeInternalImageGenTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ImageGenToolModel? model = default; + ImageGenToolQuality? quality = default; + ImageGenToolSize? size = default; + ImageGenToolOutputFormat? outputFormat = default; + int? outputCompression = default; + ImageGenToolModeration? moderation = default; + ImageGenToolBackground? background = default; + InternalImageGenToolInputImageMask inputImageMask = default; + int? partialImages = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("model"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + model = new ImageGenToolModel(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("quality"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + quality = new ImageGenToolQuality(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("size"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + size = new ImageGenToolSize(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("output_format"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + outputFormat = new ImageGenToolOutputFormat(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("output_compression"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + outputCompression = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("moderation"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + moderation = new ImageGenToolModeration(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("background"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + background = new ImageGenToolBackground(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("input_image_mask"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + inputImageMask = InternalImageGenToolInputImageMask.DeserializeInternalImageGenToolInputImageMask(prop.Value, options); + continue; + } + if (prop.NameEquals("partial_images"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + partialImages = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalImageGenTool( + @type, + additionalBinaryDataProperties, + model, + quality, + size, + outputFormat, + outputCompression, + moderation, + background, + inputImageMask, + partialImages); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalImageGenTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalImageGenTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalImageGenTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalImageGenTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalImageGenTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalImageGenTool.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalImageGenTool.cs new file mode 100644 index 000000000000..086638c02772 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalImageGenTool.cs @@ -0,0 +1,100 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalImageGenTool : InternalTool + { + /// Initializes a new instance of . + public InternalImageGenTool() : base(ToolType.ImageGeneration) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The image generation model to use. Default: `gpt-image-1`. + /// + /// The quality of the generated image. One of `low`, `medium`, `high`, + /// or `auto`. Default: `auto`. + /// + /// + /// The size of the generated image. One of `1024x1024`, `1024x1536`, + /// `1536x1024`, or `auto`. Default: `auto`. + /// + /// + /// The output format of the generated image. One of `png`, `webp`, or + /// `jpeg`. Default: `png`. + /// + /// Compression level for the output image. Default: 100. + /// Moderation level for the generated image. Default: `auto`. + /// + /// Background type for the generated image. One of `transparent`, + /// `opaque`, or `auto`. Default: `auto`. + /// + /// + /// Optional mask for inpainting. Contains `image_url` + /// (string, optional) and `file_id` (string, optional). + /// + /// Number of partial images to generate in streaming mode, from 0 (default value) to 3. + internal InternalImageGenTool(ToolType @type, IDictionary additionalBinaryDataProperties, ImageGenToolModel? model, ImageGenToolQuality? quality, ImageGenToolSize? size, ImageGenToolOutputFormat? outputFormat, int? outputCompression, ImageGenToolModeration? moderation, ImageGenToolBackground? background, InternalImageGenToolInputImageMask inputImageMask, int? partialImages) : base(@type, additionalBinaryDataProperties) + { + Model = model; + Quality = quality; + Size = size; + OutputFormat = outputFormat; + OutputCompression = outputCompression; + Moderation = moderation; + Background = background; + InputImageMask = inputImageMask; + PartialImages = partialImages; + } + + /// The image generation model to use. Default: `gpt-image-1`. + public ImageGenToolModel? Model { get; set; } + + /// + /// The quality of the generated image. One of `low`, `medium`, `high`, + /// or `auto`. Default: `auto`. + /// + public ImageGenToolQuality? Quality { get; set; } + + /// + /// The size of the generated image. One of `1024x1024`, `1024x1536`, + /// `1536x1024`, or `auto`. Default: `auto`. + /// + public ImageGenToolSize? Size { get; set; } + + /// + /// The output format of the generated image. One of `png`, `webp`, or + /// `jpeg`. Default: `png`. + /// + public ImageGenToolOutputFormat? OutputFormat { get; set; } + + /// Compression level for the output image. Default: 100. + public int? OutputCompression { get; set; } + + /// Moderation level for the generated image. Default: `auto`. + public ImageGenToolModeration? Moderation { get; set; } + + /// + /// Background type for the generated image. One of `transparent`, + /// `opaque`, or `auto`. Default: `auto`. + /// + public ImageGenToolBackground? Background { get; set; } + + /// + /// Optional mask for inpainting. Contains `image_url` + /// (string, optional) and `file_id` (string, optional). + /// + public InternalImageGenToolInputImageMask InputImageMask { get; set; } + + /// Number of partial images to generate in streaming mode, from 0 (default value) to 3. + public int? PartialImages { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalImageGenToolCallItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalImageGenToolCallItemParam.Serialization.cs new file mode 100644 index 000000000000..a82d9fb653eb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalImageGenToolCallItemParam.Serialization.cs @@ -0,0 +1,143 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalImageGenToolCallItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalImageGenToolCallItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalImageGenToolCallItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Result)) + { + writer.WritePropertyName("result"u8); + writer.WriteStringValue(Result); + } + else + { + writer.WriteNull("result"u8); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalImageGenToolCallItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalImageGenToolCallItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalImageGenToolCallItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalImageGenToolCallItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalImageGenToolCallItemParam DeserializeInternalImageGenToolCallItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string result = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ItemType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("result"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + result = null; + continue; + } + result = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalImageGenToolCallItemParam(@type, additionalBinaryDataProperties, result); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalImageGenToolCallItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalImageGenToolCallItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalImageGenToolCallItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalImageGenToolCallItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalImageGenToolCallItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalImageGenToolCallItemParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalImageGenToolCallItemParam.cs new file mode 100644 index 000000000000..19359a268903 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalImageGenToolCallItemParam.cs @@ -0,0 +1,31 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalImageGenToolCallItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The generated image encoded in base64. + public InternalImageGenToolCallItemParam(string result) : base(ItemType.ImageGenerationCall) + { + Result = result; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The generated image encoded in base64. + internal InternalImageGenToolCallItemParam(ItemType @type, IDictionary additionalBinaryDataProperties, string result) : base(@type, additionalBinaryDataProperties) + { + Result = result; + } + + /// The generated image encoded in base64. + public string Result { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalImageGenToolInputImageMask.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalImageGenToolInputImageMask.Serialization.cs new file mode 100644 index 000000000000..8908d1f8ae2d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalImageGenToolInputImageMask.Serialization.cs @@ -0,0 +1,148 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalImageGenToolInputImageMask : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalImageGenToolInputImageMask)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(ImageUrl)) + { + writer.WritePropertyName("image_url"u8); + writer.WriteStringValue(ImageUrl); + } + if (Optional.IsDefined(FileId)) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalImageGenToolInputImageMask IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalImageGenToolInputImageMask JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalImageGenToolInputImageMask)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalImageGenToolInputImageMask(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalImageGenToolInputImageMask DeserializeInternalImageGenToolInputImageMask(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string imageUrl = default; + string fileId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("image_url"u8)) + { + imageUrl = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("file_id"u8)) + { + fileId = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalImageGenToolInputImageMask(imageUrl, fileId, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalImageGenToolInputImageMask)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalImageGenToolInputImageMask IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalImageGenToolInputImageMask PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalImageGenToolInputImageMask(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalImageGenToolInputImageMask)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalImageGenToolInputImageMask.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalImageGenToolInputImageMask.cs new file mode 100644 index 000000000000..d5139c3ce34c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalImageGenToolInputImageMask.cs @@ -0,0 +1,37 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalImageGenToolInputImageMask + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public InternalImageGenToolInputImageMask() + { + } + + /// Initializes a new instance of . + /// Base64-encoded mask image. + /// File ID for the mask image. + /// Keeps track of any properties unknown to the library. + internal InternalImageGenToolInputImageMask(string imageUrl, string fileId, IDictionary additionalBinaryDataProperties) + { + ImageUrl = imageUrl; + FileId = fileId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Base64-encoded mask image. + public string ImageUrl { get; set; } + + /// File ID for the mask image. + public string FileId { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContent.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContent.Serialization.cs new file mode 100644 index 000000000000..9e3dac0fd747 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContent.Serialization.cs @@ -0,0 +1,145 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + [PersistableModelProxy(typeof(UnknownItemContent))] + internal abstract partial class InternalItemContent : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalItemContent() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContent)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToSerialString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalItemContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalItemContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalItemContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalItemContent DeserializeInternalItemContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "input_text": + return InternalItemContentInputText.DeserializeInternalItemContentInputText(element, options); + case "input_audio": + return InternalItemContentInputAudio.DeserializeInternalItemContentInputAudio(element, options); + case "output_audio": + return InternalItemContentOutputAudio.DeserializeInternalItemContentOutputAudio(element, options); + case "refusal": + return InternalItemContentRefusal.DeserializeInternalItemContentRefusal(element, options); + case "input_image": + return InternalItemContentInputImage.DeserializeInternalItemContentInputImage(element, options); + case "input_file": + return InternalItemContentInputFile.DeserializeInternalItemContentInputFile(element, options); + case "output_text": + return InternalItemContentOutputText.DeserializeInternalItemContentOutputText(element, options); + } + } + return UnknownItemContent.DeserializeUnknownItemContent(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalItemContent)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalItemContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalItemContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalItemContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalItemContent)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContent.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContent.cs new file mode 100644 index 000000000000..cfc9a9ff0418 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContent.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal abstract partial class InternalItemContent + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + private protected InternalItemContent(ItemContentType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalItemContent(ItemContentType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Type. + internal ItemContentType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentInputAudio.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentInputAudio.Serialization.cs new file mode 100644 index 000000000000..f1a513ebc26c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentInputAudio.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalItemContentInputAudio : InternalItemContent, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalItemContentInputAudio() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentInputAudio)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("data"u8); + writer.WriteStringValue(Data); + writer.WritePropertyName("format"u8); + writer.WriteStringValue(Format.ToString()); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalItemContentInputAudio IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalItemContentInputAudio)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentInputAudio)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalItemContentInputAudio(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalItemContentInputAudio DeserializeInternalItemContentInputAudio(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemContentType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string data = default; + ItemContentInputAudioFormat format = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToItemContentType(); + continue; + } + if (prop.NameEquals("data"u8)) + { + data = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("format"u8)) + { + format = new ItemContentInputAudioFormat(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalItemContentInputAudio(@type, additionalBinaryDataProperties, data, format); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalItemContentInputAudio)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalItemContentInputAudio IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalItemContentInputAudio)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalItemContentInputAudio(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalItemContentInputAudio)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentInputAudio.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentInputAudio.cs new file mode 100644 index 000000000000..48610cbe3489 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentInputAudio.cs @@ -0,0 +1,51 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalItemContentInputAudio : InternalItemContent + { + /// Initializes a new instance of . + /// Base64-encoded audio data. + /// + /// The format of the audio data. Currently supported formats are `mp3` and + /// `wav`. + /// + /// is null. + public InternalItemContentInputAudio(string data, ItemContentInputAudioFormat format) : base(ItemContentType.InputAudio) + { + Argument.AssertNotNull(data, nameof(data)); + + Data = data; + Format = format; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// Base64-encoded audio data. + /// + /// The format of the audio data. Currently supported formats are `mp3` and + /// `wav`. + /// + internal InternalItemContentInputAudio(ItemContentType @type, IDictionary additionalBinaryDataProperties, string data, ItemContentInputAudioFormat format) : base(@type, additionalBinaryDataProperties) + { + Data = data; + Format = format; + } + + /// Base64-encoded audio data. + public string Data { get; } + + /// + /// The format of the audio data. Currently supported formats are `mp3` and + /// `wav`. + /// + public ItemContentInputAudioFormat Format { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentInputFile.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentInputFile.Serialization.cs new file mode 100644 index 000000000000..8a98599601c5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentInputFile.Serialization.cs @@ -0,0 +1,156 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalItemContentInputFile : InternalItemContent, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentInputFile)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(FileId)) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + if (Optional.IsDefined(Filename)) + { + writer.WritePropertyName("filename"u8); + writer.WriteStringValue(Filename); + } + if (Optional.IsDefined(FileData)) + { + writer.WritePropertyName("file_data"u8); + writer.WriteStringValue(FileData); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalItemContentInputFile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalItemContentInputFile)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentInputFile)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalItemContentInputFile(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalItemContentInputFile DeserializeInternalItemContentInputFile(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemContentType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string fileId = default; + string filename = default; + string fileData = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToItemContentType(); + continue; + } + if (prop.NameEquals("file_id"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + fileId = null; + continue; + } + fileId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("filename"u8)) + { + filename = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("file_data"u8)) + { + fileData = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalItemContentInputFile(@type, additionalBinaryDataProperties, fileId, filename, fileData); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalItemContentInputFile)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalItemContentInputFile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalItemContentInputFile)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalItemContentInputFile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalItemContentInputFile)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentInputFile.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentInputFile.cs new file mode 100644 index 000000000000..f69e94685577 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentInputFile.cs @@ -0,0 +1,39 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalItemContentInputFile : InternalItemContent + { + /// Initializes a new instance of . + public InternalItemContentInputFile() : base(ItemContentType.InputFile) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The ID of the file to be sent to the model. + /// The name of the file to be sent to the model. + /// The content of the file to be sent to the model. + internal InternalItemContentInputFile(ItemContentType @type, IDictionary additionalBinaryDataProperties, string fileId, string filename, string fileData) : base(@type, additionalBinaryDataProperties) + { + FileId = fileId; + Filename = filename; + FileData = fileData; + } + + /// The ID of the file to be sent to the model. + public string FileId { get; set; } + + /// The name of the file to be sent to the model. + public string Filename { get; set; } + + /// The content of the file to be sent to the model. + public string FileData { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentInputImage.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentInputImage.Serialization.cs new file mode 100644 index 000000000000..b8ec74d10ff4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentInputImage.Serialization.cs @@ -0,0 +1,165 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalItemContentInputImage : InternalItemContent, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentInputImage)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(ImageUrl)) + { + writer.WritePropertyName("image_url"u8); + writer.WriteStringValue(ImageUrl); + } + if (Optional.IsDefined(FileId)) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + if (Optional.IsDefined(Detail)) + { + writer.WritePropertyName("detail"u8); + writer.WriteStringValue(Detail.Value.ToSerialString()); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalItemContentInputImage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalItemContentInputImage)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentInputImage)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalItemContentInputImage(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalItemContentInputImage DeserializeInternalItemContentInputImage(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemContentType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string imageUrl = default; + string fileId = default; + ItemContentInputImageDetail1? detail = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToItemContentType(); + continue; + } + if (prop.NameEquals("image_url"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + imageUrl = null; + continue; + } + imageUrl = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("file_id"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + fileId = null; + continue; + } + fileId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("detail"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + detail = prop.Value.GetString().ToItemContentInputImageDetail1(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalItemContentInputImage(@type, additionalBinaryDataProperties, imageUrl, fileId, detail); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalItemContentInputImage)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalItemContentInputImage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalItemContentInputImage)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalItemContentInputImage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalItemContentInputImage)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentInputImage.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentInputImage.cs new file mode 100644 index 000000000000..9d40d8b74f1d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentInputImage.cs @@ -0,0 +1,39 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalItemContentInputImage : InternalItemContent + { + /// Initializes a new instance of . + public InternalItemContentInputImage() : base(ItemContentType.InputImage) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL. + /// The ID of the file to be sent to the model. + /// The detail level of the image to be sent to the model. One of `high`, `low`, or `auto`. Defaults to `auto`. + internal InternalItemContentInputImage(ItemContentType @type, IDictionary additionalBinaryDataProperties, string imageUrl, string fileId, ItemContentInputImageDetail1? detail) : base(@type, additionalBinaryDataProperties) + { + ImageUrl = imageUrl; + FileId = fileId; + Detail = detail; + } + + /// The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL. + public string ImageUrl { get; set; } + + /// The ID of the file to be sent to the model. + public string FileId { get; set; } + + /// The detail level of the image to be sent to the model. One of `high`, `low`, or `auto`. Defaults to `auto`. + public ItemContentInputImageDetail1? Detail { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentInputText.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentInputText.Serialization.cs new file mode 100644 index 000000000000..41315ea86bc1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentInputText.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalItemContentInputText : InternalItemContent, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalItemContentInputText() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentInputText)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalItemContentInputText IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalItemContentInputText)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentInputText)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalItemContentInputText(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalItemContentInputText DeserializeInternalItemContentInputText(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemContentType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string text = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToItemContentType(); + continue; + } + if (prop.NameEquals("text"u8)) + { + text = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalItemContentInputText(@type, additionalBinaryDataProperties, text); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalItemContentInputText)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalItemContentInputText IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalItemContentInputText)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalItemContentInputText(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalItemContentInputText)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentInputText.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentInputText.cs new file mode 100644 index 000000000000..ad7e3a867e05 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentInputText.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalItemContentInputText : InternalItemContent + { + /// Initializes a new instance of . + /// The text input to the model. + /// is null. + public InternalItemContentInputText(string text) : base(ItemContentType.InputText) + { + Argument.AssertNotNull(text, nameof(text)); + + Text = text; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The text input to the model. + internal InternalItemContentInputText(ItemContentType @type, IDictionary additionalBinaryDataProperties, string text) : base(@type, additionalBinaryDataProperties) + { + Text = text; + } + + /// The text input to the model. + public string Text { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentOutputAudio.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentOutputAudio.Serialization.cs new file mode 100644 index 000000000000..73dcaacb55e0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentOutputAudio.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalItemContentOutputAudio : InternalItemContent, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalItemContentOutputAudio() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentOutputAudio)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("data"u8); + writer.WriteStringValue(Data); + writer.WritePropertyName("transcript"u8); + writer.WriteStringValue(Transcript); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalItemContentOutputAudio IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalItemContentOutputAudio)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentOutputAudio)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalItemContentOutputAudio(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalItemContentOutputAudio DeserializeInternalItemContentOutputAudio(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemContentType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string data = default; + string transcript = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToItemContentType(); + continue; + } + if (prop.NameEquals("data"u8)) + { + data = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("transcript"u8)) + { + transcript = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalItemContentOutputAudio(@type, additionalBinaryDataProperties, data, transcript); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalItemContentOutputAudio)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalItemContentOutputAudio IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalItemContentOutputAudio)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalItemContentOutputAudio(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalItemContentOutputAudio)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentOutputAudio.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentOutputAudio.cs new file mode 100644 index 000000000000..a00cc2a27799 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentOutputAudio.cs @@ -0,0 +1,43 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalItemContentOutputAudio : InternalItemContent + { + /// Initializes a new instance of . + /// Base64-encoded audio data from the model. + /// The transcript of the audio data from the model. + /// or is null. + public InternalItemContentOutputAudio(string data, string transcript) : base(ItemContentType.OutputAudio) + { + Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNull(transcript, nameof(transcript)); + + Data = data; + Transcript = transcript; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// Base64-encoded audio data from the model. + /// The transcript of the audio data from the model. + internal InternalItemContentOutputAudio(ItemContentType @type, IDictionary additionalBinaryDataProperties, string data, string transcript) : base(@type, additionalBinaryDataProperties) + { + Data = data; + Transcript = transcript; + } + + /// Base64-encoded audio data from the model. + public string Data { get; } + + /// The transcript of the audio data from the model. + public string Transcript { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentOutputText.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentOutputText.Serialization.cs new file mode 100644 index 000000000000..9e37b0d3f59b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentOutputText.Serialization.cs @@ -0,0 +1,174 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalItemContentOutputText : InternalItemContent, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalItemContentOutputText() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentOutputText)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + writer.WritePropertyName("annotations"u8); + writer.WriteStartArray(); + foreach (InternalAnnotation item in Annotations) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsCollectionDefined(Logprobs)) + { + writer.WritePropertyName("logprobs"u8); + writer.WriteStartArray(); + foreach (InternalLogProb item in Logprobs) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalItemContentOutputText IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalItemContentOutputText)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentOutputText)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalItemContentOutputText(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalItemContentOutputText DeserializeInternalItemContentOutputText(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemContentType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string text = default; + IList annotations = default; + IList logprobs = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToItemContentType(); + continue; + } + if (prop.NameEquals("text"u8)) + { + text = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("annotations"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalAnnotation.DeserializeInternalAnnotation(item, options)); + } + annotations = array; + continue; + } + if (prop.NameEquals("logprobs"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalLogProb.DeserializeInternalLogProb(item, options)); + } + logprobs = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalItemContentOutputText(@type, additionalBinaryDataProperties, text, annotations, logprobs ?? new ChangeTrackingList()); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalItemContentOutputText)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalItemContentOutputText IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalItemContentOutputText)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalItemContentOutputText(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalItemContentOutputText)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentOutputText.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentOutputText.cs new file mode 100644 index 000000000000..3abc51ddbba9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentOutputText.cs @@ -0,0 +1,50 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalItemContentOutputText : InternalItemContent + { + /// Initializes a new instance of . + /// The text output from the model. + /// The annotations of the text output. + /// or is null. + public InternalItemContentOutputText(string text, IEnumerable annotations) : base(ItemContentType.OutputText) + { + Argument.AssertNotNull(text, nameof(text)); + Argument.AssertNotNull(annotations, nameof(annotations)); + + Text = text; + Annotations = annotations.ToList(); + Logprobs = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The text output from the model. + /// The annotations of the text output. + /// + internal InternalItemContentOutputText(ItemContentType @type, IDictionary additionalBinaryDataProperties, string text, IList annotations, IList logprobs) : base(@type, additionalBinaryDataProperties) + { + Text = text; + Annotations = annotations; + Logprobs = logprobs; + } + + /// The text output from the model. + public string Text { get; } + + /// The annotations of the text output. + public IList Annotations { get; } + + /// Gets the Logprobs. + public IList Logprobs { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentRefusal.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentRefusal.Serialization.cs new file mode 100644 index 000000000000..2e35271945cc --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentRefusal.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalItemContentRefusal : InternalItemContent, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalItemContentRefusal() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentRefusal)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("refusal"u8); + writer.WriteStringValue(Refusal); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalItemContentRefusal IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalItemContentRefusal)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContentRefusal)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalItemContentRefusal(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalItemContentRefusal DeserializeInternalItemContentRefusal(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemContentType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string refusal = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToItemContentType(); + continue; + } + if (prop.NameEquals("refusal"u8)) + { + refusal = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalItemContentRefusal(@type, additionalBinaryDataProperties, refusal); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalItemContentRefusal)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalItemContentRefusal IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalItemContentRefusal)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalItemContentRefusal(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalItemContentRefusal)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentRefusal.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentRefusal.cs new file mode 100644 index 000000000000..2bab15bc9e20 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemContentRefusal.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalItemContentRefusal : InternalItemContent + { + /// Initializes a new instance of . + /// The refusal explanationfrom the model. + /// is null. + public InternalItemContentRefusal(string refusal) : base(ItemContentType.Refusal) + { + Argument.AssertNotNull(refusal, nameof(refusal)); + + Refusal = refusal; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The refusal explanationfrom the model. + internal InternalItemContentRefusal(ItemContentType @type, IDictionary additionalBinaryDataProperties, string refusal) : base(@type, additionalBinaryDataProperties) + { + Refusal = refusal; + } + + /// The refusal explanationfrom the model. + public string Refusal { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemParam.Serialization.cs new file mode 100644 index 000000000000..c0348b2d7a90 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemParam.Serialization.cs @@ -0,0 +1,167 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + [PersistableModelProxy(typeof(UnknownItemParam))] + internal abstract partial class InternalItemParam : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemParam)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalItemParam DeserializeInternalItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "message": + return InternalResponsesMessageItemParam.DeserializeInternalResponsesMessageItemParam(element, options); + case "function_call_output": + return InternalFunctionToolCallOutputItemParam.DeserializeInternalFunctionToolCallOutputItemParam(element, options); + case "file_search_call": + return InternalFileSearchToolCallItemParam.DeserializeInternalFileSearchToolCallItemParam(element, options); + case "computer_call": + return InternalComputerToolCallItemParam.DeserializeInternalComputerToolCallItemParam(element, options); + case "computer_call_output": + return InternalComputerToolCallOutputItemParam.DeserializeInternalComputerToolCallOutputItemParam(element, options); + case "web_search_call": + return InternalWebSearchToolCallItemParam.DeserializeInternalWebSearchToolCallItemParam(element, options); + case "function_call": + return InternalFunctionToolCallItemParam.DeserializeInternalFunctionToolCallItemParam(element, options); + case "reasoning": + return InternalReasoningItemParam.DeserializeInternalReasoningItemParam(element, options); + case "item_reference": + return InternalItemReferenceItemParam.DeserializeInternalItemReferenceItemParam(element, options); + case "image_generation_call": + return InternalImageGenToolCallItemParam.DeserializeInternalImageGenToolCallItemParam(element, options); + case "code_interpreter_call": + return InternalCodeInterpreterToolCallItemParam.DeserializeInternalCodeInterpreterToolCallItemParam(element, options); + case "local_shell_call": + return InternalLocalShellToolCallItemParam.DeserializeInternalLocalShellToolCallItemParam(element, options); + case "local_shell_call_output": + return InternalLocalShellToolCallOutputItemParam.DeserializeInternalLocalShellToolCallOutputItemParam(element, options); + case "mcp_list_tools": + return InternalMCPListToolsItemParam.DeserializeInternalMCPListToolsItemParam(element, options); + case "mcp_approval_request": + return InternalMCPApprovalRequestItemParam.DeserializeInternalMCPApprovalRequestItemParam(element, options); + case "mcp_approval_response": + return InternalMCPApprovalResponseItemParam.DeserializeInternalMCPApprovalResponseItemParam(element, options); + case "mcp_call": + return InternalMCPCallItemParam.DeserializeInternalMCPCallItemParam(element, options); + case "memory_search_call": + return MemorySearchToolCallItemParam.DeserializeMemorySearchToolCallItemParam(element, options); + } + } + return UnknownItemParam.DeserializeUnknownItemParam(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemParam.cs new file mode 100644 index 000000000000..6dc16fdff183 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemParam.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal abstract partial class InternalItemParam + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + private protected InternalItemParam(ItemType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalItemParam(ItemType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Type. + internal ItemType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemReferenceItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemReferenceItemParam.Serialization.cs new file mode 100644 index 000000000000..8eebd806e25b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemReferenceItemParam.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalItemReferenceItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalItemReferenceItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemReferenceItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalItemReferenceItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalItemReferenceItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemReferenceItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalItemReferenceItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalItemReferenceItemParam DeserializeInternalItemReferenceItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string id = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ItemType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalItemReferenceItemParam(@type, additionalBinaryDataProperties, id); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalItemReferenceItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalItemReferenceItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalItemReferenceItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalItemReferenceItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalItemReferenceItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemReferenceItemParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemReferenceItemParam.cs new file mode 100644 index 000000000000..22eb5de95370 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalItemReferenceItemParam.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalItemReferenceItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The service-originated ID of the previously generated response item being referenced. + /// is null. + public InternalItemReferenceItemParam(string id) : base(ItemType.ItemReference) + { + Argument.AssertNotNull(id, nameof(id)); + + Id = id; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The service-originated ID of the previously generated response item being referenced. + internal InternalItemReferenceItemParam(ItemType @type, IDictionary additionalBinaryDataProperties, string id) : base(@type, additionalBinaryDataProperties) + { + Id = id; + } + + /// The service-originated ID of the previously generated response item being referenced. + public string Id { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocalShellExecAction.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocalShellExecAction.Serialization.cs new file mode 100644 index 000000000000..baa1b53d4389 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocalShellExecAction.Serialization.cs @@ -0,0 +1,255 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalLocalShellExecAction : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalLocalShellExecAction() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalLocalShellExecAction)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + writer.WritePropertyName("command"u8); + writer.WriteStartArray(); + foreach (string item in Command) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + if (Optional.IsDefined(TimeoutMs)) + { + writer.WritePropertyName("timeout_ms"u8); + writer.WriteNumberValue(TimeoutMs.Value); + } + if (Optional.IsDefined(WorkingDirectory)) + { + writer.WritePropertyName("working_directory"u8); + writer.WriteStringValue(WorkingDirectory); + } + writer.WritePropertyName("env"u8); + writer.WriteStartObject(); + foreach (var item in Env) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + if (Optional.IsDefined(User)) + { + writer.WritePropertyName("user"u8); + writer.WriteStringValue(User); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalLocalShellExecAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalLocalShellExecAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalLocalShellExecAction)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalLocalShellExecAction(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalLocalShellExecAction DeserializeInternalLocalShellExecAction(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = default; + IList command = default; + int? timeoutMs = default; + string workingDirectory = default; + IDictionary env = default; + string user = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("command"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + command = array; + continue; + } + if (prop.NameEquals("timeout_ms"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + timeoutMs = null; + continue; + } + timeoutMs = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("working_directory"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + workingDirectory = null; + continue; + } + workingDirectory = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("env"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + env = dictionary; + continue; + } + if (prop.NameEquals("user"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + user = null; + continue; + } + user = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalLocalShellExecAction( + @type, + command, + timeoutMs, + workingDirectory, + env, + user, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalLocalShellExecAction)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalLocalShellExecAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalLocalShellExecAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalLocalShellExecAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalLocalShellExecAction)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocalShellExecAction.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocalShellExecAction.cs new file mode 100644 index 000000000000..c086e3cffa56 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocalShellExecAction.cs @@ -0,0 +1,67 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalLocalShellExecAction + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The command to run. + /// Environment variables to set for the command. + /// or is null. + public InternalLocalShellExecAction(IEnumerable command, IDictionary env) + { + Argument.AssertNotNull(command, nameof(command)); + Argument.AssertNotNull(env, nameof(env)); + + Command = command.ToList(); + Env = env; + } + + /// Initializes a new instance of . + /// The type of the local shell action. Always `exec`. + /// The command to run. + /// Optional timeout in milliseconds for the command. + /// Optional working directory to run the command in. + /// Environment variables to set for the command. + /// Optional user to run the command as. + /// Keeps track of any properties unknown to the library. + internal InternalLocalShellExecAction(string @type, IList command, int? timeoutMs, string workingDirectory, IDictionary env, string user, IDictionary additionalBinaryDataProperties) + { + Type = @type; + Command = command; + TimeoutMs = timeoutMs; + WorkingDirectory = workingDirectory; + Env = env; + User = user; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The type of the local shell action. Always `exec`. + internal string Type { get; } = "exec"; + + /// The command to run. + public IList Command { get; } + + /// Optional timeout in milliseconds for the command. + public int? TimeoutMs { get; set; } + + /// Optional working directory to run the command in. + public string WorkingDirectory { get; set; } + + /// Environment variables to set for the command. + public IDictionary Env { get; } + + /// Optional user to run the command as. + public string User { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocalShellTool.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocalShellTool.Serialization.cs new file mode 100644 index 000000000000..a328f5b428b3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocalShellTool.Serialization.cs @@ -0,0 +1,118 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalLocalShellTool : InternalTool, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalLocalShellTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalLocalShellTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalLocalShellTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalLocalShellTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalLocalShellTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalLocalShellTool DeserializeInternalLocalShellTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalLocalShellTool(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalLocalShellTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalLocalShellTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalLocalShellTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalLocalShellTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalLocalShellTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocalShellTool.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocalShellTool.cs new file mode 100644 index 000000000000..3ff03b9e7318 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocalShellTool.cs @@ -0,0 +1,25 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalLocalShellTool : InternalTool + { + /// Initializes a new instance of . + public InternalLocalShellTool() : base(ToolType.LocalShell) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalLocalShellTool(ToolType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocalShellToolCallItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocalShellToolCallItemParam.Serialization.cs new file mode 100644 index 000000000000..89f2bbf136bc --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocalShellToolCallItemParam.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalLocalShellToolCallItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalLocalShellToolCallItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalLocalShellToolCallItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("call_id"u8); + writer.WriteStringValue(CallId); + writer.WritePropertyName("action"u8); + writer.WriteObjectValue(Action, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalLocalShellToolCallItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalLocalShellToolCallItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalLocalShellToolCallItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalLocalShellToolCallItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalLocalShellToolCallItemParam DeserializeInternalLocalShellToolCallItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string callId = default; + InternalLocalShellExecAction action = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ItemType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("call_id"u8)) + { + callId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("action"u8)) + { + action = InternalLocalShellExecAction.DeserializeInternalLocalShellExecAction(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalLocalShellToolCallItemParam(@type, additionalBinaryDataProperties, callId, action); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalLocalShellToolCallItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalLocalShellToolCallItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalLocalShellToolCallItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalLocalShellToolCallItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalLocalShellToolCallItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocalShellToolCallItemParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocalShellToolCallItemParam.cs new file mode 100644 index 000000000000..7b69b57e0819 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocalShellToolCallItemParam.cs @@ -0,0 +1,43 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalLocalShellToolCallItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The unique ID of the local shell tool call generated by the model. + /// + /// or is null. + public InternalLocalShellToolCallItemParam(string callId, InternalLocalShellExecAction action) : base(ItemType.LocalShellCall) + { + Argument.AssertNotNull(callId, nameof(callId)); + Argument.AssertNotNull(action, nameof(action)); + + CallId = callId; + Action = action; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The unique ID of the local shell tool call generated by the model. + /// + internal InternalLocalShellToolCallItemParam(ItemType @type, IDictionary additionalBinaryDataProperties, string callId, InternalLocalShellExecAction action) : base(@type, additionalBinaryDataProperties) + { + CallId = callId; + Action = action; + } + + /// The unique ID of the local shell tool call generated by the model. + public string CallId { get; } + + /// Gets the Action. + public InternalLocalShellExecAction Action { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocalShellToolCallOutputItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocalShellToolCallOutputItemParam.Serialization.cs new file mode 100644 index 000000000000..fdd3ac65dbb2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocalShellToolCallOutputItemParam.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalLocalShellToolCallOutputItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalLocalShellToolCallOutputItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalLocalShellToolCallOutputItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("output"u8); + writer.WriteStringValue(Output); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalLocalShellToolCallOutputItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalLocalShellToolCallOutputItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalLocalShellToolCallOutputItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalLocalShellToolCallOutputItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalLocalShellToolCallOutputItemParam DeserializeInternalLocalShellToolCallOutputItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string output = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ItemType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("output"u8)) + { + output = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalLocalShellToolCallOutputItemParam(@type, additionalBinaryDataProperties, output); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalLocalShellToolCallOutputItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalLocalShellToolCallOutputItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalLocalShellToolCallOutputItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalLocalShellToolCallOutputItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalLocalShellToolCallOutputItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocalShellToolCallOutputItemParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocalShellToolCallOutputItemParam.cs new file mode 100644 index 000000000000..a07fee124b7b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocalShellToolCallOutputItemParam.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalLocalShellToolCallOutputItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// A JSON string of the output of the local shell tool call. + /// is null. + public InternalLocalShellToolCallOutputItemParam(string output) : base(ItemType.LocalShellCallOutput) + { + Argument.AssertNotNull(output, nameof(output)); + + Output = output; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// A JSON string of the output of the local shell tool call. + internal InternalLocalShellToolCallOutputItemParam(ItemType @type, IDictionary additionalBinaryDataProperties, string output) : base(@type, additionalBinaryDataProperties) + { + Output = output; + } + + /// A JSON string of the output of the local shell tool call. + public string Output { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocation.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocation.Serialization.cs new file mode 100644 index 000000000000..a1bceb841472 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocation.Serialization.cs @@ -0,0 +1,133 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + [PersistableModelProxy(typeof(UnknownLocation))] + internal abstract partial class InternalLocation : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalLocation() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalLocation)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalLocation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalLocation JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalLocation)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalLocation(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalLocation DeserializeInternalLocation(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "approximate": + return InternalApproximateLocation.DeserializeInternalApproximateLocation(element, options); + } + } + return UnknownLocation.DeserializeUnknownLocation(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalLocation)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalLocation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalLocation PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalLocation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalLocation)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocation.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocation.cs new file mode 100644 index 000000000000..ae1142d7bec9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalLocation.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal abstract partial class InternalLocation + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + private protected InternalLocation(LocationType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalLocation(LocationType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Type. + internal LocationType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalLogProb.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalLogProb.Serialization.cs new file mode 100644 index 000000000000..09829cf050a6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalLogProb.Serialization.cs @@ -0,0 +1,183 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalLogProb : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalLogProb() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalLogProb)} does not support writing '{format}' format."); + } + writer.WritePropertyName("token"u8); + writer.WriteStringValue(Token); + writer.WritePropertyName("logprob"u8); + writer.WriteNumberValue(Logprob); + writer.WritePropertyName("bytes"u8); + writer.WriteStartArray(); + foreach (int item in Bytes) + { + writer.WriteNumberValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("top_logprobs"u8); + writer.WriteStartArray(); + foreach (InternalTopLogProb item in TopLogprobs) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalLogProb IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalLogProb JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalLogProb)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalLogProb(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalLogProb DeserializeInternalLogProb(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string token = default; + float logprob = default; + IList bytes = default; + IList topLogprobs = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("token"u8)) + { + token = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("logprob"u8)) + { + logprob = prop.Value.GetSingle(); + continue; + } + if (prop.NameEquals("bytes"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(item.GetInt32()); + } + bytes = array; + continue; + } + if (prop.NameEquals("top_logprobs"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalTopLogProb.DeserializeInternalTopLogProb(item, options)); + } + topLogprobs = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalLogProb(token, logprob, bytes, topLogprobs, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalLogProb)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalLogProb IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalLogProb PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalLogProb(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalLogProb)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalLogProb.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalLogProb.cs new file mode 100644 index 000000000000..fec500a22e53 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalLogProb.cs @@ -0,0 +1,62 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalLogProb + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// + /// + /// + /// , or is null. + public InternalLogProb(string token, float logprob, IEnumerable bytes, IEnumerable topLogprobs) + { + Argument.AssertNotNull(token, nameof(token)); + Argument.AssertNotNull(bytes, nameof(bytes)); + Argument.AssertNotNull(topLogprobs, nameof(topLogprobs)); + + Token = token; + Logprob = logprob; + Bytes = bytes.ToList(); + TopLogprobs = topLogprobs.ToList(); + } + + /// Initializes a new instance of . + /// + /// + /// + /// + /// Keeps track of any properties unknown to the library. + internal InternalLogProb(string token, float logprob, IList bytes, IList topLogprobs, IDictionary additionalBinaryDataProperties) + { + Token = token; + Logprob = logprob; + Bytes = bytes; + TopLogprobs = topLogprobs; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Token. + public string Token { get; } + + /// Gets the Logprob. + public float Logprob { get; } + + /// Gets the Bytes. + public IList Bytes { get; } + + /// Gets the TopLogprobs. + public IList TopLogprobs { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPApprovalRequestItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPApprovalRequestItemParam.Serialization.cs new file mode 100644 index 000000000000..a227e89313a6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPApprovalRequestItemParam.Serialization.cs @@ -0,0 +1,147 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalMCPApprovalRequestItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalMCPApprovalRequestItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPApprovalRequestItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("server_label"u8); + writer.WriteStringValue(ServerLabel); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("arguments"u8); + writer.WriteStringValue(Arguments); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMCPApprovalRequestItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalMCPApprovalRequestItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPApprovalRequestItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMCPApprovalRequestItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMCPApprovalRequestItemParam DeserializeInternalMCPApprovalRequestItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string serverLabel = default; + string name = default; + string arguments = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ItemType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("server_label"u8)) + { + serverLabel = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("arguments"u8)) + { + arguments = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMCPApprovalRequestItemParam(@type, additionalBinaryDataProperties, serverLabel, name, arguments); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMCPApprovalRequestItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMCPApprovalRequestItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalMCPApprovalRequestItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMCPApprovalRequestItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMCPApprovalRequestItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPApprovalRequestItemParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPApprovalRequestItemParam.cs new file mode 100644 index 000000000000..49358170cb81 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPApprovalRequestItemParam.cs @@ -0,0 +1,51 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalMCPApprovalRequestItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The label of the MCP server making the request. + /// The name of the tool to run. + /// A JSON string of arguments for the tool. + /// , or is null. + public InternalMCPApprovalRequestItemParam(string serverLabel, string name, string arguments) : base(ItemType.McpApprovalRequest) + { + Argument.AssertNotNull(serverLabel, nameof(serverLabel)); + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(arguments, nameof(arguments)); + + ServerLabel = serverLabel; + Name = name; + Arguments = arguments; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The label of the MCP server making the request. + /// The name of the tool to run. + /// A JSON string of arguments for the tool. + internal InternalMCPApprovalRequestItemParam(ItemType @type, IDictionary additionalBinaryDataProperties, string serverLabel, string name, string arguments) : base(@type, additionalBinaryDataProperties) + { + ServerLabel = serverLabel; + Name = name; + Arguments = arguments; + } + + /// The label of the MCP server making the request. + public string ServerLabel { get; } + + /// The name of the tool to run. + public string Name { get; } + + /// A JSON string of arguments for the tool. + public string Arguments { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPApprovalResponseItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPApprovalResponseItemParam.Serialization.cs new file mode 100644 index 000000000000..5a7637868a73 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPApprovalResponseItemParam.Serialization.cs @@ -0,0 +1,155 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalMCPApprovalResponseItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalMCPApprovalResponseItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPApprovalResponseItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("approval_request_id"u8); + writer.WriteStringValue(ApprovalRequestId); + writer.WritePropertyName("approve"u8); + writer.WriteBooleanValue(Approve); + if (Optional.IsDefined(Reason)) + { + writer.WritePropertyName("reason"u8); + writer.WriteStringValue(Reason); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMCPApprovalResponseItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalMCPApprovalResponseItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPApprovalResponseItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMCPApprovalResponseItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMCPApprovalResponseItemParam DeserializeInternalMCPApprovalResponseItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string approvalRequestId = default; + bool approve = default; + string reason = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ItemType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("approval_request_id"u8)) + { + approvalRequestId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("approve"u8)) + { + approve = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("reason"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + reason = null; + continue; + } + reason = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMCPApprovalResponseItemParam(@type, additionalBinaryDataProperties, approvalRequestId, approve, reason); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMCPApprovalResponseItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMCPApprovalResponseItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalMCPApprovalResponseItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMCPApprovalResponseItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMCPApprovalResponseItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPApprovalResponseItemParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPApprovalResponseItemParam.cs new file mode 100644 index 000000000000..84941ebd5c3d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPApprovalResponseItemParam.cs @@ -0,0 +1,47 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalMCPApprovalResponseItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The ID of the approval request being answered. + /// Whether the request was approved. + /// is null. + public InternalMCPApprovalResponseItemParam(string approvalRequestId, bool approve) : base(ItemType.McpApprovalResponse) + { + Argument.AssertNotNull(approvalRequestId, nameof(approvalRequestId)); + + ApprovalRequestId = approvalRequestId; + Approve = approve; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The ID of the approval request being answered. + /// Whether the request was approved. + /// Optional reason for the decision. + internal InternalMCPApprovalResponseItemParam(ItemType @type, IDictionary additionalBinaryDataProperties, string approvalRequestId, bool approve, string reason) : base(@type, additionalBinaryDataProperties) + { + ApprovalRequestId = approvalRequestId; + Approve = approve; + Reason = reason; + } + + /// The ID of the approval request being answered. + public string ApprovalRequestId { get; } + + /// Whether the request was approved. + public bool Approve { get; } + + /// Optional reason for the decision. + public string Reason { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPCallItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPCallItemParam.Serialization.cs new file mode 100644 index 000000000000..dfd2de925d9c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPCallItemParam.Serialization.cs @@ -0,0 +1,186 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalMCPCallItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalMCPCallItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPCallItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("server_label"u8); + writer.WriteStringValue(ServerLabel); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("arguments"u8); + writer.WriteStringValue(Arguments); + if (Optional.IsDefined(Output)) + { + writer.WritePropertyName("output"u8); + writer.WriteStringValue(Output); + } + if (Optional.IsDefined(Error)) + { + writer.WritePropertyName("error"u8); + writer.WriteStringValue(Error); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMCPCallItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalMCPCallItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPCallItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMCPCallItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMCPCallItemParam DeserializeInternalMCPCallItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string serverLabel = default; + string name = default; + string arguments = default; + string output = default; + string error = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ItemType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("server_label"u8)) + { + serverLabel = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("arguments"u8)) + { + arguments = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("output"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + output = null; + continue; + } + output = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("error"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + error = null; + continue; + } + error = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMCPCallItemParam( + @type, + additionalBinaryDataProperties, + serverLabel, + name, + arguments, + output, + error); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMCPCallItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMCPCallItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalMCPCallItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMCPCallItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMCPCallItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPCallItemParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPCallItemParam.cs new file mode 100644 index 000000000000..c4761bdf357f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPCallItemParam.cs @@ -0,0 +1,61 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalMCPCallItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The label of the MCP server running the tool. + /// The name of the tool that was run. + /// A JSON string of the arguments passed to the tool. + /// , or is null. + public InternalMCPCallItemParam(string serverLabel, string name, string arguments) : base(ItemType.McpCall) + { + Argument.AssertNotNull(serverLabel, nameof(serverLabel)); + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(arguments, nameof(arguments)); + + ServerLabel = serverLabel; + Name = name; + Arguments = arguments; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The label of the MCP server running the tool. + /// The name of the tool that was run. + /// A JSON string of the arguments passed to the tool. + /// The output from the tool call. + /// The error from the tool call, if any. + internal InternalMCPCallItemParam(ItemType @type, IDictionary additionalBinaryDataProperties, string serverLabel, string name, string arguments, string output, string error) : base(@type, additionalBinaryDataProperties) + { + ServerLabel = serverLabel; + Name = name; + Arguments = arguments; + Output = output; + Error = error; + } + + /// The label of the MCP server running the tool. + public string ServerLabel { get; } + + /// The name of the tool that was run. + public string Name { get; } + + /// A JSON string of the arguments passed to the tool. + public string Arguments { get; } + + /// The output from the tool call. + public string Output { get; set; } + + /// The error from the tool call, if any. + public string Error { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPListToolsItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPListToolsItemParam.Serialization.cs new file mode 100644 index 000000000000..0079470193ec --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPListToolsItemParam.Serialization.cs @@ -0,0 +1,165 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalMCPListToolsItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalMCPListToolsItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPListToolsItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("server_label"u8); + writer.WriteStringValue(ServerLabel); + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (InternalMCPListToolsTool item in Tools) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(Error)) + { + writer.WritePropertyName("error"u8); + writer.WriteStringValue(Error); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMCPListToolsItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalMCPListToolsItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPListToolsItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMCPListToolsItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMCPListToolsItemParam DeserializeInternalMCPListToolsItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string serverLabel = default; + IList tools = default; + string error = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ItemType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("server_label"u8)) + { + serverLabel = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("tools"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalMCPListToolsTool.DeserializeInternalMCPListToolsTool(item, options)); + } + tools = array; + continue; + } + if (prop.NameEquals("error"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + error = null; + continue; + } + error = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMCPListToolsItemParam(@type, additionalBinaryDataProperties, serverLabel, tools, error); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMCPListToolsItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMCPListToolsItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalMCPListToolsItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMCPListToolsItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMCPListToolsItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPListToolsItemParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPListToolsItemParam.cs new file mode 100644 index 000000000000..b8920eae51cb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPListToolsItemParam.cs @@ -0,0 +1,49 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalMCPListToolsItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The label of the MCP server. + /// The tools available on the server. + /// or is null. + public InternalMCPListToolsItemParam(string serverLabel, IEnumerable tools) : base(ItemType.McpListTools) + { + Argument.AssertNotNull(serverLabel, nameof(serverLabel)); + Argument.AssertNotNull(tools, nameof(tools)); + + ServerLabel = serverLabel; + Tools = tools.ToList(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The label of the MCP server. + /// The tools available on the server. + /// Error message if the server could not list tools. + internal InternalMCPListToolsItemParam(ItemType @type, IDictionary additionalBinaryDataProperties, string serverLabel, IList tools, string error) : base(@type, additionalBinaryDataProperties) + { + ServerLabel = serverLabel; + Tools = tools; + Error = error; + } + + /// The label of the MCP server. + public string ServerLabel { get; } + + /// The tools available on the server. + public IList Tools { get; } + + /// Error message if the server could not list tools. + public string Error { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPListToolsTool.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPListToolsTool.Serialization.cs new file mode 100644 index 000000000000..83d5f749ef84 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPListToolsTool.Serialization.cs @@ -0,0 +1,193 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalMCPListToolsTool : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalMCPListToolsTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPListToolsTool)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("input_schema"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(InputSchema); +#else + using (JsonDocument document = JsonDocument.Parse(InputSchema)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + if (Optional.IsDefined(Annotations)) + { + writer.WritePropertyName("annotations"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Annotations); +#else + using (JsonDocument document = JsonDocument.Parse(Annotations)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMCPListToolsTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalMCPListToolsTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPListToolsTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMCPListToolsTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMCPListToolsTool DeserializeInternalMCPListToolsTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string description = default; + BinaryData inputSchema = default; + BinaryData annotations = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("description"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + description = null; + continue; + } + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("input_schema"u8)) + { + inputSchema = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("annotations"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + annotations = null; + continue; + } + annotations = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMCPListToolsTool(name, description, inputSchema, annotations, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMCPListToolsTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMCPListToolsTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalMCPListToolsTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMCPListToolsTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMCPListToolsTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPListToolsTool.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPListToolsTool.cs new file mode 100644 index 000000000000..2655aa08e3eb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPListToolsTool.cs @@ -0,0 +1,107 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalMCPListToolsTool + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The name of the tool. + /// The JSON schema describing the tool's input. + /// or is null. + public InternalMCPListToolsTool(string name, BinaryData inputSchema) + { + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(inputSchema, nameof(inputSchema)); + + Name = name; + InputSchema = inputSchema; + } + + /// Initializes a new instance of . + /// The name of the tool. + /// The description of the tool. + /// The JSON schema describing the tool's input. + /// Additional annotations about the tool. + /// Keeps track of any properties unknown to the library. + internal InternalMCPListToolsTool(string name, string description, BinaryData inputSchema, BinaryData annotations, IDictionary additionalBinaryDataProperties) + { + Name = name; + Description = description; + InputSchema = inputSchema; + Annotations = annotations; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The name of the tool. + public string Name { get; } + + /// The description of the tool. + public string Description { get; set; } + + /// + /// The JSON schema describing the tool's input. + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData InputSchema { get; } + + /// + /// Additional annotations about the tool. + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData Annotations { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPTool.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPTool.Serialization.cs new file mode 100644 index 000000000000..2f7ed21c2230 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPTool.Serialization.cs @@ -0,0 +1,242 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalMCPTool : InternalTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalMCPTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("server_label"u8); + writer.WriteStringValue(ServerLabel); + writer.WritePropertyName("server_url"u8); + writer.WriteStringValue(ServerUrl); + if (Optional.IsCollectionDefined(Headers)) + { + writer.WritePropertyName("headers"u8); + writer.WriteStartObject(); + foreach (var item in Headers) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(AllowedTools)) + { + writer.WritePropertyName("allowed_tools"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(AllowedTools); +#else + using (JsonDocument document = JsonDocument.Parse(AllowedTools)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (Optional.IsDefined(RequireApproval)) + { + writer.WritePropertyName("require_approval"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(RequireApproval); +#else + using (JsonDocument document = JsonDocument.Parse(RequireApproval)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (Optional.IsDefined(ProjectConnectionId)) + { + writer.WritePropertyName("project_connection_id"u8); + writer.WriteStringValue(ProjectConnectionId); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMCPTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalMCPTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMCPTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMCPTool DeserializeInternalMCPTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string serverLabel = default; + string serverUrl = default; + IDictionary headers = default; + BinaryData allowedTools = default; + BinaryData requireApproval = default; + string projectConnectionId = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("server_label"u8)) + { + serverLabel = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("server_url"u8)) + { + serverUrl = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("headers"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + headers = dictionary; + continue; + } + if (prop.NameEquals("allowed_tools"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + allowedTools = null; + continue; + } + allowedTools = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("require_approval"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + requireApproval = null; + continue; + } + requireApproval = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("project_connection_id"u8)) + { + projectConnectionId = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMCPTool( + @type, + additionalBinaryDataProperties, + serverLabel, + serverUrl, + headers ?? new ChangeTrackingDictionary(), + allowedTools, + requireApproval, + projectConnectionId); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMCPTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMCPTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalMCPTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMCPTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMCPTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPTool.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPTool.cs new file mode 100644 index 000000000000..982e64e6745a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPTool.cs @@ -0,0 +1,150 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalMCPTool : InternalTool + { + /// Initializes a new instance of . + /// A label for this MCP server, used to identify it in tool calls. + /// The URL for the MCP server. + /// or is null. + public InternalMCPTool(string serverLabel, string serverUrl) : base(ToolType.Mcp) + { + Argument.AssertNotNull(serverLabel, nameof(serverLabel)); + Argument.AssertNotNull(serverUrl, nameof(serverUrl)); + + ServerLabel = serverLabel; + ServerUrl = serverUrl; + Headers = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// A label for this MCP server, used to identify it in tool calls. + /// The URL for the MCP server. + /// + /// Optional HTTP headers to send to the MCP server. Use for authentication + /// or other purposes. + /// + /// List of allowed tool names or a filter object. + /// Specify which of the MCP server's tools require approval. + /// The connection ID in the project for the MCP server. The connection stores authentication and other connection details needed to connect to the MCP server. + internal InternalMCPTool(ToolType @type, IDictionary additionalBinaryDataProperties, string serverLabel, string serverUrl, IDictionary headers, BinaryData allowedTools, BinaryData requireApproval, string projectConnectionId) : base(@type, additionalBinaryDataProperties) + { + ServerLabel = serverLabel; + ServerUrl = serverUrl; + Headers = headers; + AllowedTools = allowedTools; + RequireApproval = requireApproval; + ProjectConnectionId = projectConnectionId; + } + + /// A label for this MCP server, used to identify it in tool calls. + public string ServerLabel { get; set; } + + /// The URL for the MCP server. + public string ServerUrl { get; set; } + + /// + /// Optional HTTP headers to send to the MCP server. Use for authentication + /// or other purposes. + /// + public IDictionary Headers { get; set; } + + /// + /// List of allowed tool names or a filter object. + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// where T is of type . + /// + /// + /// . + /// + /// + /// + /// + /// + /// 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" }. + /// + /// + /// + /// + public BinaryData AllowedTools { get; set; } + + /// + /// Specify which of the MCP server's tools require approval. + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// "always". + /// + /// + /// "never". + /// + /// + /// + /// + /// + /// 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" }. + /// + /// + /// + /// + public BinaryData RequireApproval { get; set; } + + /// The connection ID in the project for the MCP server. The connection stores authentication and other connection details needed to connect to the MCP server. + public string ProjectConnectionId { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPToolAllowedTools1.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPToolAllowedTools1.Serialization.cs new file mode 100644 index 000000000000..d583f36350ce --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPToolAllowedTools1.Serialization.cs @@ -0,0 +1,163 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalMCPToolAllowedTools1 : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPToolAllowedTools1)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(ToolNames)) + { + writer.WritePropertyName("tool_names"u8); + writer.WriteStartArray(); + foreach (string item in ToolNames) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMCPToolAllowedTools1 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalMCPToolAllowedTools1 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPToolAllowedTools1)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMCPToolAllowedTools1(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMCPToolAllowedTools1 DeserializeInternalMCPToolAllowedTools1(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList toolNames = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("tool_names"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + toolNames = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMCPToolAllowedTools1(toolNames ?? new ChangeTrackingList(), additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMCPToolAllowedTools1)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMCPToolAllowedTools1 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalMCPToolAllowedTools1 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMCPToolAllowedTools1(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMCPToolAllowedTools1)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPToolAllowedTools1.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPToolAllowedTools1.cs new file mode 100644 index 000000000000..e8b0538b95ca --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPToolAllowedTools1.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalMCPToolAllowedTools1 + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public InternalMCPToolAllowedTools1() + { + ToolNames = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// List of allowed tool names. + /// Keeps track of any properties unknown to the library. + internal InternalMCPToolAllowedTools1(IList toolNames, IDictionary additionalBinaryDataProperties) + { + ToolNames = toolNames; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// List of allowed tool names. + public IList ToolNames { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPToolRequireApproval1.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPToolRequireApproval1.Serialization.cs new file mode 100644 index 000000000000..368a38ab0e9f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPToolRequireApproval1.Serialization.cs @@ -0,0 +1,156 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalMCPToolRequireApproval1 : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPToolRequireApproval1)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Always)) + { + writer.WritePropertyName("always"u8); + writer.WriteObjectValue(Always, options); + } + if (Optional.IsDefined(Never)) + { + writer.WritePropertyName("never"u8); + writer.WriteObjectValue(Never, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMCPToolRequireApproval1 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalMCPToolRequireApproval1 JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPToolRequireApproval1)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMCPToolRequireApproval1(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMCPToolRequireApproval1 DeserializeInternalMCPToolRequireApproval1(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalMCPToolRequireApprovalAlways always = default; + InternalMCPToolRequireApprovalNever never = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("always"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + always = InternalMCPToolRequireApprovalAlways.DeserializeInternalMCPToolRequireApprovalAlways(prop.Value, options); + continue; + } + if (prop.NameEquals("never"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + never = InternalMCPToolRequireApprovalNever.DeserializeInternalMCPToolRequireApprovalNever(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMCPToolRequireApproval1(always, never, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMCPToolRequireApproval1)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMCPToolRequireApproval1 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalMCPToolRequireApproval1 PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMCPToolRequireApproval1(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMCPToolRequireApproval1)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPToolRequireApproval1.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPToolRequireApproval1.cs new file mode 100644 index 000000000000..be59e8145e35 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPToolRequireApproval1.cs @@ -0,0 +1,37 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalMCPToolRequireApproval1 + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public InternalMCPToolRequireApproval1() + { + } + + /// Initializes a new instance of . + /// A list of tools that always require approval. + /// A list of tools that never require approval. + /// Keeps track of any properties unknown to the library. + internal InternalMCPToolRequireApproval1(InternalMCPToolRequireApprovalAlways always, InternalMCPToolRequireApprovalNever never, IDictionary additionalBinaryDataProperties) + { + Always = always; + Never = never; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// A list of tools that always require approval. + public InternalMCPToolRequireApprovalAlways Always { get; set; } + + /// A list of tools that never require approval. + public InternalMCPToolRequireApprovalNever Never { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPToolRequireApprovalAlways.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPToolRequireApprovalAlways.Serialization.cs new file mode 100644 index 000000000000..3b0a891b640b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPToolRequireApprovalAlways.Serialization.cs @@ -0,0 +1,163 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalMCPToolRequireApprovalAlways : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPToolRequireApprovalAlways)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(ToolNames)) + { + writer.WritePropertyName("tool_names"u8); + writer.WriteStartArray(); + foreach (string item in ToolNames) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMCPToolRequireApprovalAlways IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalMCPToolRequireApprovalAlways JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPToolRequireApprovalAlways)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMCPToolRequireApprovalAlways(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMCPToolRequireApprovalAlways DeserializeInternalMCPToolRequireApprovalAlways(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList toolNames = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("tool_names"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + toolNames = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMCPToolRequireApprovalAlways(toolNames ?? new ChangeTrackingList(), additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMCPToolRequireApprovalAlways)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMCPToolRequireApprovalAlways IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalMCPToolRequireApprovalAlways PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMCPToolRequireApprovalAlways(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMCPToolRequireApprovalAlways)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPToolRequireApprovalAlways.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPToolRequireApprovalAlways.cs new file mode 100644 index 000000000000..8411a4a9e08a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPToolRequireApprovalAlways.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalMCPToolRequireApprovalAlways + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public InternalMCPToolRequireApprovalAlways() + { + ToolNames = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// List of tools that require approval. + /// Keeps track of any properties unknown to the library. + internal InternalMCPToolRequireApprovalAlways(IList toolNames, IDictionary additionalBinaryDataProperties) + { + ToolNames = toolNames; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// List of tools that require approval. + public IList ToolNames { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPToolRequireApprovalNever.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPToolRequireApprovalNever.Serialization.cs new file mode 100644 index 000000000000..aac930ecaf68 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPToolRequireApprovalNever.Serialization.cs @@ -0,0 +1,163 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalMCPToolRequireApprovalNever : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPToolRequireApprovalNever)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(ToolNames)) + { + writer.WritePropertyName("tool_names"u8); + writer.WriteStartArray(); + foreach (string item in ToolNames) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMCPToolRequireApprovalNever IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalMCPToolRequireApprovalNever JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMCPToolRequireApprovalNever)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMCPToolRequireApprovalNever(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMCPToolRequireApprovalNever DeserializeInternalMCPToolRequireApprovalNever(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList toolNames = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("tool_names"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + toolNames = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMCPToolRequireApprovalNever(toolNames ?? new ChangeTrackingList(), additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMCPToolRequireApprovalNever)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMCPToolRequireApprovalNever IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalMCPToolRequireApprovalNever PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMCPToolRequireApprovalNever(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMCPToolRequireApprovalNever)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPToolRequireApprovalNever.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPToolRequireApprovalNever.cs new file mode 100644 index 000000000000..8f5618876d72 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMCPToolRequireApprovalNever.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalMCPToolRequireApprovalNever + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public InternalMCPToolRequireApprovalNever() + { + ToolNames = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// List of tools that do not require approval. + /// Keeps track of any properties unknown to the library. + internal InternalMCPToolRequireApprovalNever(IList toolNames, IDictionary additionalBinaryDataProperties) + { + ToolNames = toolNames; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// List of tools that do not require approval. + public IList ToolNames { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMemorySearchOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMemorySearchOptions.Serialization.cs new file mode 100644 index 000000000000..4bd6d7ac5b57 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMemorySearchOptions.Serialization.cs @@ -0,0 +1,201 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects +{ + internal partial class InternalMemorySearchOptions : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalMemorySearchOptions() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMemorySearchOptions)} does not support writing '{format}' format."); + } + writer.WritePropertyName("scope"u8); + writer.WriteStringValue(Scope); + if (Optional.IsCollectionDefined(Items)) + { + writer.WritePropertyName("items"u8); + writer.WriteStartArray(); + foreach (InternalItemParam item in Items) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(PreviousSearchId)) + { + writer.WritePropertyName("previous_search_id"u8); + writer.WriteStringValue(PreviousSearchId); + } + if (Optional.IsDefined(Options)) + { + writer.WritePropertyName("options"u8); + writer.WriteObjectValue(Options, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMemorySearchOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalMemorySearchOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMemorySearchOptions)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMemorySearchOptions(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMemorySearchOptions DeserializeInternalMemorySearchOptions(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string scope = default; + IList items = default; + string previousSearchId = default; + MemorySearchResultOptions options0 = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("scope"u8)) + { + scope = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("items"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalItemParam.DeserializeInternalItemParam(item, options)); + } + items = array; + continue; + } + if (prop.NameEquals("previous_search_id"u8)) + { + previousSearchId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("options"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + options0 = MemorySearchResultOptions.DeserializeMemorySearchResultOptions(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMemorySearchOptions(scope, items ?? new ChangeTrackingList(), previousSearchId, options0, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMemorySearchOptions)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMemorySearchOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalMemorySearchOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMemorySearchOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMemorySearchOptions)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(InternalMemorySearchOptions internalMemorySearchOptions) + { + if (internalMemorySearchOptions == null) + { + return null; + } + return BinaryContent.Create(internalMemorySearchOptions, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMemorySearchOptions.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMemorySearchOptions.cs new file mode 100644 index 000000000000..a5d63adbf114 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMemorySearchOptions.cs @@ -0,0 +1,51 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects +{ + internal partial class InternalMemorySearchOptions + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The namespace that logically groups and isolates memories, such as a user ID. + internal InternalMemorySearchOptions(string scope) + { + Scope = scope; + Items = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The namespace that logically groups and isolates memories, such as a user ID. + /// Items for which to search for relevant memories. + /// The unique ID of the previous search request, enabling incremental memory search from where the last operation left off. + /// Memory search options. + /// Keeps track of any properties unknown to the library. + internal InternalMemorySearchOptions(string scope, IList items, string previousSearchId, MemorySearchResultOptions options, IDictionary additionalBinaryDataProperties) + { + Scope = scope; + Items = items; + PreviousSearchId = previousSearchId; + Options = options; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The namespace that logically groups and isolates memories, such as a user ID. + public string Scope { get; } + + /// Items for which to search for relevant memories. + public IList Items { get; } + + /// The unique ID of the previous search request, enabling incremental memory search from where the last operation left off. + public string PreviousSearchId { get; } + + /// Memory search options. + public MemorySearchResultOptions Options { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMemoryUpdateOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMemoryUpdateOptions.Serialization.cs new file mode 100644 index 000000000000..87e5ea984937 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMemoryUpdateOptions.Serialization.cs @@ -0,0 +1,201 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects +{ + internal partial class InternalMemoryUpdateOptions : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalMemoryUpdateOptions() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMemoryUpdateOptions)} does not support writing '{format}' format."); + } + writer.WritePropertyName("scope"u8); + writer.WriteStringValue(Scope); + if (Optional.IsCollectionDefined(Items)) + { + writer.WritePropertyName("items"u8); + writer.WriteStartArray(); + foreach (InternalItemParam item in Items) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(PreviousUpdateId)) + { + writer.WritePropertyName("previous_update_id"u8); + writer.WriteStringValue(PreviousUpdateId); + } + if (Optional.IsDefined(UpdateDelay)) + { + writer.WritePropertyName("update_delay"u8); + writer.WriteNumberValue(UpdateDelay.Value); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalMemoryUpdateOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalMemoryUpdateOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalMemoryUpdateOptions)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalMemoryUpdateOptions(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalMemoryUpdateOptions DeserializeInternalMemoryUpdateOptions(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string scope = default; + IList items = default; + string previousUpdateId = default; + int? updateDelay = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("scope"u8)) + { + scope = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("items"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalItemParam.DeserializeInternalItemParam(item, options)); + } + items = array; + continue; + } + if (prop.NameEquals("previous_update_id"u8)) + { + previousUpdateId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("update_delay"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + updateDelay = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalMemoryUpdateOptions(scope, items ?? new ChangeTrackingList(), previousUpdateId, updateDelay, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalMemoryUpdateOptions)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalMemoryUpdateOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalMemoryUpdateOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalMemoryUpdateOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalMemoryUpdateOptions)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(InternalMemoryUpdateOptions internalMemoryUpdateOptions) + { + if (internalMemoryUpdateOptions == null) + { + return null; + } + return BinaryContent.Create(internalMemoryUpdateOptions, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalMemoryUpdateOptions.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMemoryUpdateOptions.cs new file mode 100644 index 000000000000..fda5fe5b8024 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalMemoryUpdateOptions.cs @@ -0,0 +1,61 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects +{ + internal partial class InternalMemoryUpdateOptions + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The namespace that logically groups and isolates memories, such as a user ID. + internal InternalMemoryUpdateOptions(string scope) + { + Scope = scope; + Items = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The namespace that logically groups and isolates memories, such as a user ID. + /// Conversation items from which to extract memories. + /// The unique ID of the previous update request, enabling incremental memory updates from where the last operation left off. + /// + /// Timeout period before processing the memory update in seconds. + /// If a new update request is received during this period, it will cancel the current request and reset the timeout. + /// Set to 0 to immediately trigger the update without delay. + /// Defaults to 300 (5 minutes). + /// + /// Keeps track of any properties unknown to the library. + internal InternalMemoryUpdateOptions(string scope, IList items, string previousUpdateId, int? updateDelay, IDictionary additionalBinaryDataProperties) + { + Scope = scope; + Items = items; + PreviousUpdateId = previousUpdateId; + UpdateDelay = updateDelay; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The namespace that logically groups and isolates memories, such as a user ID. + public string Scope { get; } + + /// Conversation items from which to extract memories. + public IList Items { get; } + + /// The unique ID of the previous update request, enabling incremental memory updates from where the last operation left off. + public string PreviousUpdateId { get; } + + /// + /// Timeout period before processing the memory update in seconds. + /// If a new update request is received during this period, it will cancel the current request and reset the timeout. + /// Set to 0 to immediately trigger the update without delay. + /// Defaults to 300 (5 minutes). + /// + public int? UpdateDelay { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalPromptAgentDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalPromptAgentDefinition.Serialization.cs new file mode 100644 index 000000000000..4f178722d5ab --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalPromptAgentDefinition.Serialization.cs @@ -0,0 +1,282 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects +{ + internal partial class InternalPromptAgentDefinition : InternalAgentDefinition, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalPromptAgentDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalPromptAgentDefinition)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("model"u8); + writer.WriteStringValue(Model); + if (Optional.IsDefined(Instructions)) + { + writer.WritePropertyName("instructions"u8); + writer.WriteStringValue(Instructions); + } + if (Optional.IsDefined(Temperature)) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + if (Optional.IsDefined(TopP)) + { + writer.WritePropertyName("top_p"u8); + writer.WriteNumberValue(TopP.Value); + } + if (Optional.IsDefined(Reasoning)) + { + writer.WritePropertyName("reasoning"u8); + writer.WriteObjectValue(Reasoning, options); + } + if (Optional.IsCollectionDefined(Tools)) + { + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (InternalTool item in Tools) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Text)) + { + writer.WritePropertyName("text"u8); + writer.WriteObjectValue(Text, options); + } + if (Optional.IsCollectionDefined(StructuredInputs)) + { + writer.WritePropertyName("structured_inputs"u8); + writer.WriteStartObject(); + foreach (var item in StructuredInputs) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalPromptAgentDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalPromptAgentDefinition)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalAgentDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalPromptAgentDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalPromptAgentDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalPromptAgentDefinition DeserializeInternalPromptAgentDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentKind kind = default; + RaiConfig raiConfig = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string model = default; + string instructions = default; + float? temperature = default; + float? topP = default; + InternalReasoning reasoning = default; + IList tools = default; + PromptAgentDefinitionText text = default; + IDictionary structuredInputs = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("kind"u8)) + { + kind = new AgentKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("rai_config"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + raiConfig = RaiConfig.DeserializeRaiConfig(prop.Value, options); + continue; + } + if (prop.NameEquals("model"u8)) + { + model = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("instructions"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + instructions = null; + continue; + } + instructions = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("temperature"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + temperature = null; + continue; + } + temperature = prop.Value.GetSingle(); + continue; + } + if (prop.NameEquals("top_p"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + topP = null; + continue; + } + topP = prop.Value.GetSingle(); + continue; + } + if (prop.NameEquals("reasoning"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + reasoning = null; + continue; + } + reasoning = InternalReasoning.DeserializeInternalReasoning(prop.Value, options); + continue; + } + if (prop.NameEquals("tools"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalTool.DeserializeInternalTool(item, options)); + } + tools = array; + continue; + } + if (prop.NameEquals("text"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + text = PromptAgentDefinitionText.DeserializePromptAgentDefinitionText(prop.Value, options); + continue; + } + if (prop.NameEquals("structured_inputs"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + dictionary.Add(prop0.Name, StructuredInputDefinition.DeserializeStructuredInputDefinition(prop0.Value, options)); + } + structuredInputs = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalPromptAgentDefinition( + kind, + raiConfig, + additionalBinaryDataProperties, + model, + instructions, + temperature, + topP, + reasoning, + tools ?? new ChangeTrackingList(), + text, + structuredInputs ?? new ChangeTrackingDictionary()); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalPromptAgentDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalPromptAgentDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalPromptAgentDefinition)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalAgentDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalPromptAgentDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalPromptAgentDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalPromptAgentDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalPromptAgentDefinition.cs new file mode 100644 index 000000000000..3cf26874e491 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalPromptAgentDefinition.cs @@ -0,0 +1,99 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects +{ + internal partial class InternalPromptAgentDefinition : InternalAgentDefinition + { + /// Initializes a new instance of . + /// The model deployment to use for this agent. + /// is null. + public InternalPromptAgentDefinition(string model) : base(AgentKind.Prompt) + { + Argument.AssertNotNull(model, nameof(model)); + + Model = model; + Tools = new ChangeTrackingList(); + StructuredInputs = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// + /// Configuration for Responsible AI (RAI) content filtering and safety features. + /// Keeps track of any properties unknown to the library. + /// The model deployment to use for this agent. + /// A system (or developer) message inserted into the model's context. + /// + /// 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. + /// We generally recommend altering this or `top_p` but not both. + /// + /// + /// 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. + /// + /// + /// + /// An array of tools the model may call while generating a response. You + /// can specify which tool to use by setting the `tool_choice` parameter. + /// + /// Configuration options for a text response from the model. Can be plain text or structured JSON data. + /// Set of structured inputs that can participate in prompt template substitution or tool argument bindings. + internal InternalPromptAgentDefinition(AgentKind kind, RaiConfig raiConfig, IDictionary additionalBinaryDataProperties, string model, string instructions, float? temperature, float? topP, InternalReasoning reasoning, IList tools, PromptAgentDefinitionText text, IDictionary structuredInputs) : base(kind, raiConfig, additionalBinaryDataProperties) + { + Model = model; + Instructions = instructions; + Temperature = temperature; + TopP = topP; + Reasoning = reasoning; + Tools = tools; + Text = text; + StructuredInputs = structuredInputs; + } + + /// The model deployment to use for this agent. + public string Model { get; set; } + + /// A system (or developer) message inserted into the model's context. + public string Instructions { get; set; } + + /// + /// 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. + /// We generally recommend altering this or `top_p` but not both. + /// + public float? Temperature { get; set; } + + /// + /// 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. + /// + public float? TopP { get; set; } + + /// Gets or sets the Reasoning. + public InternalReasoning Reasoning { get; set; } + + /// + /// An array of tools the model may call while generating a response. You + /// can specify which tool to use by setting the `tool_choice` parameter. + /// + public IList Tools { get; } + + /// Configuration options for a text response from the model. Can be plain text or structured JSON data. + public PromptAgentDefinitionText Text { get; set; } + + /// Set of structured inputs that can participate in prompt template substitution or tool argument bindings. + public IDictionary StructuredInputs { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalRankingOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalRankingOptions.Serialization.cs new file mode 100644 index 000000000000..9681bb7d5dc4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalRankingOptions.Serialization.cs @@ -0,0 +1,156 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalRankingOptions : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalRankingOptions)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Ranker)) + { + writer.WritePropertyName("ranker"u8); + writer.WriteStringValue(Ranker.Value.ToString()); + } + if (Optional.IsDefined(ScoreThreshold)) + { + writer.WritePropertyName("score_threshold"u8); + writer.WriteNumberValue(ScoreThreshold.Value); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalRankingOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalRankingOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalRankingOptions)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalRankingOptions(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalRankingOptions DeserializeInternalRankingOptions(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RankingOptionsRanker? ranker = default; + float? scoreThreshold = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("ranker"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + ranker = new RankingOptionsRanker(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("score_threshold"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + scoreThreshold = prop.Value.GetSingle(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalRankingOptions(ranker, scoreThreshold, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalRankingOptions)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalRankingOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalRankingOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalRankingOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalRankingOptions)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalRankingOptions.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalRankingOptions.cs new file mode 100644 index 000000000000..1a7309395e70 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalRankingOptions.cs @@ -0,0 +1,37 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalRankingOptions + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public InternalRankingOptions() + { + } + + /// Initializes a new instance of . + /// The ranker to use for the file search. + /// The score threshold for the file search, a number between 0 and 1. Numbers closer to 1 will attempt to return only the most relevant results, but may return fewer results. + /// Keeps track of any properties unknown to the library. + internal InternalRankingOptions(RankingOptionsRanker? ranker, float? scoreThreshold, IDictionary additionalBinaryDataProperties) + { + Ranker = ranker; + ScoreThreshold = scoreThreshold; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The ranker to use for the file search. + public RankingOptionsRanker? Ranker { get; set; } + + /// The score threshold for the file search, a number between 0 and 1. Numbers closer to 1 will attempt to return only the most relevant results, but may return fewer results. + public float? ScoreThreshold { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalReasoning.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalReasoning.Serialization.cs new file mode 100644 index 000000000000..6edf625a3051 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalReasoning.Serialization.cs @@ -0,0 +1,174 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalReasoning : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalReasoning)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Effort)) + { + writer.WritePropertyName("effort"u8); + writer.WriteStringValue(Effort.Value.ToString()); + } + if (Optional.IsDefined(Summary)) + { + writer.WritePropertyName("summary"u8); + writer.WriteStringValue(Summary.Value.ToString()); + } + if (Optional.IsDefined(GenerateSummary)) + { + writer.WritePropertyName("generate_summary"u8); + writer.WriteStringValue(GenerateSummary.Value.ToString()); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalReasoning IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalReasoning JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalReasoning)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalReasoning(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalReasoning DeserializeInternalReasoning(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ReasoningEffort? effort = default; + ReasoningSummary? summary = default; + ReasoningGenerateSummary? generateSummary = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("effort"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + effort = null; + continue; + } + effort = new ReasoningEffort(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("summary"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + summary = null; + continue; + } + summary = new ReasoningSummary(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("generate_summary"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + generateSummary = null; + continue; + } + generateSummary = new ReasoningGenerateSummary(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalReasoning(effort, summary, generateSummary, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalReasoning)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalReasoning IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalReasoning PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalReasoning(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalReasoning)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalReasoning.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalReasoning.cs new file mode 100644 index 000000000000..e26a1b61420f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalReasoning.cs @@ -0,0 +1,50 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalReasoning + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public InternalReasoning() + { + } + + /// Initializes a new instance of . + /// + /// + /// A summary of the reasoning performed by the model. This can be + /// useful for debugging and understanding the model's reasoning process. + /// One of `auto`, `concise`, or `detailed`. + /// + /// **Deprecated**: use `summary` instead. A summary of the reasoning performed by the model. This can be useful for debugging and understanding the model's reasoning process. One of `auto`, `concise`, or `detailed`. + /// Keeps track of any properties unknown to the library. + internal InternalReasoning(ReasoningEffort? effort, ReasoningSummary? summary, ReasoningGenerateSummary? generateSummary, IDictionary additionalBinaryDataProperties) + { + Effort = effort; + Summary = summary; + GenerateSummary = generateSummary; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Effort. + public ReasoningEffort? Effort { get; set; } + + /// + /// A summary of the reasoning performed by the model. This can be + /// useful for debugging and understanding the model's reasoning process. + /// One of `auto`, `concise`, or `detailed`. + /// + public ReasoningSummary? Summary { get; set; } + + /// **Deprecated**: use `summary` instead. A summary of the reasoning performed by the model. This can be useful for debugging and understanding the model's reasoning process. One of `auto`, `concise`, or `detailed`. + public ReasoningGenerateSummary? GenerateSummary { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalReasoningItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalReasoningItemParam.Serialization.cs new file mode 100644 index 000000000000..9450c479ced3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalReasoningItemParam.Serialization.cs @@ -0,0 +1,157 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalReasoningItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalReasoningItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalReasoningItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(EncryptedContent)) + { + writer.WritePropertyName("encrypted_content"u8); + writer.WriteStringValue(EncryptedContent); + } + writer.WritePropertyName("summary"u8); + writer.WriteStartArray(); + foreach (InternalReasoningItemSummaryPart item in Summary) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalReasoningItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalReasoningItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalReasoningItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalReasoningItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalReasoningItemParam DeserializeInternalReasoningItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string encryptedContent = default; + IList summary = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ItemType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("encrypted_content"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + encryptedContent = null; + continue; + } + encryptedContent = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("summary"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalReasoningItemSummaryPart.DeserializeInternalReasoningItemSummaryPart(item, options)); + } + summary = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalReasoningItemParam(@type, additionalBinaryDataProperties, encryptedContent, summary); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalReasoningItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalReasoningItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalReasoningItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalReasoningItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalReasoningItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalReasoningItemParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalReasoningItemParam.cs new file mode 100644 index 000000000000..26654e21788b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalReasoningItemParam.cs @@ -0,0 +1,47 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalReasoningItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// Reasoning text contents. + /// is null. + public InternalReasoningItemParam(IEnumerable summary) : base(ItemType.Reasoning) + { + Argument.AssertNotNull(summary, nameof(summary)); + + Summary = summary.ToList(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// + /// The encrypted content of the reasoning item - populated when a response is + /// generated with `reasoning.encrypted_content` in the `include` parameter. + /// + /// Reasoning text contents. + internal InternalReasoningItemParam(ItemType @type, IDictionary additionalBinaryDataProperties, string encryptedContent, IList summary) : base(@type, additionalBinaryDataProperties) + { + EncryptedContent = encryptedContent; + Summary = summary; + } + + /// + /// The encrypted content of the reasoning item - populated when a response is + /// generated with `reasoning.encrypted_content` in the `include` parameter. + /// + public string EncryptedContent { get; set; } + + /// Reasoning text contents. + public IList Summary { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalReasoningItemSummaryPart.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalReasoningItemSummaryPart.Serialization.cs new file mode 100644 index 000000000000..cebe01760d8f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalReasoningItemSummaryPart.Serialization.cs @@ -0,0 +1,133 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + [PersistableModelProxy(typeof(UnknownReasoningItemSummaryPart))] + internal abstract partial class InternalReasoningItemSummaryPart : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalReasoningItemSummaryPart() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalReasoningItemSummaryPart)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalReasoningItemSummaryPart IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalReasoningItemSummaryPart JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalReasoningItemSummaryPart)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalReasoningItemSummaryPart(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalReasoningItemSummaryPart DeserializeInternalReasoningItemSummaryPart(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "summary_text": + return InternalReasoningItemSummaryTextPart.DeserializeInternalReasoningItemSummaryTextPart(element, options); + } + } + return UnknownReasoningItemSummaryPart.DeserializeUnknownReasoningItemSummaryPart(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalReasoningItemSummaryPart)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalReasoningItemSummaryPart IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalReasoningItemSummaryPart PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalReasoningItemSummaryPart(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalReasoningItemSummaryPart)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalReasoningItemSummaryPart.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalReasoningItemSummaryPart.cs new file mode 100644 index 000000000000..9c90e84b6c68 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalReasoningItemSummaryPart.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal abstract partial class InternalReasoningItemSummaryPart + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + private protected InternalReasoningItemSummaryPart(ReasoningItemSummaryPartType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalReasoningItemSummaryPart(ReasoningItemSummaryPartType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Type. + internal ReasoningItemSummaryPartType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalReasoningItemSummaryTextPart.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalReasoningItemSummaryTextPart.Serialization.cs new file mode 100644 index 000000000000..8f1d50eb363c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalReasoningItemSummaryTextPart.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalReasoningItemSummaryTextPart : InternalReasoningItemSummaryPart, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalReasoningItemSummaryTextPart() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalReasoningItemSummaryTextPart)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalReasoningItemSummaryTextPart IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalReasoningItemSummaryTextPart)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalReasoningItemSummaryPart JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalReasoningItemSummaryTextPart)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalReasoningItemSummaryTextPart(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalReasoningItemSummaryTextPart DeserializeInternalReasoningItemSummaryTextPart(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ReasoningItemSummaryPartType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string text = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ReasoningItemSummaryPartType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("text"u8)) + { + text = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalReasoningItemSummaryTextPart(@type, additionalBinaryDataProperties, text); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalReasoningItemSummaryTextPart)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalReasoningItemSummaryTextPart IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalReasoningItemSummaryTextPart)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalReasoningItemSummaryPart PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalReasoningItemSummaryTextPart(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalReasoningItemSummaryTextPart)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalReasoningItemSummaryTextPart.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalReasoningItemSummaryTextPart.cs new file mode 100644 index 000000000000..3f2cad580997 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalReasoningItemSummaryTextPart.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalReasoningItemSummaryTextPart : InternalReasoningItemSummaryPart + { + /// Initializes a new instance of . + /// + /// is null. + public InternalReasoningItemSummaryTextPart(string text) : base(ReasoningItemSummaryPartType.SummaryText) + { + Argument.AssertNotNull(text, nameof(text)); + + Text = text; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// + internal InternalReasoningItemSummaryTextPart(ReasoningItemSummaryPartType @type, IDictionary additionalBinaryDataProperties, string text) : base(@type, additionalBinaryDataProperties) + { + Text = text; + } + + /// Gets the Text. + public string Text { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponseTextFormatConfiguration.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponseTextFormatConfiguration.Serialization.cs new file mode 100644 index 000000000000..339b61dd9a5e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponseTextFormatConfiguration.Serialization.cs @@ -0,0 +1,137 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + [PersistableModelProxy(typeof(UnknownResponseTextFormatConfiguration))] + internal abstract partial class InternalResponseTextFormatConfiguration : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalResponseTextFormatConfiguration() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfiguration)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponseTextFormatConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalResponseTextFormatConfiguration JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfiguration)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponseTextFormatConfiguration(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalResponseTextFormatConfiguration DeserializeInternalResponseTextFormatConfiguration(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "text": + return InternalResponseTextFormatConfigurationText.DeserializeInternalResponseTextFormatConfigurationText(element, options); + case "json_object": + return InternalResponseTextFormatConfigurationJsonObject.DeserializeInternalResponseTextFormatConfigurationJsonObject(element, options); + case "json_schema": + return InternalResponseTextFormatConfigurationJsonSchema.DeserializeInternalResponseTextFormatConfigurationJsonSchema(element, options); + } + } + return UnknownResponseTextFormatConfiguration.DeserializeUnknownResponseTextFormatConfiguration(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfiguration)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponseTextFormatConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalResponseTextFormatConfiguration PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponseTextFormatConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfiguration)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponseTextFormatConfiguration.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponseTextFormatConfiguration.cs new file mode 100644 index 000000000000..134c9b052903 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponseTextFormatConfiguration.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal abstract partial class InternalResponseTextFormatConfiguration + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + private protected InternalResponseTextFormatConfiguration(ResponseTextFormatConfigurationType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalResponseTextFormatConfiguration(ResponseTextFormatConfigurationType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Type. + internal ResponseTextFormatConfigurationType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponseTextFormatConfigurationJsonObject.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponseTextFormatConfigurationJsonObject.Serialization.cs new file mode 100644 index 000000000000..a699567a2aca --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponseTextFormatConfigurationJsonObject.Serialization.cs @@ -0,0 +1,118 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalResponseTextFormatConfigurationJsonObject : InternalResponseTextFormatConfiguration, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfigurationJsonObject)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponseTextFormatConfigurationJsonObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponseTextFormatConfigurationJsonObject)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalResponseTextFormatConfiguration JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfigurationJsonObject)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponseTextFormatConfigurationJsonObject(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalResponseTextFormatConfigurationJsonObject DeserializeInternalResponseTextFormatConfigurationJsonObject(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResponseTextFormatConfigurationType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ResponseTextFormatConfigurationType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalResponseTextFormatConfigurationJsonObject(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfigurationJsonObject)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponseTextFormatConfigurationJsonObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponseTextFormatConfigurationJsonObject)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalResponseTextFormatConfiguration PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponseTextFormatConfigurationJsonObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfigurationJsonObject)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponseTextFormatConfigurationJsonObject.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponseTextFormatConfigurationJsonObject.cs new file mode 100644 index 000000000000..8e3093103d10 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponseTextFormatConfigurationJsonObject.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalResponseTextFormatConfigurationJsonObject : InternalResponseTextFormatConfiguration + { + /// Initializes a new instance of . + public InternalResponseTextFormatConfigurationJsonObject() : base(ResponseTextFormatConfigurationType.JsonObject) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalResponseTextFormatConfigurationJsonObject(ResponseTextFormatConfigurationType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponseTextFormatConfigurationJsonSchema.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponseTextFormatConfigurationJsonSchema.Serialization.cs new file mode 100644 index 000000000000..6e30ac954171 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponseTextFormatConfigurationJsonSchema.Serialization.cs @@ -0,0 +1,202 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalResponseTextFormatConfigurationJsonSchema : InternalResponseTextFormatConfiguration, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalResponseTextFormatConfigurationJsonSchema() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfigurationJsonSchema)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("schema"u8); + writer.WriteStartObject(); + foreach (var item in Schema) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#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(); + if (Optional.IsDefined(Strict)) + { + writer.WritePropertyName("strict"u8); + writer.WriteBooleanValue(Strict.Value); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponseTextFormatConfigurationJsonSchema IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponseTextFormatConfigurationJsonSchema)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalResponseTextFormatConfiguration JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfigurationJsonSchema)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponseTextFormatConfigurationJsonSchema(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalResponseTextFormatConfigurationJsonSchema DeserializeInternalResponseTextFormatConfigurationJsonSchema(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResponseTextFormatConfigurationType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string description = default; + string name = default; + IDictionary schema = default; + bool? strict = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ResponseTextFormatConfigurationType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("schema"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + schema = dictionary; + continue; + } + if (prop.NameEquals("strict"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + strict = null; + continue; + } + strict = prop.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalResponseTextFormatConfigurationJsonSchema( + @type, + additionalBinaryDataProperties, + description, + name, + schema, + strict); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfigurationJsonSchema)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponseTextFormatConfigurationJsonSchema IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponseTextFormatConfigurationJsonSchema)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalResponseTextFormatConfiguration PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponseTextFormatConfigurationJsonSchema(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfigurationJsonSchema)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponseTextFormatConfigurationJsonSchema.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponseTextFormatConfigurationJsonSchema.cs new file mode 100644 index 000000000000..4624002268a1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponseTextFormatConfigurationJsonSchema.cs @@ -0,0 +1,106 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalResponseTextFormatConfigurationJsonSchema : InternalResponseTextFormatConfiguration + { + /// Initializes a new instance of . + /// + /// The name of the response format. Must be a-z, A-Z, 0-9, or contain + /// underscores and dashes, with a maximum length of 64. + /// + /// + /// or is null. + public InternalResponseTextFormatConfigurationJsonSchema(string name, IDictionary schema) : base(ResponseTextFormatConfigurationType.JsonSchema) + { + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(schema, nameof(schema)); + + Name = name; + Schema = schema; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// + /// A description of what the response format is for, used by the model to + /// determine how to respond in the format. + /// + /// + /// The name of the response format. Must be a-z, A-Z, 0-9, or contain + /// underscores and dashes, with a maximum length of 64. + /// + /// + /// + /// Whether to enable strict schema adherence when generating the output. + /// If set to true, the model will always follow the exact schema defined + /// in the `schema` field. Only a subset of JSON Schema is supported when + /// `strict` is `true`. To learn more, read the [Structured Outputs + /// guide](https://platform.openai.com/docs/guides/structured-outputs). + /// + internal InternalResponseTextFormatConfigurationJsonSchema(ResponseTextFormatConfigurationType @type, IDictionary additionalBinaryDataProperties, string description, string name, IDictionary schema, bool? strict) : base(@type, additionalBinaryDataProperties) + { + Description = description; + Name = name; + Schema = schema; + Strict = strict; + } + + /// + /// A description of what the response format is for, used by the model to + /// determine how to respond in the format. + /// + public string Description { get; set; } + + /// + /// The name of the response format. Must be a-z, A-Z, 0-9, or contain + /// underscores and dashes, with a maximum length of 64. + /// + public string Name { get; set; } + + /// + /// Gets the Schema. + /// 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" }. + /// + /// + /// + /// + public IDictionary Schema { get; } + + /// + /// Whether to enable strict schema adherence when generating the output. + /// If set to true, the model will always follow the exact schema defined + /// in the `schema` field. Only a subset of JSON Schema is supported when + /// `strict` is `true`. To learn more, read the [Structured Outputs + /// guide](https://platform.openai.com/docs/guides/structured-outputs). + /// + public bool? Strict { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponseTextFormatConfigurationText.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponseTextFormatConfigurationText.Serialization.cs new file mode 100644 index 000000000000..6c89a530399f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponseTextFormatConfigurationText.Serialization.cs @@ -0,0 +1,118 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalResponseTextFormatConfigurationText : InternalResponseTextFormatConfiguration, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfigurationText)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponseTextFormatConfigurationText IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponseTextFormatConfigurationText)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalResponseTextFormatConfiguration JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfigurationText)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponseTextFormatConfigurationText(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalResponseTextFormatConfigurationText DeserializeInternalResponseTextFormatConfigurationText(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResponseTextFormatConfigurationType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ResponseTextFormatConfigurationType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalResponseTextFormatConfigurationText(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfigurationText)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponseTextFormatConfigurationText IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponseTextFormatConfigurationText)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalResponseTextFormatConfiguration PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponseTextFormatConfigurationText(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfigurationText)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponseTextFormatConfigurationText.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponseTextFormatConfigurationText.cs new file mode 100644 index 000000000000..8ca9f61f2a8e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponseTextFormatConfigurationText.cs @@ -0,0 +1,24 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalResponseTextFormatConfigurationText : InternalResponseTextFormatConfiguration + { + /// Initializes a new instance of . + public InternalResponseTextFormatConfigurationText() : base(ResponseTextFormatConfigurationType.Text) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalResponseTextFormatConfigurationText(ResponseTextFormatConfigurationType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesAssistantMessageItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesAssistantMessageItemParam.Serialization.cs new file mode 100644 index 000000000000..32fad9bb4547 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesAssistantMessageItemParam.Serialization.cs @@ -0,0 +1,144 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalResponsesAssistantMessageItemParam : InternalResponsesMessageItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalResponsesAssistantMessageItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesAssistantMessageItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("content"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Content); +#else + using (JsonDocument document = JsonDocument.Parse(Content)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponsesAssistantMessageItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesAssistantMessageItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesAssistantMessageItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponsesAssistantMessageItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalResponsesAssistantMessageItemParam DeserializeInternalResponsesAssistantMessageItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ResponsesMessageRole role = default; + BinaryData content = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ItemType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("role"u8)) + { + role = new ResponsesMessageRole(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("content"u8)) + { + content = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalResponsesAssistantMessageItemParam(@type, additionalBinaryDataProperties, role, content); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponsesAssistantMessageItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponsesAssistantMessageItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesAssistantMessageItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponsesAssistantMessageItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponsesAssistantMessageItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesAssistantMessageItemParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesAssistantMessageItemParam.cs new file mode 100644 index 000000000000..ef19bf25e450 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesAssistantMessageItemParam.cs @@ -0,0 +1,75 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalResponsesAssistantMessageItemParam : InternalResponsesMessageItemParam + { + /// Initializes a new instance of . + /// The content associated with the message. + /// is null. + public InternalResponsesAssistantMessageItemParam(BinaryData content) : base(ResponsesMessageRole.Assistant) + { + Argument.AssertNotNull(content, nameof(content)); + + Content = content; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The role associated with the message. + /// The content associated with the message. + internal InternalResponsesAssistantMessageItemParam(ItemType @type, IDictionary additionalBinaryDataProperties, ResponsesMessageRole role, BinaryData content) : base(@type, additionalBinaryDataProperties, role) + { + Content = content; + } + + /// + /// The content associated with the message. + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// where T is of type . + /// + /// + /// + /// + /// + /// 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" }. + /// + /// + /// + /// + public BinaryData Content { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesDeveloperMessageItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesDeveloperMessageItemParam.Serialization.cs new file mode 100644 index 000000000000..f98a606741a1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesDeveloperMessageItemParam.Serialization.cs @@ -0,0 +1,144 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalResponsesDeveloperMessageItemParam : InternalResponsesMessageItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalResponsesDeveloperMessageItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesDeveloperMessageItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("content"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Content); +#else + using (JsonDocument document = JsonDocument.Parse(Content)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponsesDeveloperMessageItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesDeveloperMessageItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesDeveloperMessageItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponsesDeveloperMessageItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalResponsesDeveloperMessageItemParam DeserializeInternalResponsesDeveloperMessageItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ResponsesMessageRole role = default; + BinaryData content = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ItemType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("role"u8)) + { + role = new ResponsesMessageRole(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("content"u8)) + { + content = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalResponsesDeveloperMessageItemParam(@type, additionalBinaryDataProperties, role, content); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponsesDeveloperMessageItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponsesDeveloperMessageItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesDeveloperMessageItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponsesDeveloperMessageItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponsesDeveloperMessageItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesDeveloperMessageItemParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesDeveloperMessageItemParam.cs new file mode 100644 index 000000000000..6680f5da3852 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesDeveloperMessageItemParam.cs @@ -0,0 +1,75 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalResponsesDeveloperMessageItemParam : InternalResponsesMessageItemParam + { + /// Initializes a new instance of . + /// The content associated with the message. + /// is null. + public InternalResponsesDeveloperMessageItemParam(BinaryData content) : base(ResponsesMessageRole.Developer) + { + Argument.AssertNotNull(content, nameof(content)); + + Content = content; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The role associated with the message. + /// The content associated with the message. + internal InternalResponsesDeveloperMessageItemParam(ItemType @type, IDictionary additionalBinaryDataProperties, ResponsesMessageRole role, BinaryData content) : base(@type, additionalBinaryDataProperties, role) + { + Content = content; + } + + /// + /// The content associated with the message. + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// where T is of type . + /// + /// + /// + /// + /// + /// 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" }. + /// + /// + /// + /// + public BinaryData Content { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesMessageItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesMessageItemParam.Serialization.cs new file mode 100644 index 000000000000..98890be34ab3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesMessageItemParam.Serialization.cs @@ -0,0 +1,124 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalResponsesMessageItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalResponsesMessageItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesMessageItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("role"u8); + writer.WriteStringValue(Role.ToString()); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponsesMessageItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesMessageItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesMessageItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponsesMessageItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalResponsesMessageItemParam DeserializeInternalResponsesMessageItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("role"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "user": + return InternalResponsesUserMessageItemParam.DeserializeInternalResponsesUserMessageItemParam(element, options); + case "system": + return InternalResponsesSystemMessageItemParam.DeserializeInternalResponsesSystemMessageItemParam(element, options); + case "developer": + return InternalResponsesDeveloperMessageItemParam.DeserializeInternalResponsesDeveloperMessageItemParam(element, options); + case "assistant": + return InternalResponsesAssistantMessageItemParam.DeserializeInternalResponsesAssistantMessageItemParam(element, options); + } + } + return UnknownResponsesMessageItemParam.DeserializeUnknownResponsesMessageItemParam(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponsesMessageItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponsesMessageItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesMessageItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponsesMessageItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponsesMessageItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesMessageItemParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesMessageItemParam.cs new file mode 100644 index 000000000000..ec325b99bbd9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesMessageItemParam.cs @@ -0,0 +1,31 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class InternalResponsesMessageItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// The role associated with the message. + public InternalResponsesMessageItemParam(ResponsesMessageRole role) : base(ItemType.Message) + { + Role = role; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The role associated with the message. + internal InternalResponsesMessageItemParam(ItemType @type, IDictionary additionalBinaryDataProperties, ResponsesMessageRole role) : base(@type, additionalBinaryDataProperties) + { + Role = role; + } + + /// The role associated with the message. + internal ResponsesMessageRole Role { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesSystemMessageItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesSystemMessageItemParam.Serialization.cs new file mode 100644 index 000000000000..6ac36380b3d8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesSystemMessageItemParam.Serialization.cs @@ -0,0 +1,144 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalResponsesSystemMessageItemParam : InternalResponsesMessageItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalResponsesSystemMessageItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesSystemMessageItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("content"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Content); +#else + using (JsonDocument document = JsonDocument.Parse(Content)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponsesSystemMessageItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesSystemMessageItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesSystemMessageItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponsesSystemMessageItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalResponsesSystemMessageItemParam DeserializeInternalResponsesSystemMessageItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ResponsesMessageRole role = default; + BinaryData content = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ItemType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("role"u8)) + { + role = new ResponsesMessageRole(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("content"u8)) + { + content = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalResponsesSystemMessageItemParam(@type, additionalBinaryDataProperties, role, content); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponsesSystemMessageItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponsesSystemMessageItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesSystemMessageItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponsesSystemMessageItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponsesSystemMessageItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesSystemMessageItemParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesSystemMessageItemParam.cs new file mode 100644 index 000000000000..23c5501f7883 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesSystemMessageItemParam.cs @@ -0,0 +1,75 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalResponsesSystemMessageItemParam : InternalResponsesMessageItemParam + { + /// Initializes a new instance of . + /// The content associated with the message. + /// is null. + public InternalResponsesSystemMessageItemParam(BinaryData content) : base(ResponsesMessageRole.System) + { + Argument.AssertNotNull(content, nameof(content)); + + Content = content; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The role associated with the message. + /// The content associated with the message. + internal InternalResponsesSystemMessageItemParam(ItemType @type, IDictionary additionalBinaryDataProperties, ResponsesMessageRole role, BinaryData content) : base(@type, additionalBinaryDataProperties, role) + { + Content = content; + } + + /// + /// The content associated with the message. + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// where T is of type . + /// + /// + /// + /// + /// + /// 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" }. + /// + /// + /// + /// + public BinaryData Content { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesUserMessageItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesUserMessageItemParam.Serialization.cs new file mode 100644 index 000000000000..1bb09353ffd6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesUserMessageItemParam.Serialization.cs @@ -0,0 +1,144 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalResponsesUserMessageItemParam : InternalResponsesMessageItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalResponsesUserMessageItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesUserMessageItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("content"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Content); +#else + using (JsonDocument document = JsonDocument.Parse(Content)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponsesUserMessageItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalResponsesUserMessageItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesUserMessageItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponsesUserMessageItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalResponsesUserMessageItemParam DeserializeInternalResponsesUserMessageItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ResponsesMessageRole role = default; + BinaryData content = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ItemType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("role"u8)) + { + role = new ResponsesMessageRole(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("content"u8)) + { + content = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalResponsesUserMessageItemParam(@type, additionalBinaryDataProperties, role, content); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponsesUserMessageItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponsesUserMessageItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalResponsesUserMessageItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponsesUserMessageItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponsesUserMessageItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesUserMessageItemParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesUserMessageItemParam.cs new file mode 100644 index 000000000000..ef4867cef19c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalResponsesUserMessageItemParam.cs @@ -0,0 +1,75 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalResponsesUserMessageItemParam : InternalResponsesMessageItemParam + { + /// Initializes a new instance of . + /// The content associated with the message. + /// is null. + public InternalResponsesUserMessageItemParam(BinaryData content) : base(ResponsesMessageRole.User) + { + Argument.AssertNotNull(content, nameof(content)); + + Content = content; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The role associated with the message. + /// The content associated with the message. + internal InternalResponsesUserMessageItemParam(ItemType @type, IDictionary additionalBinaryDataProperties, ResponsesMessageRole role, BinaryData content) : base(@type, additionalBinaryDataProperties, role) + { + Content = content; + } + + /// + /// The content associated with the message. + /// To assign an object to this property use . + /// To assign an already formatted json string to this property use . + /// + /// + /// Supported types: + /// + /// + /// . + /// + /// + /// where T is of type . + /// + /// + /// + /// + /// + /// 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" }. + /// + /// + /// + /// + public BinaryData Content { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalTool.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalTool.Serialization.cs new file mode 100644 index 000000000000..fd917441a8ec --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalTool.Serialization.cs @@ -0,0 +1,169 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects +{ + [PersistableModelProxy(typeof(UnknownTool))] + internal abstract partial class InternalTool : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalTool)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalTool DeserializeInternalTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "function": + return InternalFunctionTool.DeserializeInternalFunctionTool(element, options); + case "file_search": + return InternalFileSearchTool.DeserializeInternalFileSearchTool(element, options); + case "computer_use_preview": + return InternalComputerUsePreviewTool.DeserializeInternalComputerUsePreviewTool(element, options); + case "web_search_preview": + return InternalWebSearchPreviewTool.DeserializeInternalWebSearchPreviewTool(element, options); + case "code_interpreter": + return InternalCodeInterpreterTool.DeserializeInternalCodeInterpreterTool(element, options); + case "image_generation": + return InternalImageGenTool.DeserializeInternalImageGenTool(element, options); + case "local_shell": + return InternalLocalShellTool.DeserializeInternalLocalShellTool(element, options); + case "mcp": + return InternalMCPTool.DeserializeInternalMCPTool(element, options); + case "bing_grounding": + return BingGroundingAgentTool.DeserializeBingGroundingAgentTool(element, options); + case "fabric_dataagent_preview": + return MicrosoftFabricAgentTool.DeserializeMicrosoftFabricAgentTool(element, options); + case "sharepoint_grounding_preview": + return SharepointAgentTool.DeserializeSharepointAgentTool(element, options); + case "azure_ai_search": + return AzureAISearchAgentTool.DeserializeAzureAISearchAgentTool(element, options); + case "openapi": + return OpenApiAgentTool.DeserializeOpenApiAgentTool(element, options); + case "bing_custom_search_preview": + return BingCustomSearchAgentTool.DeserializeBingCustomSearchAgentTool(element, options); + case "browser_automation_preview": + return BrowserAutomationAgentTool.DeserializeBrowserAutomationAgentTool(element, options); + case "azure_function": + return AzureFunctionAgentTool.DeserializeAzureFunctionAgentTool(element, options); + case "capture_structured_outputs": + return CaptureStructuredOutputsTool.DeserializeCaptureStructuredOutputsTool(element, options); + case "a2a_preview": + return A2ATool.DeserializeA2ATool(element, options); + case "memory_search": + return MemorySearchTool.DeserializeMemorySearchTool(element, options); + } + } + return UnknownTool.DeserializeUnknownTool(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalTool.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalTool.cs new file mode 100644 index 000000000000..71e30a32c36e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalTool.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects +{ + internal abstract partial class InternalTool + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + private protected InternalTool(ToolType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalTool(ToolType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Type. + internal ToolType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalTopLogProb.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalTopLogProb.Serialization.cs new file mode 100644 index 000000000000..fbaef49f3a95 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalTopLogProb.Serialization.cs @@ -0,0 +1,165 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalTopLogProb : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalTopLogProb() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalTopLogProb)} does not support writing '{format}' format."); + } + writer.WritePropertyName("token"u8); + writer.WriteStringValue(Token); + writer.WritePropertyName("logprob"u8); + writer.WriteNumberValue(Logprob); + writer.WritePropertyName("bytes"u8); + writer.WriteStartArray(); + foreach (int item in Bytes) + { + writer.WriteNumberValue(item); + } + writer.WriteEndArray(); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalTopLogProb IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalTopLogProb JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalTopLogProb)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalTopLogProb(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalTopLogProb DeserializeInternalTopLogProb(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string token = default; + float logprob = default; + IList bytes = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("token"u8)) + { + token = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("logprob"u8)) + { + logprob = prop.Value.GetSingle(); + continue; + } + if (prop.NameEquals("bytes"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(item.GetInt32()); + } + bytes = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalTopLogProb(token, logprob, bytes, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalTopLogProb)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalTopLogProb IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalTopLogProb PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalTopLogProb(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalTopLogProb)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalTopLogProb.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalTopLogProb.cs new file mode 100644 index 000000000000..64b017c8a10d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalTopLogProb.cs @@ -0,0 +1,54 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalTopLogProb + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// + /// + /// or is null. + public InternalTopLogProb(string token, float logprob, IEnumerable bytes) + { + Argument.AssertNotNull(token, nameof(token)); + Argument.AssertNotNull(bytes, nameof(bytes)); + + Token = token; + Logprob = logprob; + Bytes = bytes.ToList(); + } + + /// Initializes a new instance of . + /// + /// + /// + /// Keeps track of any properties unknown to the library. + internal InternalTopLogProb(string token, float logprob, IList bytes, IDictionary additionalBinaryDataProperties) + { + Token = token; + Logprob = logprob; + Bytes = bytes; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Token. + public string Token { get; } + + /// Gets the Logprob. + public float Logprob { get; } + + /// Gets the Bytes. + public IList Bytes { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalUpdateAgentRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalUpdateAgentRequest.Serialization.cs new file mode 100644 index 000000000000..86f973bccd0b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalUpdateAgentRequest.Serialization.cs @@ -0,0 +1,187 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + internal partial class InternalUpdateAgentRequest : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalUpdateAgentRequest() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalUpdateAgentRequest)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("definition"u8); + writer.WriteObjectValue(Definition, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalUpdateAgentRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalUpdateAgentRequest JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalUpdateAgentRequest)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalUpdateAgentRequest(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalUpdateAgentRequest DeserializeInternalUpdateAgentRequest(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary metadata = default; + string description = default; + Projects.OpenAI.AgentDefinition definition = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("metadata"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + metadata = dictionary; + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("definition"u8)) + { + DeserializeDefinitionValue(prop, ref definition); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalUpdateAgentRequest(metadata ?? new ChangeTrackingDictionary(), description, definition, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalUpdateAgentRequest)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalUpdateAgentRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalUpdateAgentRequest PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalUpdateAgentRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalUpdateAgentRequest)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalUpdateAgentRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalUpdateAgentRequest.cs new file mode 100644 index 000000000000..9947a69cc44b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalUpdateAgentRequest.cs @@ -0,0 +1,59 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + internal partial class InternalUpdateAgentRequest + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The agent definition. This can be a workflow, hosted agent, or a simple agent definition. + /// is null. + public InternalUpdateAgentRequest(Projects.OpenAI.AgentDefinition definition) + { + Argument.AssertNotNull(definition, nameof(definition)); + + Metadata = new ChangeTrackingDictionary(); + Definition = definition; + } + + /// Initializes a new instance of . + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + /// A human-readable description of the agent. + /// The agent definition. This can be a workflow, hosted agent, or a simple agent definition. + /// Keeps track of any properties unknown to the library. + internal InternalUpdateAgentRequest(IDictionary metadata, string description, Projects.OpenAI.AgentDefinition definition, IDictionary additionalBinaryDataProperties) + { + Metadata = metadata; + Description = description; + Definition = definition; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// 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, and querying for objects via API or the dashboard. + /// + /// Keys are strings with a maximum length of 64 characters. Values are strings + /// with a maximum length of 512 characters. + /// + public IDictionary Metadata { get; } + + /// A human-readable description of the agent. + public string Description { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalVectorStoreFileAttributes.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalVectorStoreFileAttributes.Serialization.cs new file mode 100644 index 000000000000..150bbfffb55b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalVectorStoreFileAttributes.Serialization.cs @@ -0,0 +1,171 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalVectorStoreFileAttributes : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalVectorStoreFileAttributes)} does not support writing '{format}' format."); + } + foreach (var item in AdditionalProperties) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + foreach (var item in AdditionalBooleanProperties) + { + writer.WritePropertyName(item.Key); + writer.WriteBooleanValue(item.Value); + } + foreach (var item in AdditionalInt32Properties) + { + writer.WritePropertyName(item.Key); + writer.WriteNumberValue(item.Value); + } + foreach (var item in AdditionalSingleProperties) + { + writer.WritePropertyName(item.Key); + writer.WriteNumberValue(item.Value); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalVectorStoreFileAttributes IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalVectorStoreFileAttributes JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalVectorStoreFileAttributes)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalVectorStoreFileAttributes(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalVectorStoreFileAttributes DeserializeInternalVectorStoreFileAttributes(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary additionalProperties = new ChangeTrackingDictionary(); + IDictionary additionalBooleanProperties = new ChangeTrackingDictionary(); + IDictionary additionalInt32Properties = new ChangeTrackingDictionary(); + IDictionary additionalSingleProperties = new ChangeTrackingDictionary(); + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + switch (prop.Value.ValueKind) + { + case JsonValueKind.String: + additionalProperties.Add(prop.Name, prop.Value.GetString()); + continue; + case JsonValueKind.True or JsonValueKind.False: + additionalBooleanProperties.Add(prop.Name, prop.Value.GetBoolean()); + continue; + case JsonValueKind.Number: + if (prop.Value.TryGetInt32(out int intValue)) + { + additionalInt32Properties.Add(prop.Name, intValue); + continue; + } + if (prop.Value.TryGetSingle(out float floatValue)) + { + additionalSingleProperties.Add(prop.Name, floatValue); + continue; + } + break; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalVectorStoreFileAttributes(additionalProperties, additionalBooleanProperties, additionalInt32Properties, additionalSingleProperties, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalVectorStoreFileAttributes)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalVectorStoreFileAttributes IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalVectorStoreFileAttributes PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalVectorStoreFileAttributes(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalVectorStoreFileAttributes)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalVectorStoreFileAttributes.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalVectorStoreFileAttributes.cs new file mode 100644 index 000000000000..36f919b5c88d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalVectorStoreFileAttributes.cs @@ -0,0 +1,56 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalVectorStoreFileAttributes + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + private IDictionary _additionalStringProperties; + private IDictionary _additionalBooleanProperties; + private IDictionary _additionalInt32Properties; + private IDictionary _additionalSingleProperties; + + /// Initializes a new instance of . + public InternalVectorStoreFileAttributes() + { + _additionalStringProperties = new ChangeTrackingDictionary(); + _additionalBooleanProperties = new ChangeTrackingDictionary(); + _additionalInt32Properties = new ChangeTrackingDictionary(); + _additionalSingleProperties = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// + /// + /// + /// + /// Keeps track of any properties unknown to the library. + internal InternalVectorStoreFileAttributes(IDictionary additionalProperties, IDictionary additionalBooleanProperties, IDictionary additionalInt32Properties, IDictionary additionalSingleProperties, IDictionary additionalBinaryDataProperties) + { + _additionalStringProperties = additionalProperties; + _additionalBooleanProperties = additionalBooleanProperties; + _additionalInt32Properties = additionalInt32Properties; + _additionalSingleProperties = additionalSingleProperties; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the AdditionalProperties. + public IDictionary AdditionalProperties => _additionalStringProperties; + + /// Gets the AdditionalBooleanProperties. + public IDictionary AdditionalBooleanProperties => _additionalBooleanProperties; + + /// Gets the AdditionalInt32Properties. + public IDictionary AdditionalInt32Properties => _additionalInt32Properties; + + /// Gets the AdditionalSingleProperties. + public IDictionary AdditionalSingleProperties => _additionalSingleProperties; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchAction.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchAction.Serialization.cs new file mode 100644 index 000000000000..611a398d81d3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchAction.Serialization.cs @@ -0,0 +1,137 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + [PersistableModelProxy(typeof(UnknownWebSearchAction))] + internal abstract partial class InternalWebSearchAction : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalWebSearchAction() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchAction)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToSerialString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalWebSearchAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual InternalWebSearchAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchAction)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalWebSearchAction(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalWebSearchAction DeserializeInternalWebSearchAction(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "find": + return InternalWebSearchActionFind.DeserializeInternalWebSearchActionFind(element, options); + case "open_page": + return InternalWebSearchActionOpenPage.DeserializeInternalWebSearchActionOpenPage(element, options); + case "search": + return InternalWebSearchActionSearch.DeserializeInternalWebSearchActionSearch(element, options); + } + } + return UnknownWebSearchAction.DeserializeUnknownWebSearchAction(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalWebSearchAction)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalWebSearchAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual InternalWebSearchAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalWebSearchAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalWebSearchAction)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchAction.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchAction.cs new file mode 100644 index 000000000000..372397a91f43 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchAction.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal abstract partial class InternalWebSearchAction + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + private protected InternalWebSearchAction(WebSearchActionType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal InternalWebSearchAction(WebSearchActionType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Type. + internal WebSearchActionType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchActionFind.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchActionFind.Serialization.cs new file mode 100644 index 000000000000..23893a69d4e9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchActionFind.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalWebSearchActionFind : InternalWebSearchAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalWebSearchActionFind() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchActionFind)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Url.AbsoluteUri); + writer.WritePropertyName("pattern"u8); + writer.WriteStringValue(Pattern); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalWebSearchActionFind IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalWebSearchActionFind)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalWebSearchAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchActionFind)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalWebSearchActionFind(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalWebSearchActionFind DeserializeInternalWebSearchActionFind(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + WebSearchActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + Uri url = default; + string pattern = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToWebSearchActionType(); + continue; + } + if (prop.NameEquals("url"u8)) + { + url = new Uri(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("pattern"u8)) + { + pattern = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalWebSearchActionFind(@type, additionalBinaryDataProperties, url, pattern); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalWebSearchActionFind)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalWebSearchActionFind IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalWebSearchActionFind)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalWebSearchAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalWebSearchActionFind(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalWebSearchActionFind)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchActionFind.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchActionFind.cs new file mode 100644 index 000000000000..8c07cc17a3c6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchActionFind.cs @@ -0,0 +1,43 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalWebSearchActionFind : InternalWebSearchAction + { + /// Initializes a new instance of . + /// The URL of the page searched for the pattern. + /// The pattern or text to search for within the page. + /// or is null. + public InternalWebSearchActionFind(Uri url, string pattern) : base(WebSearchActionType.Find) + { + Argument.AssertNotNull(url, nameof(url)); + Argument.AssertNotNull(pattern, nameof(pattern)); + + Url = url; + Pattern = pattern; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The URL of the page searched for the pattern. + /// The pattern or text to search for within the page. + internal InternalWebSearchActionFind(WebSearchActionType @type, IDictionary additionalBinaryDataProperties, Uri url, string pattern) : base(@type, additionalBinaryDataProperties) + { + Url = url; + Pattern = pattern; + } + + /// The URL of the page searched for the pattern. + public Uri Url { get; } + + /// The pattern or text to search for within the page. + public string Pattern { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchActionOpenPage.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchActionOpenPage.Serialization.cs new file mode 100644 index 000000000000..960038daa736 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchActionOpenPage.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalWebSearchActionOpenPage : InternalWebSearchAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalWebSearchActionOpenPage() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchActionOpenPage)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Url.AbsoluteUri); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalWebSearchActionOpenPage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalWebSearchActionOpenPage)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalWebSearchAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchActionOpenPage)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalWebSearchActionOpenPage(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalWebSearchActionOpenPage DeserializeInternalWebSearchActionOpenPage(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + WebSearchActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + Uri url = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToWebSearchActionType(); + continue; + } + if (prop.NameEquals("url"u8)) + { + url = new Uri(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalWebSearchActionOpenPage(@type, additionalBinaryDataProperties, url); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalWebSearchActionOpenPage)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalWebSearchActionOpenPage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalWebSearchActionOpenPage)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalWebSearchAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalWebSearchActionOpenPage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalWebSearchActionOpenPage)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchActionOpenPage.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchActionOpenPage.cs new file mode 100644 index 000000000000..337440ddc544 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchActionOpenPage.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalWebSearchActionOpenPage : InternalWebSearchAction + { + /// Initializes a new instance of . + /// The URL opened by the model. + /// is null. + public InternalWebSearchActionOpenPage(Uri url) : base(WebSearchActionType.OpenPage) + { + Argument.AssertNotNull(url, nameof(url)); + + Url = url; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The URL opened by the model. + internal InternalWebSearchActionOpenPage(WebSearchActionType @type, IDictionary additionalBinaryDataProperties, Uri url) : base(@type, additionalBinaryDataProperties) + { + Url = url; + } + + /// The URL opened by the model. + public Uri Url { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchActionSearch.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchActionSearch.Serialization.cs new file mode 100644 index 000000000000..04dd005279f3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchActionSearch.Serialization.cs @@ -0,0 +1,156 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalWebSearchActionSearch : InternalWebSearchAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalWebSearchActionSearch() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchActionSearch)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("query"u8); + writer.WriteStringValue(Query); + if (Optional.IsCollectionDefined(Sources)) + { + writer.WritePropertyName("sources"u8); + writer.WriteStartArray(); + foreach (WebSearchActionSearchSources item in Sources) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalWebSearchActionSearch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalWebSearchActionSearch)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalWebSearchAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchActionSearch)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalWebSearchActionSearch(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalWebSearchActionSearch DeserializeInternalWebSearchActionSearch(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + WebSearchActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string query = default; + IList sources = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToWebSearchActionType(); + continue; + } + if (prop.NameEquals("query"u8)) + { + query = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("sources"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(WebSearchActionSearchSources.DeserializeWebSearchActionSearchSources(item, options)); + } + sources = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalWebSearchActionSearch(@type, additionalBinaryDataProperties, query, sources ?? new ChangeTrackingList()); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalWebSearchActionSearch)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalWebSearchActionSearch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalWebSearchActionSearch)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalWebSearchAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalWebSearchActionSearch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalWebSearchActionSearch)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchActionSearch.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchActionSearch.cs new file mode 100644 index 000000000000..65e41b71daf8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchActionSearch.cs @@ -0,0 +1,41 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalWebSearchActionSearch : InternalWebSearchAction + { + /// Initializes a new instance of . + /// The search query. + /// is null. + public InternalWebSearchActionSearch(string query) : base(WebSearchActionType.Search) + { + Argument.AssertNotNull(query, nameof(query)); + + Query = query; + Sources = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The search query. + /// The sources used in the search. + internal InternalWebSearchActionSearch(WebSearchActionType @type, IDictionary additionalBinaryDataProperties, string query, IList sources) : base(@type, additionalBinaryDataProperties) + { + Query = query; + Sources = sources; + } + + /// The search query. + public string Query { get; } + + /// The sources used in the search. + public IList Sources { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchPreviewTool.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchPreviewTool.Serialization.cs new file mode 100644 index 000000000000..f0d0b0ee4fe1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchPreviewTool.Serialization.cs @@ -0,0 +1,149 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalWebSearchPreviewTool : InternalTool, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchPreviewTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(UserLocation)) + { + writer.WritePropertyName("user_location"u8); + writer.WriteObjectValue(UserLocation, options); + } + if (Optional.IsDefined(SearchContextSize)) + { + writer.WritePropertyName("search_context_size"u8); + writer.WriteStringValue(SearchContextSize.Value.ToString()); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalWebSearchPreviewTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalWebSearchPreviewTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchPreviewTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalWebSearchPreviewTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalWebSearchPreviewTool DeserializeInternalWebSearchPreviewTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + InternalLocation userLocation = default; + WebSearchPreviewToolSearchContextSize? searchContextSize = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("user_location"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + userLocation = null; + continue; + } + userLocation = InternalLocation.DeserializeInternalLocation(prop.Value, options); + continue; + } + if (prop.NameEquals("search_context_size"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + searchContextSize = new WebSearchPreviewToolSearchContextSize(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalWebSearchPreviewTool(@type, additionalBinaryDataProperties, userLocation, searchContextSize); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalWebSearchPreviewTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalWebSearchPreviewTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalWebSearchPreviewTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalWebSearchPreviewTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalWebSearchPreviewTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchPreviewTool.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchPreviewTool.cs new file mode 100644 index 000000000000..2981f9d38ad7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchPreviewTool.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalWebSearchPreviewTool : InternalTool + { + /// Initializes a new instance of . + public InternalWebSearchPreviewTool() : base(ToolType.WebSearchPreview) + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The user's location. + /// High level guidance for the amount of context window space to use for the search. One of `low`, `medium`, or `high`. `medium` is the default. + internal InternalWebSearchPreviewTool(ToolType @type, IDictionary additionalBinaryDataProperties, InternalLocation userLocation, WebSearchPreviewToolSearchContextSize? searchContextSize) : base(@type, additionalBinaryDataProperties) + { + UserLocation = userLocation; + SearchContextSize = searchContextSize; + } + + /// The user's location. + public InternalLocation UserLocation { get; set; } + + /// High level guidance for the amount of context window space to use for the search. One of `low`, `medium`, or `high`. `medium` is the default. + public WebSearchPreviewToolSearchContextSize? SearchContextSize { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchToolCallItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchToolCallItemParam.Serialization.cs new file mode 100644 index 000000000000..48e4f3889318 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchToolCallItemParam.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalWebSearchToolCallItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal InternalWebSearchToolCallItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchToolCallItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("action"u8); + writer.WriteObjectValue(Action, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalWebSearchToolCallItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalWebSearchToolCallItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchToolCallItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalWebSearchToolCallItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static InternalWebSearchToolCallItemParam DeserializeInternalWebSearchToolCallItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + InternalWebSearchAction action = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ItemType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("action"u8)) + { + action = InternalWebSearchAction.DeserializeInternalWebSearchAction(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new InternalWebSearchToolCallItemParam(@type, additionalBinaryDataProperties, action); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalWebSearchToolCallItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalWebSearchToolCallItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalWebSearchToolCallItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalWebSearchToolCallItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalWebSearchToolCallItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchToolCallItemParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchToolCallItemParam.cs new file mode 100644 index 000000000000..77ac453048f1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/InternalWebSearchToolCallItemParam.cs @@ -0,0 +1,44 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class InternalWebSearchToolCallItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// + /// An object describing the specific action taken in this web search call. + /// Includes details on how the model used the web (search, open_page, find). + /// + /// is null. + public InternalWebSearchToolCallItemParam(InternalWebSearchAction action) : base(ItemType.WebSearchCall) + { + Argument.AssertNotNull(action, nameof(action)); + + Action = action; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// + /// An object describing the specific action taken in this web search call. + /// Includes details on how the model used the web (search, open_page, find). + /// + internal InternalWebSearchToolCallItemParam(ItemType @type, IDictionary additionalBinaryDataProperties, InternalWebSearchAction action) : base(@type, additionalBinaryDataProperties) + { + Action = action; + } + + /// + /// An object describing the specific action taken in this web search call. + /// Includes details on how the model used the web (search, open_page, find). + /// + public InternalWebSearchAction Action { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ItemContentInputAudioFormat.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ItemContentInputAudioFormat.cs new file mode 100644 index 000000000000..993a5b385519 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ItemContentInputAudioFormat.cs @@ -0,0 +1,65 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal readonly partial struct ItemContentInputAudioFormat : IEquatable + { + private readonly string _value; + private const string Mp3Value = "mp3"; + private const string WavValue = "wav"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ItemContentInputAudioFormat(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Mp3. + public static ItemContentInputAudioFormat Mp3 { get; } = new ItemContentInputAudioFormat(Mp3Value); + + /// Gets the Wav. + public static ItemContentInputAudioFormat Wav { get; } = new ItemContentInputAudioFormat(WavValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ItemContentInputAudioFormat left, ItemContentInputAudioFormat right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ItemContentInputAudioFormat left, ItemContentInputAudioFormat right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ItemContentInputAudioFormat(string value) => new ItemContentInputAudioFormat(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ItemContentInputAudioFormat?(string value) => value == null ? null : new ItemContentInputAudioFormat(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ItemContentInputAudioFormat other && Equals(other); + + /// + public bool Equals(ItemContentInputAudioFormat other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ItemContentInputImageDetail1.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ItemContentInputImageDetail1.Serialization.cs new file mode 100644 index 000000000000..2a316d19a60c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ItemContentInputImageDetail1.Serialization.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; + +namespace OpenAI +{ + internal static partial class ItemContentInputImageDetail1Extensions + { + /// The value to serialize. + public static string ToSerialString(this ItemContentInputImageDetail1 value) => value switch + { + ItemContentInputImageDetail1.Low => "low", + ItemContentInputImageDetail1.High => "high", + ItemContentInputImageDetail1.Auto => "auto", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ItemContentInputImageDetail1 value.") + }; + + /// The value to deserialize. + public static ItemContentInputImageDetail1 ToItemContentInputImageDetail1(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "low")) + { + return ItemContentInputImageDetail1.Low; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "high")) + { + return ItemContentInputImageDetail1.High; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "auto")) + { + return ItemContentInputImageDetail1.Auto; + } + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ItemContentInputImageDetail1 value."); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ItemContentInputImageDetail1.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ItemContentInputImageDetail1.cs new file mode 100644 index 000000000000..1010d0926adc --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ItemContentInputImageDetail1.cs @@ -0,0 +1,17 @@ +// + +#nullable disable + +namespace OpenAI +{ + /// + internal enum ItemContentInputImageDetail1 + { + /// Low. + Low, + /// High. + High, + /// Auto. + Auto + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ItemContentType.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ItemContentType.Serialization.cs new file mode 100644 index 000000000000..eaa2f9a227e6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ItemContentType.Serialization.cs @@ -0,0 +1,58 @@ +// + +#nullable disable + +using System; + +namespace OpenAI +{ + internal static partial class ItemContentTypeExtensions + { + /// The value to serialize. + public static string ToSerialString(this ItemContentType value) => value switch + { + ItemContentType.InputText => "input_text", + ItemContentType.InputAudio => "input_audio", + ItemContentType.InputImage => "input_image", + ItemContentType.InputFile => "input_file", + ItemContentType.OutputText => "output_text", + ItemContentType.OutputAudio => "output_audio", + ItemContentType.Refusal => "refusal", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ItemContentType value.") + }; + + /// The value to deserialize. + public static ItemContentType ToItemContentType(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "input_text")) + { + return ItemContentType.InputText; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "input_audio")) + { + return ItemContentType.InputAudio; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "input_image")) + { + return ItemContentType.InputImage; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "input_file")) + { + return ItemContentType.InputFile; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "output_text")) + { + return ItemContentType.OutputText; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "output_audio")) + { + return ItemContentType.OutputAudio; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "refusal")) + { + return ItemContentType.Refusal; + } + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ItemContentType value."); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ItemContentType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ItemContentType.cs new file mode 100644 index 000000000000..da75ee105bfd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ItemContentType.cs @@ -0,0 +1,25 @@ +// + +#nullable disable + +namespace OpenAI +{ + /// Multi-modal input and output contents. + internal enum ItemContentType + { + /// InputText. + InputText, + /// InputAudio. + InputAudio, + /// InputImage. + InputImage, + /// InputFile. + InputFile, + /// OutputText. + OutputText, + /// OutputAudio. + OutputAudio, + /// Refusal. + Refusal + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ItemType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ItemType.cs new file mode 100644 index 000000000000..93b4cf2ad335 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ItemType.cs @@ -0,0 +1,142 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects; + +namespace OpenAI +{ + /// + internal readonly partial struct ItemType : IEquatable + { + private readonly string _value; + private const string MessageValue = "message"; + private const string FileSearchCallValue = "file_search_call"; + private const string FunctionCallValue = "function_call"; + private const string FunctionCallOutputValue = "function_call_output"; + private const string ComputerCallValue = "computer_call"; + private const string ComputerCallOutputValue = "computer_call_output"; + private const string WebSearchCallValue = "web_search_call"; + private const string ReasoningValue = "reasoning"; + private const string ItemReferenceValue = "item_reference"; + private const string ImageGenerationCallValue = "image_generation_call"; + private const string CodeInterpreterCallValue = "code_interpreter_call"; + private const string LocalShellCallValue = "local_shell_call"; + private const string LocalShellCallOutputValue = "local_shell_call_output"; + private const string McpListToolsValue = "mcp_list_tools"; + private const string McpApprovalRequestValue = "mcp_approval_request"; + private const string McpApprovalResponseValue = "mcp_approval_response"; + private const string McpCallValue = "mcp_call"; + private const string StructuredOutputsValue = "structured_outputs"; + private const string WorkflowActionValue = "workflow_action"; + private const string MemorySearchCallValue = "memory_search_call"; + private const string OauthConsentRequestValue = "oauth_consent_request"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ItemType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Message. + public static ItemType Message { get; } = new ItemType(MessageValue); + + /// Gets the FileSearchCall. + public static ItemType FileSearchCall { get; } = new ItemType(FileSearchCallValue); + + /// Gets the FunctionCall. + public static ItemType FunctionCall { get; } = new ItemType(FunctionCallValue); + + /// Gets the FunctionCallOutput. + public static ItemType FunctionCallOutput { get; } = new ItemType(FunctionCallOutputValue); + + /// Gets the ComputerCall. + public static ItemType ComputerCall { get; } = new ItemType(ComputerCallValue); + + /// Gets the ComputerCallOutput. + public static ItemType ComputerCallOutput { get; } = new ItemType(ComputerCallOutputValue); + + /// Gets the WebSearchCall. + public static ItemType WebSearchCall { get; } = new ItemType(WebSearchCallValue); + + /// Gets the Reasoning. + public static ItemType Reasoning { get; } = new ItemType(ReasoningValue); + + /// Gets the ItemReference. + public static ItemType ItemReference { get; } = new ItemType(ItemReferenceValue); + + /// Gets the ImageGenerationCall. + public static ItemType ImageGenerationCall { get; } = new ItemType(ImageGenerationCallValue); + + /// Gets the CodeInterpreterCall. + public static ItemType CodeInterpreterCall { get; } = new ItemType(CodeInterpreterCallValue); + + /// Gets the LocalShellCall. + public static ItemType LocalShellCall { get; } = new ItemType(LocalShellCallValue); + + /// Gets the LocalShellCallOutput. + public static ItemType LocalShellCallOutput { get; } = new ItemType(LocalShellCallOutputValue); + + /// Gets the McpListTools. + public static ItemType McpListTools { get; } = new ItemType(McpListToolsValue); + + /// Gets the McpApprovalRequest. + public static ItemType McpApprovalRequest { get; } = new ItemType(McpApprovalRequestValue); + + /// Gets the McpApprovalResponse. + public static ItemType McpApprovalResponse { get; } = new ItemType(McpApprovalResponseValue); + + /// Gets the McpCall. + public static ItemType McpCall { get; } = new ItemType(McpCallValue); + + /// Gets the StructuredOutputs. + public static ItemType StructuredOutputs { get; } = new ItemType(StructuredOutputsValue); + + /// Gets the WorkflowAction. + public static ItemType WorkflowAction { get; } = new ItemType(WorkflowActionValue); + + /// Gets the MemorySearchCall. + public static ItemType MemorySearchCall { get; } = new ItemType(MemorySearchCallValue); + + /// Gets the OauthConsentRequest. + public static ItemType OauthConsentRequest { get; } = new ItemType(OauthConsentRequestValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ItemType left, ItemType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ItemType left, ItemType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ItemType(string value) => new ItemType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ItemType?(string value) => value == null ? null : new ItemType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ItemType other && Equals(other); + + /// + public bool Equals(ItemType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ListVersionsRequestType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ListVersionsRequestType.cs new file mode 100644 index 000000000000..70225cf0fb8a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ListVersionsRequestType.cs @@ -0,0 +1,71 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// + public readonly partial struct ListVersionsRequestType : IEquatable + { + private readonly string _value; + /// Built-in evaluator (Microsoft provided). + private const string BuiltInValue = "builtin"; + /// Custom evaluator. + private const string CustomValue = "custom"; + private const string AllValue = "all"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ListVersionsRequestType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Built-in evaluator (Microsoft provided). + public static ListVersionsRequestType BuiltIn { get; } = new ListVersionsRequestType(BuiltInValue); + + /// Custom evaluator. + public static ListVersionsRequestType Custom { get; } = new ListVersionsRequestType(CustomValue); + + /// Gets the All. + public static ListVersionsRequestType All { get; } = new ListVersionsRequestType(AllValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ListVersionsRequestType left, ListVersionsRequestType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ListVersionsRequestType left, ListVersionsRequestType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ListVersionsRequestType(string value) => new ListVersionsRequestType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ListVersionsRequestType?(string value) => value == null ? null : new ListVersionsRequestType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ListVersionsRequestType other && Equals(other); + + /// + public bool Equals(ListVersionsRequestType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/LocationType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/LocationType.cs new file mode 100644 index 000000000000..5e9a72eee863 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/LocationType.cs @@ -0,0 +1,62 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects; + +namespace OpenAI +{ + /// + internal readonly partial struct LocationType : IEquatable + { + private readonly string _value; + private const string ApproximateValue = "approximate"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public LocationType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Approximate. + public static LocationType Approximate { get; } = new LocationType(ApproximateValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(LocationType left, LocationType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(LocationType left, LocationType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator LocationType(string value) => new LocationType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator LocationType?(string value) => value == null ? null : new LocationType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is LocationType other && Equals(other); + + /// + public bool Equals(LocationType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryItem.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryItem.Serialization.cs new file mode 100644 index 000000000000..ae3f14325d8f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryItem.Serialization.cs @@ -0,0 +1,146 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// + /// A single memory item stored in the memory store, containing content and metadata. + /// Please note this is the abstract base class. The derived classes available for instantiation are: and . + /// + [PersistableModelProxy(typeof(UnknownMemoryItem))] + public abstract partial class MemoryItem : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal MemoryItem() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryItem)} does not support writing '{format}' format."); + } + writer.WritePropertyName("memory_id"u8); + writer.WriteStringValue(MemoryId); + writer.WritePropertyName("updated_at"u8); + writer.WriteNumberValue(UpdatedAt, "U"); + writer.WritePropertyName("scope"u8); + writer.WriteStringValue(Scope); + writer.WritePropertyName("content"u8); + writer.WriteStringValue(Content); + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemoryItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MemoryItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryItem)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemoryItem(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MemoryItem DeserializeMemoryItem(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("kind"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "user_profile": + return UserProfileMemoryItem.DeserializeUserProfileMemoryItem(element, options); + case "chat_summary": + return ChatSummaryMemoryItem.DeserializeChatSummaryMemoryItem(element, options); + } + } + return UnknownMemoryItem.DeserializeUnknownMemoryItem(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(MemoryItem)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemoryItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MemoryItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemoryItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemoryItem)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryItem.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryItem.cs new file mode 100644 index 000000000000..d590b2ea1199 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryItem.cs @@ -0,0 +1,66 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// + /// A single memory item stored in the memory store, containing content and metadata. + /// Please note this is the abstract base class. The derived classes available for instantiation are: and . + /// + public abstract partial class MemoryItem + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The unique ID of the memory item. + /// The last update time of the memory item. + /// The namespace that logically groups and isolates memories, such as a user ID. + /// The content of the memory. + /// The kind of the memory item. + private protected MemoryItem(string memoryId, DateTimeOffset updatedAt, string scope, string content, MemoryItemKind kind) + { + MemoryId = memoryId; + UpdatedAt = updatedAt; + Scope = scope; + Content = content; + Kind = kind; + } + + /// Initializes a new instance of . + /// The unique ID of the memory item. + /// The last update time of the memory item. + /// The namespace that logically groups and isolates memories, such as a user ID. + /// The content of the memory. + /// The kind of the memory item. + /// Keeps track of any properties unknown to the library. + internal MemoryItem(string memoryId, DateTimeOffset updatedAt, string scope, string content, MemoryItemKind kind, IDictionary additionalBinaryDataProperties) + { + MemoryId = memoryId; + UpdatedAt = updatedAt; + Scope = scope; + Content = content; + Kind = kind; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The unique ID of the memory item. + public string MemoryId { get; set; } + + /// The last update time of the memory item. + public DateTimeOffset UpdatedAt { get; set; } + + /// The namespace that logically groups and isolates memories, such as a user ID. + public string Scope { get; set; } + + /// The content of the memory. + public string Content { get; set; } + + /// The kind of the memory item. + internal MemoryItemKind Kind { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryItemKind.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryItemKind.cs new file mode 100644 index 000000000000..8dc3c76cd973 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryItemKind.cs @@ -0,0 +1,67 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// Memory item kind. + internal readonly partial struct MemoryItemKind : IEquatable + { + private readonly string _value; + /// User profile information extracted from conversations. + private const string UserProfileValue = "user_profile"; + /// Summary of chat conversations. + private const string ChatSummaryValue = "chat_summary"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public MemoryItemKind(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// User profile information extracted from conversations. + public static MemoryItemKind UserProfile { get; } = new MemoryItemKind(UserProfileValue); + + /// Summary of chat conversations. + public static MemoryItemKind ChatSummary { get; } = new MemoryItemKind(ChatSummaryValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(MemoryItemKind left, MemoryItemKind right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(MemoryItemKind left, MemoryItemKind right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator MemoryItemKind(string value) => new MemoryItemKind(value); + + /// Converts a string to a . + /// The value. + public static implicit operator MemoryItemKind?(string value) => value == null ? null : new MemoryItemKind(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MemoryItemKind other && Equals(other); + + /// + public bool Equals(MemoryItemKind other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryOperation.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryOperation.Serialization.cs new file mode 100644 index 000000000000..157508f9a548 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryOperation.Serialization.cs @@ -0,0 +1,147 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Represents a single memory operation (create, update, or delete) performed on a memory item. + public partial class MemoryOperation : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal MemoryOperation() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryOperation)} does not support writing '{format}' format."); + } + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind.ToString()); + writer.WritePropertyName("memory_item"u8); + writer.WriteObjectValue(MemoryItem, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemoryOperation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MemoryOperation JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryOperation)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemoryOperation(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MemoryOperation DeserializeMemoryOperation(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MemoryOperationKind kind = default; + MemoryItem memoryItem = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("kind"u8)) + { + kind = new MemoryOperationKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("memory_item"u8)) + { + memoryItem = MemoryItem.DeserializeMemoryItem(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MemoryOperation(kind, memoryItem, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(MemoryOperation)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemoryOperation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MemoryOperation PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemoryOperation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemoryOperation)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryOperation.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryOperation.cs new file mode 100644 index 000000000000..a5db726b01f6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryOperation.cs @@ -0,0 +1,42 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Represents a single memory operation (create, update, or delete) performed on a memory item. + public partial class MemoryOperation + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The type of memory operation being performed. + /// The memory item to create, update, or delete. + internal MemoryOperation(MemoryOperationKind kind, MemoryItem memoryItem) + { + Kind = kind; + MemoryItem = memoryItem; + } + + /// Initializes a new instance of . + /// The type of memory operation being performed. + /// The memory item to create, update, or delete. + /// Keeps track of any properties unknown to the library. + internal MemoryOperation(MemoryOperationKind kind, MemoryItem memoryItem, IDictionary additionalBinaryDataProperties) + { + Kind = kind; + MemoryItem = memoryItem; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The type of memory operation being performed. + public MemoryOperationKind Kind { get; } + + /// The memory item to create, update, or delete. + public MemoryItem MemoryItem { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryOperationKind.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryOperationKind.cs new file mode 100644 index 000000000000..b5d7bc2b86a5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryOperationKind.cs @@ -0,0 +1,72 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// Memory operation kind. + public readonly partial struct MemoryOperationKind : IEquatable + { + private readonly string _value; + /// Create a new memory item. + private const string CreateValue = "create"; + /// Update an existing memory item. + private const string UpdateValue = "update"; + /// Delete an existing memory item. + private const string DeleteValue = "delete"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public MemoryOperationKind(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Create a new memory item. + public static MemoryOperationKind Create { get; } = new MemoryOperationKind(CreateValue); + + /// Update an existing memory item. + public static MemoryOperationKind Update { get; } = new MemoryOperationKind(UpdateValue); + + /// Delete an existing memory item. + public static MemoryOperationKind Delete { get; } = new MemoryOperationKind(DeleteValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(MemoryOperationKind left, MemoryOperationKind right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(MemoryOperationKind left, MemoryOperationKind right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator MemoryOperationKind(string value) => new MemoryOperationKind(value); + + /// Converts a string to a . + /// The value. + public static implicit operator MemoryOperationKind?(string value) => value == null ? null : new MemoryOperationKind(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MemoryOperationKind other && Equals(other); + + /// + public bool Equals(MemoryOperationKind other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemorySearchItem.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemorySearchItem.Serialization.cs new file mode 100644 index 000000000000..3f28b00c2757 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemorySearchItem.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// A retrieved memory item from memory search. + public partial class MemorySearchItem : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal MemorySearchItem() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemorySearchItem)} does not support writing '{format}' format."); + } + writer.WritePropertyName("memory_item"u8); + writer.WriteObjectValue(MemoryItem, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemorySearchItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MemorySearchItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemorySearchItem)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemorySearchItem(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MemorySearchItem DeserializeMemorySearchItem(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MemoryItem memoryItem = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("memory_item"u8)) + { + memoryItem = MemoryItem.DeserializeMemoryItem(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MemorySearchItem(memoryItem, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(MemorySearchItem)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemorySearchItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MemorySearchItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemorySearchItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemorySearchItem)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemorySearchItem.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemorySearchItem.cs new file mode 100644 index 000000000000..3d8ee7011ceb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemorySearchItem.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// A retrieved memory item from memory search. + public partial class MemorySearchItem + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Retrieved memory item. + /// is null. + public MemorySearchItem(MemoryItem memoryItem) + { + Argument.AssertNotNull(memoryItem, nameof(memoryItem)); + + MemoryItem = memoryItem; + } + + /// Initializes a new instance of . + /// Retrieved memory item. + /// Keeps track of any properties unknown to the library. + internal MemorySearchItem(MemoryItem memoryItem, IDictionary additionalBinaryDataProperties) + { + MemoryItem = memoryItem; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Retrieved memory item. + public MemoryItem MemoryItem { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemorySearchResultOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemorySearchResultOptions.Serialization.cs new file mode 100644 index 000000000000..7b0f73002af1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemorySearchResultOptions.Serialization.cs @@ -0,0 +1,141 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Memory search options. + public partial class MemorySearchResultOptions : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemorySearchResultOptions)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(MaxMemories)) + { + writer.WritePropertyName("max_memories"u8); + writer.WriteNumberValue(MaxMemories.Value); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemorySearchResultOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MemorySearchResultOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemorySearchResultOptions)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemorySearchResultOptions(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MemorySearchResultOptions DeserializeMemorySearchResultOptions(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? maxMemories = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("max_memories"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxMemories = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MemorySearchResultOptions(maxMemories, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(MemorySearchResultOptions)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemorySearchResultOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MemorySearchResultOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemorySearchResultOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemorySearchResultOptions)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemorySearchResultOptions.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemorySearchResultOptions.cs new file mode 100644 index 000000000000..feb546a66105 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemorySearchResultOptions.cs @@ -0,0 +1,33 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Memory search options. + public partial class MemorySearchResultOptions + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public MemorySearchResultOptions() + { + } + + /// Initializes a new instance of . + /// Maximum number of memory items to return. + /// Keeps track of any properties unknown to the library. + internal MemorySearchResultOptions(int? maxMemories, IDictionary additionalBinaryDataProperties) + { + MaxMemories = maxMemories; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Maximum number of memory items to return. + public int? MaxMemories { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemorySearchTool.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemorySearchTool.Serialization.cs new file mode 100644 index 000000000000..957cebd17898 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemorySearchTool.Serialization.cs @@ -0,0 +1,176 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// A tool for integrating memories into the agent. + internal partial class MemorySearchTool : InternalTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal MemorySearchTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemorySearchTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("memory_store_name"u8); + writer.WriteStringValue(MemoryStoreName); + writer.WritePropertyName("scope"u8); + writer.WriteStringValue(Scope); + if (Optional.IsDefined(SearchOptions)) + { + writer.WritePropertyName("search_options"u8); + writer.WriteObjectValue(SearchOptions, options); + } + if (Optional.IsDefined(UpdateDelay)) + { + writer.WritePropertyName("update_delay"u8); + writer.WriteNumberValue(UpdateDelay.Value); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemorySearchTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (MemorySearchTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemorySearchTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemorySearchTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MemorySearchTool DeserializeMemorySearchTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string memoryStoreName = default; + string scope = default; + MemorySearchResultOptions searchOptions = default; + int? updateDelay = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("memory_store_name"u8)) + { + memoryStoreName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("scope"u8)) + { + scope = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("search_options"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + searchOptions = MemorySearchResultOptions.DeserializeMemorySearchResultOptions(prop.Value, options); + continue; + } + if (prop.NameEquals("update_delay"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + updateDelay = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MemorySearchTool( + @type, + additionalBinaryDataProperties, + memoryStoreName, + scope, + searchOptions, + updateDelay); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(MemorySearchTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemorySearchTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (MemorySearchTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemorySearchTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemorySearchTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemorySearchTool.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemorySearchTool.cs new file mode 100644 index 000000000000..4055827a5342 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemorySearchTool.cs @@ -0,0 +1,66 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// A tool for integrating memories into the agent. + internal partial class MemorySearchTool : InternalTool + { + /// Initializes a new instance of . + /// The name of the memory store to use. + /// + /// The namespace used to group and isolate memories, such as a user ID. + /// Limits which memories can be retrieved or updated. + /// Use special variable `{{$userId}}` to scope memories to the current signed-in user. + /// + /// or is null. + public MemorySearchTool(string memoryStoreName, string scope) : base(ToolType.MemorySearch) + { + Argument.AssertNotNull(memoryStoreName, nameof(memoryStoreName)); + Argument.AssertNotNull(scope, nameof(scope)); + + MemoryStoreName = memoryStoreName; + Scope = scope; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The name of the memory store to use. + /// + /// The namespace used to group and isolate memories, such as a user ID. + /// Limits which memories can be retrieved or updated. + /// Use special variable `{{$userId}}` to scope memories to the current signed-in user. + /// + /// Options for searching the memory store. + /// Time to wait before updating memories after inactivity (seconds). Default 300. + internal MemorySearchTool(ToolType @type, IDictionary additionalBinaryDataProperties, string memoryStoreName, string scope, MemorySearchResultOptions searchOptions, int? updateDelay) : base(@type, additionalBinaryDataProperties) + { + MemoryStoreName = memoryStoreName; + Scope = scope; + SearchOptions = searchOptions; + UpdateDelay = updateDelay; + } + + /// The name of the memory store to use. + public string MemoryStoreName { get; set; } + + /// + /// The namespace used to group and isolate memories, such as a user ID. + /// Limits which memories can be retrieved or updated. + /// Use special variable `{{$userId}}` to scope memories to the current signed-in user. + /// + public string Scope { get; set; } + + /// Options for searching the memory store. + public MemorySearchResultOptions SearchOptions { get; set; } + + /// Time to wait before updating memories after inactivity (seconds). Default 300. + public int? UpdateDelay { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemorySearchToolCallItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemorySearchToolCallItemParam.Serialization.cs new file mode 100644 index 000000000000..fbedaf2fe081 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemorySearchToolCallItemParam.Serialization.cs @@ -0,0 +1,144 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// The MemorySearchToolCallItemParam. + internal partial class MemorySearchToolCallItemParam : InternalItemParam, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemorySearchToolCallItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsCollectionDefined(Results)) + { + writer.WritePropertyName("results"u8); + writer.WriteStartArray(); + foreach (MemorySearchItem item in Results) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemorySearchToolCallItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (MemorySearchToolCallItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemorySearchToolCallItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemorySearchToolCallItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MemorySearchToolCallItemParam DeserializeMemorySearchToolCallItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList results = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ItemType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("results"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(MemorySearchItem.DeserializeMemorySearchItem(item, options)); + } + results = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MemorySearchToolCallItemParam(@type, additionalBinaryDataProperties, results ?? new ChangeTrackingList()); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(MemorySearchToolCallItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemorySearchToolCallItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (MemorySearchToolCallItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemorySearchToolCallItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemorySearchToolCallItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemorySearchToolCallItemParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemorySearchToolCallItemParam.cs new file mode 100644 index 000000000000..01f1be8af7d1 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemorySearchToolCallItemParam.cs @@ -0,0 +1,32 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// The MemorySearchToolCallItemParam. + internal partial class MemorySearchToolCallItemParam : InternalItemParam + { + /// Initializes a new instance of . + public MemorySearchToolCallItemParam() : base(ItemType.MemorySearchCall) + { + Results = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The results returned from the memory search. + internal MemorySearchToolCallItemParam(ItemType @type, IDictionary additionalBinaryDataProperties, IList results) : base(@type, additionalBinaryDataProperties) + { + Results = results; + } + + /// The results returned from the memory search. + public IList Results { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStore.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStore.Serialization.cs new file mode 100644 index 000000000000..ab62245f44fc --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStore.Serialization.cs @@ -0,0 +1,246 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// A memory store that can store and retrieve user memories. + public partial class MemoryStore : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal MemoryStore() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryStore)} does not support writing '{format}' format."); + } + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + writer.WritePropertyName("updated_at"u8); + writer.WriteNumberValue(UpdatedAt, "U"); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("definition"u8); + writer.WriteObjectValue(Definition, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemoryStore IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MemoryStore JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryStore)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemoryStore(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MemoryStore DeserializeMemoryStore(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @object = default; + string id = default; + DateTimeOffset createdAt = default; + DateTimeOffset updatedAt = default; + string name = default; + string description = default; + IDictionary metadata = default; + MemoryStoreDefinition definition = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("object"u8)) + { + @object = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("created_at"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64()); + continue; + } + if (prop.NameEquals("updated_at"u8)) + { + updatedAt = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("metadata"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + metadata = dictionary; + continue; + } + if (prop.NameEquals("definition"u8)) + { + definition = MemoryStoreDefinition.DeserializeMemoryStoreDefinition(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MemoryStore( + @object, + id, + createdAt, + updatedAt, + name, + description, + metadata ?? new ChangeTrackingDictionary(), + definition, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(MemoryStore)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemoryStore IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MemoryStore PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemoryStore(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemoryStore)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator MemoryStore(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMemoryStore(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStore.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStore.cs new file mode 100644 index 000000000000..0aa172ccbe6a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStore.cs @@ -0,0 +1,76 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// A memory store that can store and retrieve user memories. + public partial class MemoryStore + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The unique identifier of the memory store. + /// The Unix timestamp (seconds) when the memory store was created. + /// The Unix timestamp (seconds) when the memory store was last updated. + /// The name of the memory store. + /// The definition of the memory store. + internal MemoryStore(string id, DateTimeOffset createdAt, DateTimeOffset updatedAt, string name, MemoryStoreDefinition definition) + { + Id = id; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + Name = name; + Metadata = new ChangeTrackingDictionary(); + Definition = definition; + } + + /// Initializes a new instance of . + /// The object type, which is always 'memory_store'. + /// The unique identifier of the memory store. + /// The Unix timestamp (seconds) when the memory store was created. + /// The Unix timestamp (seconds) when the memory store was last updated. + /// The name of the memory store. + /// A human-readable description of the memory store. + /// Arbitrary key-value metadata to associate with the memory store. + /// The definition of the memory store. + /// Keeps track of any properties unknown to the library. + internal MemoryStore(string @object, string id, DateTimeOffset createdAt, DateTimeOffset updatedAt, string name, string description, IDictionary metadata, MemoryStoreDefinition definition, IDictionary additionalBinaryDataProperties) + { + Object = @object; + Id = id; + CreatedAt = createdAt; + UpdatedAt = updatedAt; + Name = name; + Description = description; + Metadata = metadata; + Definition = definition; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The unique identifier of the memory store. + public string Id { get; } + + /// The Unix timestamp (seconds) when the memory store was created. + public DateTimeOffset CreatedAt { get; } + + /// The Unix timestamp (seconds) when the memory store was last updated. + public DateTimeOffset UpdatedAt { get; } + + /// The name of the memory store. + public string Name { get; } + + /// A human-readable description of the memory store. + public string Description { get; } + + /// Arbitrary key-value metadata to associate with the memory store. + public IDictionary Metadata { get; } + + /// The definition of the memory store. + public MemoryStoreDefinition Definition { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreDefaultDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreDefaultDefinition.Serialization.cs new file mode 100644 index 000000000000..b0fc57a9fa0b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreDefaultDefinition.Serialization.cs @@ -0,0 +1,154 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Default memory store implementation. + public partial class MemoryStoreDefaultDefinition : MemoryStoreDefinition, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal MemoryStoreDefaultDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryStoreDefaultDefinition)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("chat_model"u8); + writer.WriteStringValue(ChatModel); + writer.WritePropertyName("embedding_model"u8); + writer.WriteStringValue(EmbeddingModel); + if (Optional.IsDefined(Options)) + { + writer.WritePropertyName("options"u8); + writer.WriteObjectValue(Options, options); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemoryStoreDefaultDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (MemoryStoreDefaultDefinition)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override MemoryStoreDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryStoreDefaultDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemoryStoreDefaultDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MemoryStoreDefaultDefinition DeserializeMemoryStoreDefaultDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MemoryStoreKind kind = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string chatModel = default; + string embeddingModel = default; + MemoryStoreDefaultOptions options0 = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("kind"u8)) + { + kind = new MemoryStoreKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("chat_model"u8)) + { + chatModel = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("embedding_model"u8)) + { + embeddingModel = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("options"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + options0 = MemoryStoreDefaultOptions.DeserializeMemoryStoreDefaultOptions(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MemoryStoreDefaultDefinition(kind, additionalBinaryDataProperties, chatModel, embeddingModel, options0); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(MemoryStoreDefaultDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemoryStoreDefaultDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (MemoryStoreDefaultDefinition)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override MemoryStoreDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemoryStoreDefaultDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemoryStoreDefaultDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreDefaultDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreDefaultDefinition.cs new file mode 100644 index 000000000000..cd8b2c3e7411 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreDefaultDefinition.cs @@ -0,0 +1,48 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Default memory store implementation. + public partial class MemoryStoreDefaultDefinition : MemoryStoreDefinition + { + /// Initializes a new instance of . + /// The name or identifier of the chat completion model deployment used for memory processing. + /// The name or identifier of the embedding model deployment used for memory processing. + /// or is null. + public MemoryStoreDefaultDefinition(string chatModel, string embeddingModel) : base(MemoryStoreKind.Default) + { + Argument.AssertNotNull(chatModel, nameof(chatModel)); + Argument.AssertNotNull(embeddingModel, nameof(embeddingModel)); + + ChatModel = chatModel; + EmbeddingModel = embeddingModel; + } + + /// Initializes a new instance of . + /// The kind of the memory store. + /// Keeps track of any properties unknown to the library. + /// The name or identifier of the chat completion model deployment used for memory processing. + /// The name or identifier of the embedding model deployment used for memory processing. + /// Default memory store options. + internal MemoryStoreDefaultDefinition(MemoryStoreKind kind, IDictionary additionalBinaryDataProperties, string chatModel, string embeddingModel, MemoryStoreDefaultOptions options) : base(kind, additionalBinaryDataProperties) + { + ChatModel = chatModel; + EmbeddingModel = embeddingModel; + Options = options; + } + + /// The name or identifier of the chat completion model deployment used for memory processing. + public string ChatModel { get; set; } + + /// The name or identifier of the embedding model deployment used for memory processing. + public string EmbeddingModel { get; set; } + + /// Default memory store options. + public MemoryStoreDefaultOptions Options { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreDefaultOptions.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreDefaultOptions.Serialization.cs new file mode 100644 index 000000000000..0ea4f692efe3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreDefaultOptions.Serialization.cs @@ -0,0 +1,158 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Default memory store configurations. + public partial class MemoryStoreDefaultOptions : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal MemoryStoreDefaultOptions() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryStoreDefaultOptions)} does not support writing '{format}' format."); + } + writer.WritePropertyName("user_profile_enabled"u8); + writer.WriteBooleanValue(UserProfileEnabled); + if (Optional.IsDefined(UserProfileDetails)) + { + writer.WritePropertyName("user_profile_details"u8); + writer.WriteStringValue(UserProfileDetails); + } + writer.WritePropertyName("chat_summary_enabled"u8); + writer.WriteBooleanValue(ChatSummaryEnabled); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemoryStoreDefaultOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MemoryStoreDefaultOptions JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryStoreDefaultOptions)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemoryStoreDefaultOptions(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MemoryStoreDefaultOptions DeserializeMemoryStoreDefaultOptions(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool userProfileEnabled = default; + string userProfileDetails = default; + bool chatSummaryEnabled = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("user_profile_enabled"u8)) + { + userProfileEnabled = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("user_profile_details"u8)) + { + userProfileDetails = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("chat_summary_enabled"u8)) + { + chatSummaryEnabled = prop.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MemoryStoreDefaultOptions(userProfileEnabled, userProfileDetails, chatSummaryEnabled, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(MemoryStoreDefaultOptions)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemoryStoreDefaultOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MemoryStoreDefaultOptions PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemoryStoreDefaultOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemoryStoreDefaultOptions)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreDefaultOptions.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreDefaultOptions.cs new file mode 100644 index 000000000000..c4ef3fc604a0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreDefaultOptions.cs @@ -0,0 +1,47 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Default memory store configurations. + public partial class MemoryStoreDefaultOptions + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Whether to enable user profile extraction and storage. Default is true. + /// Whether to enable chat summary extraction and storage. Default is true. + public MemoryStoreDefaultOptions(bool userProfileEnabled, bool chatSummaryEnabled) + { + UserProfileEnabled = userProfileEnabled; + ChatSummaryEnabled = chatSummaryEnabled; + } + + /// Initializes a new instance of . + /// Whether to enable user profile extraction and storage. Default is true. + /// Specific categories or types of user profile information to extract and store. + /// Whether to enable chat summary extraction and storage. Default is true. + /// Keeps track of any properties unknown to the library. + internal MemoryStoreDefaultOptions(bool userProfileEnabled, string userProfileDetails, bool chatSummaryEnabled, IDictionary additionalBinaryDataProperties) + { + UserProfileEnabled = userProfileEnabled; + UserProfileDetails = userProfileDetails; + ChatSummaryEnabled = chatSummaryEnabled; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Whether to enable user profile extraction and storage. Default is true. + public bool UserProfileEnabled { get; set; } + + /// Specific categories or types of user profile information to extract and store. + public string UserProfileDetails { get; set; } + + /// Whether to enable chat summary extraction and storage. Default is true. + public bool ChatSummaryEnabled { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreDefinition.Serialization.cs new file mode 100644 index 000000000000..c9ef90a3f941 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreDefinition.Serialization.cs @@ -0,0 +1,136 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// + /// Base definition for memory store configurations. + /// Please note this is the abstract base class. The derived classes available for instantiation are: . + /// + [PersistableModelProxy(typeof(UnknownMemoryStoreDefinition))] + public abstract partial class MemoryStoreDefinition : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal MemoryStoreDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryStoreDefinition)} does not support writing '{format}' format."); + } + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemoryStoreDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MemoryStoreDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryStoreDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemoryStoreDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MemoryStoreDefinition DeserializeMemoryStoreDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("kind"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "default": + return MemoryStoreDefaultDefinition.DeserializeMemoryStoreDefaultDefinition(element, options); + } + } + return UnknownMemoryStoreDefinition.DeserializeUnknownMemoryStoreDefinition(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(MemoryStoreDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemoryStoreDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MemoryStoreDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemoryStoreDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemoryStoreDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreDefinition.cs new file mode 100644 index 000000000000..88774495fcc3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreDefinition.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// + /// Base definition for memory store configurations. + /// Please note this is the abstract base class. The derived classes available for instantiation are: . + /// + public abstract partial class MemoryStoreDefinition + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The kind of the memory store. + private protected MemoryStoreDefinition(MemoryStoreKind kind) + { + Kind = kind; + } + + /// Initializes a new instance of . + /// The kind of the memory store. + /// Keeps track of any properties unknown to the library. + internal MemoryStoreDefinition(MemoryStoreKind kind, IDictionary additionalBinaryDataProperties) + { + Kind = kind; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The kind of the memory store. + internal MemoryStoreKind Kind { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreDeleteScopeResponse.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreDeleteScopeResponse.Serialization.cs new file mode 100644 index 000000000000..3ce05d988f8b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreDeleteScopeResponse.Serialization.cs @@ -0,0 +1,172 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Response for deleting memories from a scope. + public partial class MemoryStoreDeleteScopeResponse : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal MemoryStoreDeleteScopeResponse() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryStoreDeleteScopeResponse)} does not support writing '{format}' format."); + } + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("scope"u8); + writer.WriteStringValue(Scope); + writer.WritePropertyName("deleted"u8); + writer.WriteBooleanValue(Deleted); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemoryStoreDeleteScopeResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MemoryStoreDeleteScopeResponse JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryStoreDeleteScopeResponse)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemoryStoreDeleteScopeResponse(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MemoryStoreDeleteScopeResponse DeserializeMemoryStoreDeleteScopeResponse(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @object = default; + string name = default; + string scope = default; + bool deleted = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("object"u8)) + { + @object = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("scope"u8)) + { + scope = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("deleted"u8)) + { + deleted = prop.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MemoryStoreDeleteScopeResponse(@object, name, scope, deleted, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(MemoryStoreDeleteScopeResponse)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemoryStoreDeleteScopeResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MemoryStoreDeleteScopeResponse PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemoryStoreDeleteScopeResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemoryStoreDeleteScopeResponse)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator MemoryStoreDeleteScopeResponse(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMemoryStoreDeleteScopeResponse(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreDeleteScopeResponse.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreDeleteScopeResponse.cs new file mode 100644 index 000000000000..11107c62c91a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreDeleteScopeResponse.cs @@ -0,0 +1,54 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Response for deleting memories from a scope. + public partial class MemoryStoreDeleteScopeResponse + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The name of the memory store. + /// The scope from which memories were deleted. + /// Whether the deletion operation was successful. + internal MemoryStoreDeleteScopeResponse(string name, string scope, bool deleted) + { + Name = name; + Scope = scope; + Deleted = deleted; + } + + /// Initializes a new instance of . + /// The object type. Always 'memory_store.scope.deleted'. + /// The name of the memory store. + /// The scope from which memories were deleted. + /// Whether the deletion operation was successful. + /// Keeps track of any properties unknown to the library. + internal MemoryStoreDeleteScopeResponse(string @object, string name, string scope, bool deleted, IDictionary additionalBinaryDataProperties) + { + Object = @object; + Name = name; + Scope = scope; + Deleted = deleted; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The object type. Always 'memory_store.scope.deleted'. + public string Object { get; } = "memory_store.scope.deleted"; + + /// The name of the memory store. + public string Name { get; } + + /// The scope from which memories were deleted. + public string Scope { get; } + + /// Whether the deletion operation was successful. + public bool Deleted { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreKind.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreKind.cs new file mode 100644 index 000000000000..387ed51cccd8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreKind.cs @@ -0,0 +1,62 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// The type of memory store implementation to use. + internal readonly partial struct MemoryStoreKind : IEquatable + { + private readonly string _value; + /// The default memory store implementation. + private const string DefaultValue = "default"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public MemoryStoreKind(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// The default memory store implementation. + public static MemoryStoreKind Default { get; } = new MemoryStoreKind(DefaultValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(MemoryStoreKind left, MemoryStoreKind right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(MemoryStoreKind left, MemoryStoreKind right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator MemoryStoreKind(string value) => new MemoryStoreKind(value); + + /// Converts a string to a . + /// The value. + public static implicit operator MemoryStoreKind?(string value) => value == null ? null : new MemoryStoreKind(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MemoryStoreKind other && Equals(other); + + /// + public bool Equals(MemoryStoreKind other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreOperationUsage.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreOperationUsage.Serialization.cs new file mode 100644 index 000000000000..74a4c210c030 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreOperationUsage.Serialization.cs @@ -0,0 +1,186 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Usage statistics of a memory store operation. + public partial class MemoryStoreOperationUsage : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal MemoryStoreOperationUsage() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryStoreOperationUsage)} does not support writing '{format}' format."); + } + writer.WritePropertyName("embedding_tokens"u8); + writer.WriteNumberValue(EmbeddingTokens); + writer.WritePropertyName("input_tokens"u8); + writer.WriteNumberValue(InputTokens); + writer.WritePropertyName("input_tokens_details"u8); + writer.WriteObjectValue(InputTokensDetails, options); + writer.WritePropertyName("output_tokens"u8); + writer.WriteNumberValue(OutputTokens); + writer.WritePropertyName("output_tokens_details"u8); + writer.WriteObjectValue(OutputTokensDetails, options); + writer.WritePropertyName("total_tokens"u8); + writer.WriteNumberValue(TotalTokens); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemoryStoreOperationUsage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MemoryStoreOperationUsage JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryStoreOperationUsage)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemoryStoreOperationUsage(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MemoryStoreOperationUsage DeserializeMemoryStoreOperationUsage(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int embeddingTokens = default; + int inputTokens = default; + MemoryStoreOperationUsageInputTokensDetails inputTokensDetails = default; + int outputTokens = default; + MemoryStoreOperationUsageOutputTokensDetails outputTokensDetails = default; + int totalTokens = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("embedding_tokens"u8)) + { + embeddingTokens = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("input_tokens"u8)) + { + inputTokens = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("input_tokens_details"u8)) + { + inputTokensDetails = MemoryStoreOperationUsageInputTokensDetails.DeserializeMemoryStoreOperationUsageInputTokensDetails(prop.Value, options); + continue; + } + if (prop.NameEquals("output_tokens"u8)) + { + outputTokens = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("output_tokens_details"u8)) + { + outputTokensDetails = MemoryStoreOperationUsageOutputTokensDetails.DeserializeMemoryStoreOperationUsageOutputTokensDetails(prop.Value, options); + continue; + } + if (prop.NameEquals("total_tokens"u8)) + { + totalTokens = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MemoryStoreOperationUsage( + embeddingTokens, + inputTokens, + inputTokensDetails, + outputTokens, + outputTokensDetails, + totalTokens, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(MemoryStoreOperationUsage)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemoryStoreOperationUsage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MemoryStoreOperationUsage PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemoryStoreOperationUsage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemoryStoreOperationUsage)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreOperationUsage.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreOperationUsage.cs new file mode 100644 index 000000000000..eac144caa980 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreOperationUsage.cs @@ -0,0 +1,70 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Usage statistics of a memory store operation. + public partial class MemoryStoreOperationUsage + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The number of embedding tokens. + /// The number of input tokens. + /// A detailed breakdown of the input tokens. + /// The number of output tokens. + /// A detailed breakdown of the output tokens. + /// The total number of tokens used. + internal MemoryStoreOperationUsage(int embeddingTokens, int inputTokens, MemoryStoreOperationUsageInputTokensDetails inputTokensDetails, int outputTokens, MemoryStoreOperationUsageOutputTokensDetails outputTokensDetails, int totalTokens) + { + EmbeddingTokens = embeddingTokens; + InputTokens = inputTokens; + InputTokensDetails = inputTokensDetails; + OutputTokens = outputTokens; + OutputTokensDetails = outputTokensDetails; + TotalTokens = totalTokens; + } + + /// Initializes a new instance of . + /// The number of embedding tokens. + /// The number of input tokens. + /// A detailed breakdown of the input tokens. + /// The number of output tokens. + /// A detailed breakdown of the output tokens. + /// The total number of tokens used. + /// Keeps track of any properties unknown to the library. + internal MemoryStoreOperationUsage(int embeddingTokens, int inputTokens, MemoryStoreOperationUsageInputTokensDetails inputTokensDetails, int outputTokens, MemoryStoreOperationUsageOutputTokensDetails outputTokensDetails, int totalTokens, IDictionary additionalBinaryDataProperties) + { + EmbeddingTokens = embeddingTokens; + InputTokens = inputTokens; + InputTokensDetails = inputTokensDetails; + OutputTokens = outputTokens; + OutputTokensDetails = outputTokensDetails; + TotalTokens = totalTokens; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The number of embedding tokens. + public int EmbeddingTokens { get; } + + /// The number of input tokens. + public int InputTokens { get; } + + /// A detailed breakdown of the input tokens. + public MemoryStoreOperationUsageInputTokensDetails InputTokensDetails { get; } + + /// The number of output tokens. + public int OutputTokens { get; } + + /// A detailed breakdown of the output tokens. + public MemoryStoreOperationUsageOutputTokensDetails OutputTokensDetails { get; } + + /// The total number of tokens used. + public int TotalTokens { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreOperationUsageInputTokensDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreOperationUsageInputTokensDetails.Serialization.cs new file mode 100644 index 000000000000..5bbb4d1919a8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreOperationUsageInputTokensDetails.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The MemoryStoreOperationUsageInputTokensDetails. + public partial class MemoryStoreOperationUsageInputTokensDetails : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal MemoryStoreOperationUsageInputTokensDetails() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryStoreOperationUsageInputTokensDetails)} does not support writing '{format}' format."); + } + writer.WritePropertyName("cached_tokens"u8); + writer.WriteNumberValue(CachedTokens); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemoryStoreOperationUsageInputTokensDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MemoryStoreOperationUsageInputTokensDetails JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryStoreOperationUsageInputTokensDetails)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemoryStoreOperationUsageInputTokensDetails(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MemoryStoreOperationUsageInputTokensDetails DeserializeMemoryStoreOperationUsageInputTokensDetails(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int cachedTokens = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("cached_tokens"u8)) + { + cachedTokens = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MemoryStoreOperationUsageInputTokensDetails(cachedTokens, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(MemoryStoreOperationUsageInputTokensDetails)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemoryStoreOperationUsageInputTokensDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MemoryStoreOperationUsageInputTokensDetails PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemoryStoreOperationUsageInputTokensDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemoryStoreOperationUsageInputTokensDetails)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreOperationUsageInputTokensDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreOperationUsageInputTokensDetails.cs new file mode 100644 index 000000000000..9b09fa945b9d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreOperationUsageInputTokensDetails.cs @@ -0,0 +1,44 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// The MemoryStoreOperationUsageInputTokensDetails. + public partial class MemoryStoreOperationUsageInputTokensDetails + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// The number of tokens that were retrieved from the cache. + /// [More on prompt caching](https://platform.openai.com/docs/guides/prompt-caching). + /// + internal MemoryStoreOperationUsageInputTokensDetails(int cachedTokens) + { + CachedTokens = cachedTokens; + } + + /// Initializes a new instance of . + /// + /// The number of tokens that were retrieved from the cache. + /// [More on prompt caching](https://platform.openai.com/docs/guides/prompt-caching). + /// + /// Keeps track of any properties unknown to the library. + internal MemoryStoreOperationUsageInputTokensDetails(int cachedTokens, IDictionary additionalBinaryDataProperties) + { + CachedTokens = cachedTokens; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// The number of tokens that were retrieved from the cache. + /// [More on prompt caching](https://platform.openai.com/docs/guides/prompt-caching). + /// + public int CachedTokens { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreOperationUsageOutputTokensDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreOperationUsageOutputTokensDetails.Serialization.cs new file mode 100644 index 000000000000..735d78891067 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreOperationUsageOutputTokensDetails.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The MemoryStoreOperationUsageOutputTokensDetails. + public partial class MemoryStoreOperationUsageOutputTokensDetails : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal MemoryStoreOperationUsageOutputTokensDetails() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryStoreOperationUsageOutputTokensDetails)} does not support writing '{format}' format."); + } + writer.WritePropertyName("reasoning_tokens"u8); + writer.WriteNumberValue(ReasoningTokens); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemoryStoreOperationUsageOutputTokensDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MemoryStoreOperationUsageOutputTokensDetails JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryStoreOperationUsageOutputTokensDetails)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemoryStoreOperationUsageOutputTokensDetails(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MemoryStoreOperationUsageOutputTokensDetails DeserializeMemoryStoreOperationUsageOutputTokensDetails(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int reasoningTokens = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("reasoning_tokens"u8)) + { + reasoningTokens = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MemoryStoreOperationUsageOutputTokensDetails(reasoningTokens, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(MemoryStoreOperationUsageOutputTokensDetails)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemoryStoreOperationUsageOutputTokensDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MemoryStoreOperationUsageOutputTokensDetails PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemoryStoreOperationUsageOutputTokensDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemoryStoreOperationUsageOutputTokensDetails)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreOperationUsageOutputTokensDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreOperationUsageOutputTokensDetails.cs new file mode 100644 index 000000000000..9193cd821616 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreOperationUsageOutputTokensDetails.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// The MemoryStoreOperationUsageOutputTokensDetails. + public partial class MemoryStoreOperationUsageOutputTokensDetails + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The number of reasoning tokens. + internal MemoryStoreOperationUsageOutputTokensDetails(int reasoningTokens) + { + ReasoningTokens = reasoningTokens; + } + + /// Initializes a new instance of . + /// The number of reasoning tokens. + /// Keeps track of any properties unknown to the library. + internal MemoryStoreOperationUsageOutputTokensDetails(int reasoningTokens, IDictionary additionalBinaryDataProperties) + { + ReasoningTokens = reasoningTokens; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The number of reasoning tokens. + public int ReasoningTokens { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreSearchResponse.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreSearchResponse.Serialization.cs new file mode 100644 index 000000000000..005513dbe130 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreSearchResponse.Serialization.cs @@ -0,0 +1,174 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Memory search response. + public partial class MemoryStoreSearchResponse : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal MemoryStoreSearchResponse() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryStoreSearchResponse)} does not support writing '{format}' format."); + } + writer.WritePropertyName("search_id"u8); + writer.WriteStringValue(SearchId); + writer.WritePropertyName("memories"u8); + writer.WriteStartArray(); + foreach (MemorySearchItem item in Memories) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + writer.WritePropertyName("usage"u8); + writer.WriteObjectValue(Usage, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemoryStoreSearchResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MemoryStoreSearchResponse JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryStoreSearchResponse)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemoryStoreSearchResponse(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MemoryStoreSearchResponse DeserializeMemoryStoreSearchResponse(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string searchId = default; + IList memories = default; + MemoryStoreOperationUsage usage = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("search_id"u8)) + { + searchId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("memories"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(MemorySearchItem.DeserializeMemorySearchItem(item, options)); + } + memories = array; + continue; + } + if (prop.NameEquals("usage"u8)) + { + usage = MemoryStoreOperationUsage.DeserializeMemoryStoreOperationUsage(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MemoryStoreSearchResponse(searchId, memories, usage, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(MemoryStoreSearchResponse)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemoryStoreSearchResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MemoryStoreSearchResponse PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemoryStoreSearchResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemoryStoreSearchResponse)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator MemoryStoreSearchResponse(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMemoryStoreSearchResponse(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreSearchResponse.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreSearchResponse.cs new file mode 100644 index 000000000000..fdebb4630040 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreSearchResponse.cs @@ -0,0 +1,50 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects +{ + /// Memory search response. + public partial class MemoryStoreSearchResponse + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The unique ID of this search request. Use this value as previous_search_id in subsequent requests to perform incremental searches. + /// Related memory items found during the search operation. + /// Usage statistics associated with the memory search operation. + internal MemoryStoreSearchResponse(string searchId, IEnumerable memories, MemoryStoreOperationUsage usage) + { + SearchId = searchId; + Memories = memories.ToList(); + Usage = usage; + } + + /// Initializes a new instance of . + /// The unique ID of this search request. Use this value as previous_search_id in subsequent requests to perform incremental searches. + /// Related memory items found during the search operation. + /// Usage statistics associated with the memory search operation. + /// Keeps track of any properties unknown to the library. + internal MemoryStoreSearchResponse(string searchId, IList memories, MemoryStoreOperationUsage usage, IDictionary additionalBinaryDataProperties) + { + SearchId = searchId; + Memories = memories; + Usage = usage; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The unique ID of this search request. Use this value as previous_search_id in subsequent requests to perform incremental searches. + public string SearchId { get; } + + /// Related memory items found during the search operation. + public IList Memories { get; } + + /// Usage statistics associated with the memory search operation. + public MemoryStoreOperationUsage Usage { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreUpdateStatus.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreUpdateStatus.Serialization.cs new file mode 100644 index 000000000000..c7f93e714b7b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreUpdateStatus.Serialization.cs @@ -0,0 +1,48 @@ +// + +#nullable disable + +using System; + +namespace Azure.AI.Projects +{ + internal static partial class MemoryStoreUpdateStatusExtensions + { + /// The value to serialize. + public static string ToSerialString(this MemoryStoreUpdateStatus value) => value switch + { + MemoryStoreUpdateStatus.Queued => "queued", + MemoryStoreUpdateStatus.InProgress => "in_progress", + MemoryStoreUpdateStatus.Completed => "completed", + MemoryStoreUpdateStatus.Failed => "failed", + MemoryStoreUpdateStatus.Superseded => "superseded", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown MemoryStoreUpdateStatus value.") + }; + + /// The value to deserialize. + public static MemoryStoreUpdateStatus ToMemoryStoreUpdateStatus(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "queued")) + { + return MemoryStoreUpdateStatus.Queued; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "in_progress")) + { + return MemoryStoreUpdateStatus.InProgress; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "completed")) + { + return MemoryStoreUpdateStatus.Completed; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "failed")) + { + return MemoryStoreUpdateStatus.Failed; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "superseded")) + { + return MemoryStoreUpdateStatus.Superseded; + } + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown MemoryStoreUpdateStatus value."); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreUpdateStatus.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreUpdateStatus.cs new file mode 100644 index 000000000000..e5978fe7e3bc --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryStoreUpdateStatus.cs @@ -0,0 +1,21 @@ +// + +#nullable disable + +namespace Azure.AI.Projects +{ + /// Status of a memory store update operation. + public enum MemoryStoreUpdateStatus + { + /// Queued. + Queued, + /// InProgress. + InProgress, + /// Completed. + Completed, + /// Failed. + Failed, + /// Superseded. + Superseded + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryUpdateResult.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryUpdateResult.Serialization.cs new file mode 100644 index 000000000000..0596e30bb2e4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryUpdateResult.Serialization.cs @@ -0,0 +1,203 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Provides the status of a memory store update operation. + public partial class MemoryUpdateResult : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal MemoryUpdateResult() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryUpdateResult)} does not support writing '{format}' format."); + } + writer.WritePropertyName("update_id"u8); + writer.WriteStringValue(UpdateId); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToSerialString()); + if (Optional.IsDefined(SupersededBy)) + { + writer.WritePropertyName("superseded_by"u8); + writer.WriteStringValue(SupersededBy); + } + if (Optional.IsDefined(Details)) + { + writer.WritePropertyName("result"u8); + writer.WriteObjectValue(Details, options); + } + if (Optional.IsDefined(InternalError)) + { + writer.WritePropertyName("error"u8); + writer.WriteObjectValue(InternalError, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemoryUpdateResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MemoryUpdateResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryUpdateResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemoryUpdateResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MemoryUpdateResult DeserializeMemoryUpdateResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string updateId = default; + MemoryStoreUpdateStatus status = default; + string supersededBy = default; + MemoryUpdateResultDetails details = default; + FoundryOpenAIError internalError = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("update_id"u8)) + { + updateId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("status"u8)) + { + status = prop.Value.GetString().ToMemoryStoreUpdateStatus(); + continue; + } + if (prop.NameEquals("superseded_by"u8)) + { + supersededBy = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("result"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + details = MemoryUpdateResultDetails.DeserializeMemoryUpdateResultDetails(prop.Value, options); + continue; + } + if (prop.NameEquals("error"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + internalError = FoundryOpenAIError.DeserializeFoundryOpenAIError(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MemoryUpdateResult( + updateId, + status, + supersededBy, + details, + internalError, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(MemoryUpdateResult)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemoryUpdateResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MemoryUpdateResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemoryUpdateResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemoryUpdateResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator MemoryUpdateResult(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMemoryUpdateResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryUpdateResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryUpdateResult.cs new file mode 100644 index 000000000000..cfaa14664cb0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryUpdateResult.cs @@ -0,0 +1,51 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Provides the status of a memory store update operation. + public partial class MemoryUpdateResult + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The unique ID of this update request. Use this value as previous_update_id in subsequent requests to perform incremental updates. + /// The status of the memory update operation. One of "queued", "in_progress", "completed", "failed", or "superseded". + internal MemoryUpdateResult(string updateId, MemoryStoreUpdateStatus status) + { + UpdateId = updateId; + Status = status; + } + + /// Initializes a new instance of . + /// The unique ID of this update request. Use this value as previous_update_id in subsequent requests to perform incremental updates. + /// The status of the memory update operation. One of "queued", "in_progress", "completed", "failed", or "superseded". + /// The update_id the operation was superseded by when status is "superseded". + /// The result of memory store update operation when status is "completed". + /// Error object that describes the error when status is "failed". + /// Keeps track of any properties unknown to the library. + internal MemoryUpdateResult(string updateId, MemoryStoreUpdateStatus status, string supersededBy, MemoryUpdateResultDetails details, FoundryOpenAIError internalError, IDictionary additionalBinaryDataProperties) + { + UpdateId = updateId; + Status = status; + SupersededBy = supersededBy; + Details = details; + InternalError = internalError; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The unique ID of this update request. Use this value as previous_update_id in subsequent requests to perform incremental updates. + public string UpdateId { get; } + + /// The status of the memory update operation. One of "queued", "in_progress", "completed", "failed", or "superseded". + public MemoryStoreUpdateStatus Status { get; } + + /// The update_id the operation was superseded by when status is "superseded". + public string SupersededBy { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryUpdateResultDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryUpdateResultDetails.Serialization.cs new file mode 100644 index 000000000000..f6d72259dfe7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryUpdateResultDetails.Serialization.cs @@ -0,0 +1,166 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Memory update result. + public partial class MemoryUpdateResultDetails : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal MemoryUpdateResultDetails() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryUpdateResultDetails)} does not support writing '{format}' format."); + } + writer.WritePropertyName("memory_operations"u8); + writer.WriteStartArray(); + foreach (MemoryOperation item in MemoryOperations) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + writer.WritePropertyName("usage"u8); + writer.WriteObjectValue(Usage, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemoryUpdateResultDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual MemoryUpdateResultDetails JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryUpdateResultDetails)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemoryUpdateResultDetails(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MemoryUpdateResultDetails DeserializeMemoryUpdateResultDetails(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList memoryOperations = default; + MemoryStoreOperationUsage usage = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("memory_operations"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(MemoryOperation.DeserializeMemoryOperation(item, options)); + } + memoryOperations = array; + continue; + } + if (prop.NameEquals("usage"u8)) + { + usage = MemoryStoreOperationUsage.DeserializeMemoryStoreOperationUsage(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MemoryUpdateResultDetails(memoryOperations, usage, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(MemoryUpdateResultDetails)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemoryUpdateResultDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual MemoryUpdateResultDetails PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemoryUpdateResultDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemoryUpdateResultDetails)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator MemoryUpdateResultDetails(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMemoryUpdateResultDetails(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MemoryUpdateResultDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryUpdateResultDetails.cs new file mode 100644 index 000000000000..92588774cecc --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MemoryUpdateResultDetails.cs @@ -0,0 +1,43 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects +{ + /// Memory update result. + public partial class MemoryUpdateResultDetails + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// A list of individual memory operations that were performed during the update. + /// Usage statistics associated with the memory update operation. + internal MemoryUpdateResultDetails(IEnumerable memoryOperations, MemoryStoreOperationUsage usage) + { + MemoryOperations = memoryOperations.ToList(); + Usage = usage; + } + + /// Initializes a new instance of . + /// A list of individual memory operations that were performed during the update. + /// Usage statistics associated with the memory update operation. + /// Keeps track of any properties unknown to the library. + internal MemoryUpdateResultDetails(IList memoryOperations, MemoryStoreOperationUsage usage, IDictionary additionalBinaryDataProperties) + { + MemoryOperations = memoryOperations; + Usage = usage; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// A list of individual memory operations that were performed during the update. + public IList MemoryOperations { get; } + + /// Usage statistics associated with the memory update operation. + public MemoryStoreOperationUsage Usage { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MicrosoftFabricAgentTool.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MicrosoftFabricAgentTool.Serialization.cs new file mode 100644 index 000000000000..c9505cc74fe8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MicrosoftFabricAgentTool.Serialization.cs @@ -0,0 +1,132 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// The input definition information for a Microsoft Fabric tool as used to configure an agent. + internal partial class MicrosoftFabricAgentTool : InternalTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal MicrosoftFabricAgentTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MicrosoftFabricAgentTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("fabric_dataagent_preview"u8); + writer.WriteObjectValue(FabricDataagentPreview, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + MicrosoftFabricAgentTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (MicrosoftFabricAgentTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MicrosoftFabricAgentTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMicrosoftFabricAgentTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MicrosoftFabricAgentTool DeserializeMicrosoftFabricAgentTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + FabricDataAgentToolParameters fabricDataagentPreview = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("fabric_dataagent_preview"u8)) + { + fabricDataagentPreview = FabricDataAgentToolParameters.DeserializeFabricDataAgentToolParameters(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MicrosoftFabricAgentTool(@type, additionalBinaryDataProperties, fabricDataagentPreview); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(MicrosoftFabricAgentTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MicrosoftFabricAgentTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (MicrosoftFabricAgentTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMicrosoftFabricAgentTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MicrosoftFabricAgentTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MicrosoftFabricAgentTool.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MicrosoftFabricAgentTool.cs new file mode 100644 index 000000000000..3fc9227fd4cd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MicrosoftFabricAgentTool.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// The input definition information for a Microsoft Fabric tool as used to configure an agent. + internal partial class MicrosoftFabricAgentTool : InternalTool + { + /// Initializes a new instance of . + /// The fabric data agent tool parameters. + /// is null. + public MicrosoftFabricAgentTool(FabricDataAgentToolParameters fabricDataagentPreview) : base(ToolType.FabricDataagentPreview) + { + Argument.AssertNotNull(fabricDataagentPreview, nameof(fabricDataagentPreview)); + + FabricDataagentPreview = fabricDataagentPreview; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The fabric data agent tool parameters. + internal MicrosoftFabricAgentTool(ToolType @type, IDictionary additionalBinaryDataProperties, FabricDataAgentToolParameters fabricDataagentPreview) : base(@type, additionalBinaryDataProperties) + { + FabricDataagentPreview = fabricDataagentPreview; + } + + /// The fabric data agent tool parameters. + public FabricDataAgentToolParameters FabricDataagentPreview { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ModelSamplingParams.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ModelSamplingParams.Serialization.cs new file mode 100644 index 000000000000..1ff2afe6e09d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ModelSamplingParams.Serialization.cs @@ -0,0 +1,163 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Represents a set of parameters used to control the sampling behavior of a language model during text generation. + public partial class ModelSamplingParams : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ModelSamplingParams() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ModelSamplingParams)} does not support writing '{format}' format."); + } + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature); + writer.WritePropertyName("top_p"u8); + writer.WriteNumberValue(TopP); + writer.WritePropertyName("seed"u8); + writer.WriteNumberValue(Seed); + writer.WritePropertyName("max_completion_tokens"u8); + writer.WriteNumberValue(MaxCompletionTokens); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ModelSamplingParams IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ModelSamplingParams JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ModelSamplingParams)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeModelSamplingParams(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ModelSamplingParams DeserializeModelSamplingParams(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + float temperature = default; + float topP = default; + int seed = default; + int maxCompletionTokens = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("temperature"u8)) + { + temperature = prop.Value.GetSingle(); + continue; + } + if (prop.NameEquals("top_p"u8)) + { + topP = prop.Value.GetSingle(); + continue; + } + if (prop.NameEquals("seed"u8)) + { + seed = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("max_completion_tokens"u8)) + { + maxCompletionTokens = prop.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ModelSamplingParams(temperature, topP, seed, maxCompletionTokens, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(ModelSamplingParams)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ModelSamplingParams IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ModelSamplingParams PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeModelSamplingParams(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ModelSamplingParams)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ModelSamplingParams.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ModelSamplingParams.cs new file mode 100644 index 000000000000..e49efcfae6b9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ModelSamplingParams.cs @@ -0,0 +1,56 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Represents a set of parameters used to control the sampling behavior of a language model during text generation. + public partial class ModelSamplingParams + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The temperature parameter for sampling. + /// The top-p parameter for nucleus sampling. + /// The random seed for reproducibility. + /// The maximum number of tokens allowed in the completion. + internal ModelSamplingParams(float temperature, float topP, int seed, int maxCompletionTokens) + { + Temperature = temperature; + TopP = topP; + Seed = seed; + MaxCompletionTokens = maxCompletionTokens; + } + + /// Initializes a new instance of . + /// The temperature parameter for sampling. + /// The top-p parameter for nucleus sampling. + /// The random seed for reproducibility. + /// The maximum number of tokens allowed in the completion. + /// Keeps track of any properties unknown to the library. + internal ModelSamplingParams(float temperature, float topP, int seed, int maxCompletionTokens, IDictionary additionalBinaryDataProperties) + { + Temperature = temperature; + TopP = topP; + Seed = seed; + MaxCompletionTokens = maxCompletionTokens; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The temperature parameter for sampling. + public float Temperature { get; } + + /// The top-p parameter for nucleus sampling. + public float TopP { get; } + + /// The random seed for reproducibility. + public int Seed { get; } + + /// The maximum number of tokens allowed in the completion. + public int MaxCompletionTokens { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Models/AzureAIProjectsContext.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Models/AzureAIProjectsContext.cs index 752b56d38aad..eac8e2dd48ed 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/Models/AzureAIProjectsContext.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Models/AzureAIProjectsContext.cs @@ -5,6 +5,7 @@ using System.ClientModel.Primitives; using Azure.Core; using Azure.Core.Foundations; +using OpenAI; namespace Azure.AI.Projects { @@ -12,6 +13,14 @@ namespace Azure.AI.Projects /// Context class which will be filled in by the System.ClientModel.SourceGeneration. /// For more information /// + [ModelReaderWriterBuildable(typeof(A2ATool))] + [ModelReaderWriterBuildable(typeof(AgentClusterInsightResult))] + [ModelReaderWriterBuildable(typeof(AgentClusterInsightsRequest))] + [ModelReaderWriterBuildable(typeof(AgenticIdentityCredentials))] + [ModelReaderWriterBuildable(typeof(AgentManifestOptions))] + [ModelReaderWriterBuildable(typeof(AgentObjectVersions))] + [ModelReaderWriterBuildable(typeof(AgentTaxonomyInput))] + [ModelReaderWriterBuildable(typeof(AgentVersionCreationOptions))] [ModelReaderWriterBuildable(typeof(AIProjectBlobReference))] [ModelReaderWriterBuildable(typeof(AIProjectConnection))] [ModelReaderWriterBuildable(typeof(AIProjectConnectionApiKeyCredential))] @@ -24,26 +33,283 @@ namespace Azure.AI.Projects [ModelReaderWriterBuildable(typeof(AIProjectDeployment))] [ModelReaderWriterBuildable(typeof(AIProjectIndex))] [ModelReaderWriterBuildable(typeof(AIProjectIndexFieldMapping))] + [ModelReaderWriterBuildable(typeof(AISearchIndexResource))] + [ModelReaderWriterBuildable(typeof(AzureAIAgentTarget))] + [ModelReaderWriterBuildable(typeof(AzureAIAssistantTarget))] + [ModelReaderWriterBuildable(typeof(AzureAIModelTarget))] + [ModelReaderWriterBuildable(typeof(AzureAISearchAgentTool))] [ModelReaderWriterBuildable(typeof(AzureAISearchIndex))] + [ModelReaderWriterBuildable(typeof(AzureAISearchToolResource))] + [ModelReaderWriterBuildable(typeof(AzureFunctionAgentTool))] + [ModelReaderWriterBuildable(typeof(AzureFunctionBinding))] + [ModelReaderWriterBuildable(typeof(AzureFunctionDefinition))] + [ModelReaderWriterBuildable(typeof(AzureFunctionDefinitionFunction))] + [ModelReaderWriterBuildable(typeof(AzureFunctionStorageQueue))] + [ModelReaderWriterBuildable(typeof(AzureOpenAIModelConfiguration))] + [ModelReaderWriterBuildable(typeof(BingCustomSearchAgentTool))] + [ModelReaderWriterBuildable(typeof(BingCustomSearchConfiguration))] + [ModelReaderWriterBuildable(typeof(BingCustomSearchToolParameters))] + [ModelReaderWriterBuildable(typeof(BingGroundingAgentTool))] + [ModelReaderWriterBuildable(typeof(BingGroundingSearchConfiguration))] + [ModelReaderWriterBuildable(typeof(BingGroundingSearchToolParameters))] [ModelReaderWriterBuildable(typeof(BlobReferenceSasCredential))] + [ModelReaderWriterBuildable(typeof(BrowserAutomationAgentTool))] + [ModelReaderWriterBuildable(typeof(BrowserAutomationToolConnectionParameters))] + [ModelReaderWriterBuildable(typeof(BrowserAutomationToolParameters))] + [ModelReaderWriterBuildable(typeof(CaptureStructuredOutputsTool))] + [ModelReaderWriterBuildable(typeof(ChartCoordinate))] + [ModelReaderWriterBuildable(typeof(ChatSummaryMemoryItem))] + [ModelReaderWriterBuildable(typeof(ClusterInsightResult))] + [ModelReaderWriterBuildable(typeof(ClusterTokenUsage))] + [ModelReaderWriterBuildable(typeof(CodeBasedEvaluatorDefinition))] + [ModelReaderWriterBuildable(typeof(ContainerAppAgentDefinition))] + [ModelReaderWriterBuildable(typeof(ContinuousEvaluationRuleAction))] + [ModelReaderWriterBuildable(typeof(CreateAgentVersionFromManifestRequest))] + [ModelReaderWriterBuildable(typeof(CronTrigger))] + [ModelReaderWriterBuildable(typeof(DailyRecurrenceSchedule))] [ModelReaderWriterBuildable(typeof(DatasetCredential))] + [ModelReaderWriterBuildable(typeof(DeleteMemoryStoreResponse))] + [ModelReaderWriterBuildable(typeof(DeleteScopeRequest))] [ModelReaderWriterBuildable(typeof(EmbeddingConfiguration))] + [ModelReaderWriterBuildable(typeof(EvalCompareReport))] + [ModelReaderWriterBuildable(typeof(EvalResult))] + [ModelReaderWriterBuildable(typeof(EvalRunResultCompareItem))] + [ModelReaderWriterBuildable(typeof(EvalRunResultComparison))] + [ModelReaderWriterBuildable(typeof(EvalRunResultSummary))] + [ModelReaderWriterBuildable(typeof(EvaluationComparisonRequest))] + [ModelReaderWriterBuildable(typeof(EvaluationResultSample))] + [ModelReaderWriterBuildable(typeof(EvaluationRule))] + [ModelReaderWriterBuildable(typeof(EvaluationRuleAction))] + [ModelReaderWriterBuildable(typeof(EvaluationRuleFilter))] + [ModelReaderWriterBuildable(typeof(EvaluationRunClusterInsightResult))] + [ModelReaderWriterBuildable(typeof(EvaluationRunClusterInsightsRequest))] + [ModelReaderWriterBuildable(typeof(EvaluationScheduleTask))] + [ModelReaderWriterBuildable(typeof(EvaluationScheduleTaskEvalRun))] + [ModelReaderWriterBuildable(typeof(EvaluationTaxonomy))] + [ModelReaderWriterBuildable(typeof(EvaluationTaxonomyInput))] + [ModelReaderWriterBuildable(typeof(EvaluatorDefinition))] + [ModelReaderWriterBuildable(typeof(EvaluatorMetric))] + [ModelReaderWriterBuildable(typeof(EvaluatorVersion))] + [ModelReaderWriterBuildable(typeof(FabricDataAgentToolParameters))] [ModelReaderWriterBuildable(typeof(FileDataset))] [ModelReaderWriterBuildable(typeof(FolderDataset))] + [ModelReaderWriterBuildable(typeof(FoundryOpenAIError))] + [ModelReaderWriterBuildable(typeof(HostedAgentDefinition))] + [ModelReaderWriterBuildable(typeof(HourlyRecurrenceSchedule))] + [ModelReaderWriterBuildable(typeof(HumanEvaluationRuleAction))] + [ModelReaderWriterBuildable(typeof(ImageBasedHostedAgentDefinition))] + [ModelReaderWriterBuildable(typeof(InnerError))] + [ModelReaderWriterBuildable(typeof(Insight))] + [ModelReaderWriterBuildable(typeof(InsightCluster))] + [ModelReaderWriterBuildable(typeof(InsightModelConfiguration))] + [ModelReaderWriterBuildable(typeof(InsightRequest))] + [ModelReaderWriterBuildable(typeof(InsightResult))] + [ModelReaderWriterBuildable(typeof(InsightSample))] + [ModelReaderWriterBuildable(typeof(InsightScheduleTask))] + [ModelReaderWriterBuildable(typeof(InsightsMetadata))] + [ModelReaderWriterBuildable(typeof(InsightSummary))] + [ModelReaderWriterBuildable(typeof(InternalAgentDefinition))] + [ModelReaderWriterBuildable(typeof(InternalAgentObject))] + [ModelReaderWriterBuildable(typeof(InternalAgentVersionObject))] + [ModelReaderWriterBuildable(typeof(InternalAnnotation))] + [ModelReaderWriterBuildable(typeof(InternalAnnotationFileCitation))] + [ModelReaderWriterBuildable(typeof(InternalAnnotationFilePath))] + [ModelReaderWriterBuildable(typeof(InternalAnnotationUrlCitation))] + [ModelReaderWriterBuildable(typeof(InternalApproximateLocation))] + [ModelReaderWriterBuildable(typeof(InternalCodeInterpreterOutput))] + [ModelReaderWriterBuildable(typeof(InternalCodeInterpreterOutputImage))] + [ModelReaderWriterBuildable(typeof(InternalCodeInterpreterOutputLogs))] + [ModelReaderWriterBuildable(typeof(InternalCodeInterpreterTool))] + [ModelReaderWriterBuildable(typeof(InternalCodeInterpreterToolAuto))] + [ModelReaderWriterBuildable(typeof(InternalCodeInterpreterToolCallItemParam))] + [ModelReaderWriterBuildable(typeof(InternalComparisonFilter))] + [ModelReaderWriterBuildable(typeof(InternalCompoundFilter))] + [ModelReaderWriterBuildable(typeof(InternalComputerAction))] + [ModelReaderWriterBuildable(typeof(InternalComputerActionClick))] + [ModelReaderWriterBuildable(typeof(InternalComputerActionDoubleClick))] + [ModelReaderWriterBuildable(typeof(InternalComputerActionDrag))] + [ModelReaderWriterBuildable(typeof(InternalComputerActionKeyPress))] + [ModelReaderWriterBuildable(typeof(InternalComputerActionMove))] + [ModelReaderWriterBuildable(typeof(InternalComputerActionScreenshot))] + [ModelReaderWriterBuildable(typeof(InternalComputerActionScroll))] + [ModelReaderWriterBuildable(typeof(InternalComputerActionTypeKeys))] + [ModelReaderWriterBuildable(typeof(InternalComputerActionWait))] + [ModelReaderWriterBuildable(typeof(InternalComputerToolCallItemParam))] + [ModelReaderWriterBuildable(typeof(InternalComputerToolCallOutputItemOutput))] + [ModelReaderWriterBuildable(typeof(InternalComputerToolCallOutputItemOutputComputerScreenshot))] + [ModelReaderWriterBuildable(typeof(InternalComputerToolCallOutputItemParam))] + [ModelReaderWriterBuildable(typeof(InternalComputerToolCallSafetyCheck))] + [ModelReaderWriterBuildable(typeof(InternalComputerUsePreviewTool))] + [ModelReaderWriterBuildable(typeof(InternalCoordinate))] + [ModelReaderWriterBuildable(typeof(InternalCreateAgentRequest))] + [ModelReaderWriterBuildable(typeof(InternalCreateMemoryStoreRequest))] + [ModelReaderWriterBuildable(typeof(InternalFileSearchTool))] + [ModelReaderWriterBuildable(typeof(InternalFileSearchToolCallItemParam))] + [ModelReaderWriterBuildable(typeof(InternalFileSearchToolCallItemParamResult))] + [ModelReaderWriterBuildable(typeof(InternalFunctionTool))] + [ModelReaderWriterBuildable(typeof(InternalFunctionToolCallItemParam))] + [ModelReaderWriterBuildable(typeof(InternalFunctionToolCallOutputItemParam))] + [ModelReaderWriterBuildable(typeof(InternalImageGenTool))] + [ModelReaderWriterBuildable(typeof(InternalImageGenToolCallItemParam))] + [ModelReaderWriterBuildable(typeof(InternalImageGenToolInputImageMask))] + [ModelReaderWriterBuildable(typeof(InternalItemContent))] + [ModelReaderWriterBuildable(typeof(InternalItemContentInputAudio))] + [ModelReaderWriterBuildable(typeof(InternalItemContentInputFile))] + [ModelReaderWriterBuildable(typeof(InternalItemContentInputImage))] + [ModelReaderWriterBuildable(typeof(InternalItemContentInputText))] + [ModelReaderWriterBuildable(typeof(InternalItemContentOutputAudio))] + [ModelReaderWriterBuildable(typeof(InternalItemContentOutputText))] + [ModelReaderWriterBuildable(typeof(InternalItemContentRefusal))] + [ModelReaderWriterBuildable(typeof(InternalItemParam))] + [ModelReaderWriterBuildable(typeof(InternalItemReferenceItemParam))] + [ModelReaderWriterBuildable(typeof(InternalLocalShellExecAction))] + [ModelReaderWriterBuildable(typeof(InternalLocalShellTool))] + [ModelReaderWriterBuildable(typeof(InternalLocalShellToolCallItemParam))] + [ModelReaderWriterBuildable(typeof(InternalLocalShellToolCallOutputItemParam))] + [ModelReaderWriterBuildable(typeof(InternalLocation))] + [ModelReaderWriterBuildable(typeof(InternalLogProb))] + [ModelReaderWriterBuildable(typeof(InternalMCPApprovalRequestItemParam))] + [ModelReaderWriterBuildable(typeof(InternalMCPApprovalResponseItemParam))] + [ModelReaderWriterBuildable(typeof(InternalMCPCallItemParam))] + [ModelReaderWriterBuildable(typeof(InternalMCPListToolsItemParam))] + [ModelReaderWriterBuildable(typeof(InternalMCPListToolsTool))] + [ModelReaderWriterBuildable(typeof(InternalMCPTool))] + [ModelReaderWriterBuildable(typeof(InternalMCPToolAllowedTools1))] + [ModelReaderWriterBuildable(typeof(InternalMCPToolRequireApproval1))] + [ModelReaderWriterBuildable(typeof(InternalMCPToolRequireApprovalAlways))] + [ModelReaderWriterBuildable(typeof(InternalMCPToolRequireApprovalNever))] + [ModelReaderWriterBuildable(typeof(InternalMemorySearchOptions))] + [ModelReaderWriterBuildable(typeof(InternalMemoryUpdateOptions))] + [ModelReaderWriterBuildable(typeof(InternalPromptAgentDefinition))] + [ModelReaderWriterBuildable(typeof(InternalRankingOptions))] + [ModelReaderWriterBuildable(typeof(InternalReasoning))] + [ModelReaderWriterBuildable(typeof(InternalReasoningItemParam))] + [ModelReaderWriterBuildable(typeof(InternalReasoningItemSummaryPart))] + [ModelReaderWriterBuildable(typeof(InternalReasoningItemSummaryTextPart))] + [ModelReaderWriterBuildable(typeof(InternalResponsesAssistantMessageItemParam))] + [ModelReaderWriterBuildable(typeof(InternalResponsesDeveloperMessageItemParam))] + [ModelReaderWriterBuildable(typeof(InternalResponsesMessageItemParam))] + [ModelReaderWriterBuildable(typeof(InternalResponsesSystemMessageItemParam))] + [ModelReaderWriterBuildable(typeof(InternalResponsesUserMessageItemParam))] + [ModelReaderWriterBuildable(typeof(InternalResponseTextFormatConfiguration))] + [ModelReaderWriterBuildable(typeof(InternalResponseTextFormatConfigurationJsonObject))] + [ModelReaderWriterBuildable(typeof(InternalResponseTextFormatConfigurationJsonSchema))] + [ModelReaderWriterBuildable(typeof(InternalResponseTextFormatConfigurationText))] + [ModelReaderWriterBuildable(typeof(InternalTool))] + [ModelReaderWriterBuildable(typeof(InternalTopLogProb))] + [ModelReaderWriterBuildable(typeof(InternalUpdateAgentRequest))] + [ModelReaderWriterBuildable(typeof(InternalVectorStoreFileAttributes))] + [ModelReaderWriterBuildable(typeof(InternalWebSearchAction))] + [ModelReaderWriterBuildable(typeof(InternalWebSearchActionFind))] + [ModelReaderWriterBuildable(typeof(InternalWebSearchActionOpenPage))] + [ModelReaderWriterBuildable(typeof(InternalWebSearchActionSearch))] + [ModelReaderWriterBuildable(typeof(InternalWebSearchPreviewTool))] + [ModelReaderWriterBuildable(typeof(InternalWebSearchToolCallItemParam))] [ModelReaderWriterBuildable(typeof(ManagedAzureAISearchIndex))] + [ModelReaderWriterBuildable(typeof(MemoryItem))] + [ModelReaderWriterBuildable(typeof(MemoryOperation))] + [ModelReaderWriterBuildable(typeof(MemorySearchItem))] + [ModelReaderWriterBuildable(typeof(MemorySearchResultOptions))] + [ModelReaderWriterBuildable(typeof(MemorySearchTool))] + [ModelReaderWriterBuildable(typeof(MemorySearchToolCallItemParam))] + [ModelReaderWriterBuildable(typeof(MemoryStore))] + [ModelReaderWriterBuildable(typeof(MemoryStoreDefaultDefinition))] + [ModelReaderWriterBuildable(typeof(MemoryStoreDefaultOptions))] + [ModelReaderWriterBuildable(typeof(MemoryStoreDefinition))] + [ModelReaderWriterBuildable(typeof(MemoryStoreDeleteScopeResponse))] + [ModelReaderWriterBuildable(typeof(MemoryStoreOperationUsage))] + [ModelReaderWriterBuildable(typeof(MemoryStoreOperationUsageInputTokensDetails))] + [ModelReaderWriterBuildable(typeof(MemoryStoreOperationUsageOutputTokensDetails))] + [ModelReaderWriterBuildable(typeof(MemoryStoreSearchResponse))] + [ModelReaderWriterBuildable(typeof(MemoryUpdateResult))] + [ModelReaderWriterBuildable(typeof(MemoryUpdateResultDetails))] + [ModelReaderWriterBuildable(typeof(MicrosoftFabricAgentTool))] [ModelReaderWriterBuildable(typeof(ModelDeployment))] [ModelReaderWriterBuildable(typeof(ModelDeploymentSku))] + [ModelReaderWriterBuildable(typeof(ModelSamplingParams))] + [ModelReaderWriterBuildable(typeof(MonthlyRecurrenceSchedule))] [ModelReaderWriterBuildable(typeof(NoAuthenticationCredentials))] + [ModelReaderWriterBuildable(typeof(OneTimeTrigger))] + [ModelReaderWriterBuildable(typeof(OpenApiAgentTool))] + [ModelReaderWriterBuildable(typeof(OpenApiAnonymousAuthDetails))] + [ModelReaderWriterBuildable(typeof(OpenApiAuthDetails))] + [ModelReaderWriterBuildable(typeof(OpenApiFunctionDefinition))] + [ModelReaderWriterBuildable(typeof(OpenApiFunctionDefinitionFunction))] + [ModelReaderWriterBuildable(typeof(OpenApiManagedAuthDetails))] + [ModelReaderWriterBuildable(typeof(OpenApiManagedSecurityScheme))] + [ModelReaderWriterBuildable(typeof(OpenApiProjectConnectionAuthDetails))] + [ModelReaderWriterBuildable(typeof(OpenApiProjectConnectionSecurityScheme))] [ModelReaderWriterBuildable(typeof(PagedConnection))] [ModelReaderWriterBuildable(typeof(PagedDatasetVersion))] [ModelReaderWriterBuildable(typeof(PagedDeployment))] + [ModelReaderWriterBuildable(typeof(PagedEvaluationRule))] + [ModelReaderWriterBuildable(typeof(PagedEvaluationTaxonomy))] + [ModelReaderWriterBuildable(typeof(PagedEvaluatorVersion))] [ModelReaderWriterBuildable(typeof(PagedIndex))] + [ModelReaderWriterBuildable(typeof(PagedInsight))] + [ModelReaderWriterBuildable(typeof(PagedRedTeam))] + [ModelReaderWriterBuildable(typeof(PagedSchedule))] + [ModelReaderWriterBuildable(typeof(PagedScheduleRun))] [ModelReaderWriterBuildable(typeof(PendingUploadConfiguration))] [ModelReaderWriterBuildable(typeof(PendingUploadResult))] + [ModelReaderWriterBuildable(typeof(PromptAgentDefinitionText))] + [ModelReaderWriterBuildable(typeof(PromptBasedEvaluatorDefinition))] + [ModelReaderWriterBuildable(typeof(ProtocolVersionRecord))] + [ModelReaderWriterBuildable(typeof(RaiConfig))] + [ModelReaderWriterBuildable(typeof(RecurrenceSchedule))] + [ModelReaderWriterBuildable(typeof(RecurrenceTrigger))] + [ModelReaderWriterBuildable(typeof(RedTeam))] + [ModelReaderWriterBuildable(typeof(Schedule))] + [ModelReaderWriterBuildable(typeof(ScheduleRun))] + [ModelReaderWriterBuildable(typeof(ScheduleTask))] + [ModelReaderWriterBuildable(typeof(SharepointAgentTool))] + [ModelReaderWriterBuildable(typeof(SharepointGroundingToolParameters))] + [ModelReaderWriterBuildable(typeof(StructuredInputDefinition))] + [ModelReaderWriterBuildable(typeof(StructuredOutputDefinition))] + [ModelReaderWriterBuildable(typeof(Target))] + [ModelReaderWriterBuildable(typeof(TargetConfig))] + [ModelReaderWriterBuildable(typeof(TaxonomyCategory))] + [ModelReaderWriterBuildable(typeof(TaxonomySubCategory))] + [ModelReaderWriterBuildable(typeof(ToolDescription))] + [ModelReaderWriterBuildable(typeof(ToolProjectConnection))] + [ModelReaderWriterBuildable(typeof(Trigger))] + [ModelReaderWriterBuildable(typeof(UnknownAgentDefinition))] [ModelReaderWriterBuildable(typeof(UnknownAIProjectConnectionBaseCredential))] [ModelReaderWriterBuildable(typeof(UnknownAIProjectDataset))] [ModelReaderWriterBuildable(typeof(UnknownAIProjectDeployment))] [ModelReaderWriterBuildable(typeof(UnknownAIProjectIndex))] + [ModelReaderWriterBuildable(typeof(UnknownAnnotation))] + [ModelReaderWriterBuildable(typeof(UnknownCodeInterpreterOutput))] + [ModelReaderWriterBuildable(typeof(UnknownComputerAction))] + [ModelReaderWriterBuildable(typeof(UnknownComputerToolCallOutputItemOutput))] + [ModelReaderWriterBuildable(typeof(UnknownEvaluationRuleAction))] + [ModelReaderWriterBuildable(typeof(UnknownEvaluationTaxonomyInput))] + [ModelReaderWriterBuildable(typeof(UnknownEvaluatorDefinition))] + [ModelReaderWriterBuildable(typeof(UnknownHostedAgentDefinition))] + [ModelReaderWriterBuildable(typeof(UnknownInsightRequest))] + [ModelReaderWriterBuildable(typeof(UnknownInsightResult))] + [ModelReaderWriterBuildable(typeof(UnknownInsightSample))] + [ModelReaderWriterBuildable(typeof(UnknownItemContent))] + [ModelReaderWriterBuildable(typeof(UnknownItemParam))] + [ModelReaderWriterBuildable(typeof(UnknownLocation))] + [ModelReaderWriterBuildable(typeof(UnknownMemoryItem))] + [ModelReaderWriterBuildable(typeof(UnknownMemoryStoreDefinition))] + [ModelReaderWriterBuildable(typeof(UnknownOpenApiAuthDetails))] + [ModelReaderWriterBuildable(typeof(UnknownReasoningItemSummaryPart))] + [ModelReaderWriterBuildable(typeof(UnknownRecurrenceSchedule))] + [ModelReaderWriterBuildable(typeof(UnknownResponsesMessageItemParam))] + [ModelReaderWriterBuildable(typeof(UnknownResponseTextFormatConfiguration))] + [ModelReaderWriterBuildable(typeof(UnknownScheduleTask))] + [ModelReaderWriterBuildable(typeof(UnknownTarget))] + [ModelReaderWriterBuildable(typeof(UnknownTargetConfig))] + [ModelReaderWriterBuildable(typeof(UnknownTool))] + [ModelReaderWriterBuildable(typeof(UnknownTrigger))] + [ModelReaderWriterBuildable(typeof(UnknownWebSearchAction))] + [ModelReaderWriterBuildable(typeof(UpdateMemoryStoreRequest))] + [ModelReaderWriterBuildable(typeof(UserProfileMemoryItem))] + [ModelReaderWriterBuildable(typeof(WebSearchActionSearchSources))] + [ModelReaderWriterBuildable(typeof(WeeklyRecurrenceSchedule))] + [ModelReaderWriterBuildable(typeof(WorkflowAgentDefinition))] public partial class AzureAIProjectsContext : ModelReaderWriterContext { } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MonthlyRecurrenceSchedule.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MonthlyRecurrenceSchedule.Serialization.cs new file mode 100644 index 000000000000..5b3efa8f4440 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MonthlyRecurrenceSchedule.Serialization.cs @@ -0,0 +1,141 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Monthly recurrence schedule. + public partial class MonthlyRecurrenceSchedule : RecurrenceSchedule, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal MonthlyRecurrenceSchedule() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MonthlyRecurrenceSchedule)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("daysOfMonth"u8); + writer.WriteStartArray(); + foreach (int item in DaysOfMonth) + { + writer.WriteNumberValue(item); + } + writer.WriteEndArray(); + } + + /// The JSON reader. + /// The client options for reading and writing models. + MonthlyRecurrenceSchedule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (MonthlyRecurrenceSchedule)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override RecurrenceSchedule JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MonthlyRecurrenceSchedule)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMonthlyRecurrenceSchedule(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static MonthlyRecurrenceSchedule DeserializeMonthlyRecurrenceSchedule(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RecurrenceType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList daysOfMonth = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new RecurrenceType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("daysOfMonth"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(item.GetInt32()); + } + daysOfMonth = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MonthlyRecurrenceSchedule(@type, additionalBinaryDataProperties, daysOfMonth); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(MonthlyRecurrenceSchedule)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MonthlyRecurrenceSchedule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (MonthlyRecurrenceSchedule)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override RecurrenceSchedule PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMonthlyRecurrenceSchedule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MonthlyRecurrenceSchedule)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MonthlyRecurrenceSchedule.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MonthlyRecurrenceSchedule.cs new file mode 100644 index 000000000000..ba94361740ef --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MonthlyRecurrenceSchedule.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects +{ + /// Monthly recurrence schedule. + public partial class MonthlyRecurrenceSchedule : RecurrenceSchedule + { + /// Initializes a new instance of . + /// Days of the month for the recurrence schedule. + /// is null. + public MonthlyRecurrenceSchedule(IEnumerable daysOfMonth) : base(RecurrenceType.Monthly) + { + Argument.AssertNotNull(daysOfMonth, nameof(daysOfMonth)); + + DaysOfMonth = daysOfMonth.ToList(); + } + + /// Initializes a new instance of . + /// Recurrence type for the recurrence schedule. + /// Keeps track of any properties unknown to the library. + /// Days of the month for the recurrence schedule. + internal MonthlyRecurrenceSchedule(RecurrenceType @type, IDictionary additionalBinaryDataProperties, IList daysOfMonth) : base(@type, additionalBinaryDataProperties) + { + DaysOfMonth = daysOfMonth; + } + + /// Days of the month for the recurrence schedule. + public IList DaysOfMonth { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OneTimeTrigger.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OneTimeTrigger.Serialization.cs new file mode 100644 index 000000000000..aad83ea8e560 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OneTimeTrigger.Serialization.cs @@ -0,0 +1,142 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// One-time trigger. + public partial class OneTimeTrigger : Trigger, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal OneTimeTrigger() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OneTimeTrigger)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("triggerAt"u8); + writer.WriteStringValue(TriggerAt); + if (Optional.IsDefined(TimeZone)) + { + writer.WritePropertyName("timeZone"u8); + writer.WriteStringValue(TimeZone); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + OneTimeTrigger IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (OneTimeTrigger)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override Trigger JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OneTimeTrigger)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOneTimeTrigger(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OneTimeTrigger DeserializeOneTimeTrigger(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TriggerType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string triggerAt = default; + string timeZone = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new TriggerType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("triggerAt"u8)) + { + triggerAt = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("timeZone"u8)) + { + timeZone = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new OneTimeTrigger(@type, additionalBinaryDataProperties, triggerAt, timeZone); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(OneTimeTrigger)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + OneTimeTrigger IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (OneTimeTrigger)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override Trigger PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeOneTimeTrigger(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OneTimeTrigger)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OneTimeTrigger.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OneTimeTrigger.cs new file mode 100644 index 000000000000..1af9e5916a1e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OneTimeTrigger.cs @@ -0,0 +1,40 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// One-time trigger. + public partial class OneTimeTrigger : Trigger + { + /// Initializes a new instance of . + /// Date and time for the one-time trigger in ISO 8601 format. + /// is null. + public OneTimeTrigger(string triggerAt) : base(TriggerType.OneTime) + { + Argument.AssertNotNull(triggerAt, nameof(triggerAt)); + + TriggerAt = triggerAt; + } + + /// Initializes a new instance of . + /// Type of the trigger. + /// Keeps track of any properties unknown to the library. + /// Date and time for the one-time trigger in ISO 8601 format. + /// Time zone for the one-time trigger. + internal OneTimeTrigger(TriggerType @type, IDictionary additionalBinaryDataProperties, string triggerAt, string timeZone) : base(@type, additionalBinaryDataProperties) + { + TriggerAt = triggerAt; + TimeZone = timeZone; + } + + /// Date and time for the one-time trigger in ISO 8601 format. + public string TriggerAt { get; set; } + + /// Time zone for the one-time trigger. + public string TimeZone { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAgentTool.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAgentTool.Serialization.cs new file mode 100644 index 000000000000..a3a4966ca0f9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAgentTool.Serialization.cs @@ -0,0 +1,132 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// The input definition information for an OpenAPI tool as used to configure an agent. + internal partial class OpenApiAgentTool : InternalTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal OpenApiAgentTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiAgentTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("openapi"u8); + writer.WriteObjectValue(Openapi, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + OpenApiAgentTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (OpenApiAgentTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiAgentTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenApiAgentTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OpenApiAgentTool DeserializeOpenApiAgentTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + OpenApiFunctionDefinition openapi = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("openapi"u8)) + { + openapi = OpenApiFunctionDefinition.DeserializeOpenApiFunctionDefinition(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new OpenApiAgentTool(@type, additionalBinaryDataProperties, openapi); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(OpenApiAgentTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + OpenApiAgentTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (OpenApiAgentTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeOpenApiAgentTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenApiAgentTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAgentTool.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAgentTool.cs new file mode 100644 index 000000000000..90c88e7ee9cb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAgentTool.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// The input definition information for an OpenAPI tool as used to configure an agent. + internal partial class OpenApiAgentTool : InternalTool + { + /// Initializes a new instance of . + /// The openapi function definition. + /// is null. + public OpenApiAgentTool(OpenApiFunctionDefinition openapi) : base(ToolType.Openapi) + { + Argument.AssertNotNull(openapi, nameof(openapi)); + + Openapi = openapi; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The openapi function definition. + internal OpenApiAgentTool(ToolType @type, IDictionary additionalBinaryDataProperties, OpenApiFunctionDefinition openapi) : base(@type, additionalBinaryDataProperties) + { + Openapi = openapi; + } + + /// The openapi function definition. + public OpenApiFunctionDefinition Openapi { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAnonymousAuthDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAnonymousAuthDetails.Serialization.cs new file mode 100644 index 000000000000..b9f2c40d28c0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAnonymousAuthDetails.Serialization.cs @@ -0,0 +1,118 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Security details for OpenApi anonymous authentication. + internal partial class OpenApiAnonymousAuthDetails : OpenApiAuthDetails, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiAnonymousAuthDetails)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + OpenApiAnonymousAuthDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (OpenApiAnonymousAuthDetails)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override OpenApiAuthDetails JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiAnonymousAuthDetails)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenApiAnonymousAuthDetails(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OpenApiAnonymousAuthDetails DeserializeOpenApiAnonymousAuthDetails(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenApiAuthType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new OpenApiAuthType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new OpenApiAnonymousAuthDetails(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(OpenApiAnonymousAuthDetails)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + OpenApiAnonymousAuthDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (OpenApiAnonymousAuthDetails)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override OpenApiAuthDetails PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeOpenApiAnonymousAuthDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenApiAnonymousAuthDetails)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAnonymousAuthDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAnonymousAuthDetails.cs new file mode 100644 index 000000000000..ae7dc377a041 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAnonymousAuthDetails.cs @@ -0,0 +1,25 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Security details for OpenApi anonymous authentication. + internal partial class OpenApiAnonymousAuthDetails : OpenApiAuthDetails + { + /// Initializes a new instance of . + public OpenApiAnonymousAuthDetails() : base(OpenApiAuthType.Anonymous) + { + } + + /// Initializes a new instance of . + /// The type of authentication, must be anonymous/project_connection/managed_identity. + /// Keeps track of any properties unknown to the library. + internal OpenApiAnonymousAuthDetails(OpenApiAuthType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAuthDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAuthDetails.Serialization.cs new file mode 100644 index 000000000000..e06c5a017bd2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAuthDetails.Serialization.cs @@ -0,0 +1,140 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// + /// authentication details for OpenApiFunctionDefinition + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// + [PersistableModelProxy(typeof(UnknownOpenApiAuthDetails))] + internal abstract partial class OpenApiAuthDetails : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal OpenApiAuthDetails() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiAuthDetails)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + OpenApiAuthDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual OpenApiAuthDetails JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiAuthDetails)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenApiAuthDetails(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OpenApiAuthDetails DeserializeOpenApiAuthDetails(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "anonymous": + return OpenApiAnonymousAuthDetails.DeserializeOpenApiAnonymousAuthDetails(element, options); + case "project_connection": + return OpenApiProjectConnectionAuthDetails.DeserializeOpenApiProjectConnectionAuthDetails(element, options); + case "managed_identity": + return OpenApiManagedAuthDetails.DeserializeOpenApiManagedAuthDetails(element, options); + } + } + return UnknownOpenApiAuthDetails.DeserializeUnknownOpenApiAuthDetails(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(OpenApiAuthDetails)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + OpenApiAuthDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual OpenApiAuthDetails PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeOpenApiAuthDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenApiAuthDetails)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAuthDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAuthDetails.cs new file mode 100644 index 000000000000..709ec6a9dc04 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAuthDetails.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// + /// authentication details for OpenApiFunctionDefinition + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// + internal abstract partial class OpenApiAuthDetails + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The type of authentication, must be anonymous/project_connection/managed_identity. + private protected OpenApiAuthDetails(OpenApiAuthType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// The type of authentication, must be anonymous/project_connection/managed_identity. + /// Keeps track of any properties unknown to the library. + internal OpenApiAuthDetails(OpenApiAuthType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The type of authentication, must be anonymous/project_connection/managed_identity. + internal OpenApiAuthType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAuthType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAuthType.cs new file mode 100644 index 000000000000..e6cceb4c8f82 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiAuthType.cs @@ -0,0 +1,74 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// + /// Authentication type for OpenApi endpoint. Allowed types are: + /// - Anonymous (no authentication required) + /// - Project Connection (requires project_connection_id to endpoint, as setup in AI Foundry) + /// - Managed_Identity (requires audience for identity based auth) + /// + internal readonly partial struct OpenApiAuthType : IEquatable + { + private readonly string _value; + private const string AnonymousValue = "anonymous"; + private const string ProjectConnectionValue = "project_connection"; + private const string ManagedIdentityValue = "managed_identity"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public OpenApiAuthType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Anonymous. + public static OpenApiAuthType Anonymous { get; } = new OpenApiAuthType(AnonymousValue); + + /// Gets the ProjectConnection. + public static OpenApiAuthType ProjectConnection { get; } = new OpenApiAuthType(ProjectConnectionValue); + + /// Gets the ManagedIdentity. + public static OpenApiAuthType ManagedIdentity { get; } = new OpenApiAuthType(ManagedIdentityValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(OpenApiAuthType left, OpenApiAuthType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(OpenApiAuthType left, OpenApiAuthType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator OpenApiAuthType(string value) => new OpenApiAuthType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator OpenApiAuthType?(string value) => value == null ? null : new OpenApiAuthType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OpenApiAuthType other && Equals(other); + + /// + public bool Equals(OpenApiAuthType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinition.Serialization.cs new file mode 100644 index 000000000000..2a6a8b5615eb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinition.Serialization.cs @@ -0,0 +1,242 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The input definition information for an openapi function. + internal partial class OpenApiFunctionDefinition : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal OpenApiFunctionDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiFunctionDefinition)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("spec"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Spec); +#else + using (JsonDocument document = JsonDocument.Parse(Spec)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + writer.WritePropertyName("auth"u8); + writer.WriteObjectValue(Auth, options); + if (Optional.IsCollectionDefined(DefaultParams)) + { + writer.WritePropertyName("default_params"u8); + writer.WriteStartArray(); + foreach (string item in DefaultParams) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Functions)) + { + writer.WritePropertyName("functions"u8); + writer.WriteStartArray(); + foreach (OpenApiFunctionDefinitionFunction item in Functions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + OpenApiFunctionDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual OpenApiFunctionDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiFunctionDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenApiFunctionDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OpenApiFunctionDefinition DeserializeOpenApiFunctionDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string description = default; + BinaryData spec = default; + OpenApiAuthDetails auth = default; + IList defaultParams = default; + IReadOnlyList functions = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("spec"u8)) + { + spec = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("auth"u8)) + { + auth = OpenApiAuthDetails.DeserializeOpenApiAuthDetails(prop.Value, options); + continue; + } + if (prop.NameEquals("default_params"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + defaultParams = array; + continue; + } + if (prop.NameEquals("functions"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(OpenApiFunctionDefinitionFunction.DeserializeOpenApiFunctionDefinitionFunction(item, options)); + } + functions = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new OpenApiFunctionDefinition( + name, + description, + spec, + auth, + defaultParams ?? new ChangeTrackingList(), + functions ?? new ChangeTrackingList(), + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(OpenApiFunctionDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + OpenApiFunctionDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual OpenApiFunctionDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeOpenApiFunctionDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenApiFunctionDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinition.cs new file mode 100644 index 000000000000..dd6aea032031 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinition.cs @@ -0,0 +1,97 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The input definition information for an openapi function. + internal partial class OpenApiFunctionDefinition + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The name of the function to be called. + /// The openapi function shape, described as a JSON Schema object. + /// Open API authentication details. + /// , or is null. + public OpenApiFunctionDefinition(string name, BinaryData spec, OpenApiAuthDetails auth) + { + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(spec, nameof(spec)); + Argument.AssertNotNull(auth, nameof(auth)); + + Name = name; + Spec = spec; + Auth = auth; + DefaultParams = new ChangeTrackingList(); + Functions = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The name of the function to be called. + /// A description of what the function does, used by the model to choose when and how to call the function. + /// The openapi function shape, described as a JSON Schema object. + /// Open API authentication details. + /// List of OpenAPI spec parameters that will use user-provided defaults. + /// List of function definitions used by OpenApi tool. + /// Keeps track of any properties unknown to the library. + internal OpenApiFunctionDefinition(string name, string description, BinaryData spec, OpenApiAuthDetails auth, IList defaultParams, IReadOnlyList functions, IDictionary additionalBinaryDataProperties) + { + Name = name; + Description = description; + Spec = spec; + Auth = auth; + DefaultParams = defaultParams; + Functions = functions; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The name of the function to be called. + public string Name { get; set; } + + /// A description of what the function does, used by the model to choose when and how to call the function. + public string Description { get; set; } + + /// + /// The openapi function shape, described as a JSON Schema object. + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData Spec { get; set; } + + /// Open API authentication details. + public OpenApiAuthDetails Auth { get; set; } + + /// List of OpenAPI spec parameters that will use user-provided defaults. + public IList DefaultParams { get; } + + /// List of function definitions used by OpenApi tool. + public IReadOnlyList Functions { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinitionFunction.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinitionFunction.Serialization.cs new file mode 100644 index 000000000000..d8952874eff4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinitionFunction.Serialization.cs @@ -0,0 +1,165 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The OpenApiFunctionDefinitionFunction. + internal partial class OpenApiFunctionDefinitionFunction : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal OpenApiFunctionDefinitionFunction() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiFunctionDefinitionFunction)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("parameters"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Parameters); +#else + using (JsonDocument document = JsonDocument.Parse(Parameters)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + OpenApiFunctionDefinitionFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual OpenApiFunctionDefinitionFunction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiFunctionDefinitionFunction)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenApiFunctionDefinitionFunction(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OpenApiFunctionDefinitionFunction DeserializeOpenApiFunctionDefinitionFunction(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string description = default; + BinaryData parameters = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("parameters"u8)) + { + parameters = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new OpenApiFunctionDefinitionFunction(name, description, parameters, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(OpenApiFunctionDefinitionFunction)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + OpenApiFunctionDefinitionFunction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual OpenApiFunctionDefinitionFunction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeOpenApiFunctionDefinitionFunction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenApiFunctionDefinitionFunction)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinitionFunction.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinitionFunction.cs new file mode 100644 index 000000000000..c543df32a516 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinitionFunction.cs @@ -0,0 +1,73 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The OpenApiFunctionDefinitionFunction. + internal partial class OpenApiFunctionDefinitionFunction + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The name of the function to be called. + /// The parameters the functions accepts, described as a JSON Schema object. + internal OpenApiFunctionDefinitionFunction(string name, BinaryData parameters) + { + Name = name; + Parameters = parameters; + } + + /// Initializes a new instance of . + /// The name of the function to be called. + /// A description of what the function does, used by the model to choose when and how to call the function. + /// The parameters the functions accepts, described as a JSON Schema object. + /// Keeps track of any properties unknown to the library. + internal OpenApiFunctionDefinitionFunction(string name, string description, BinaryData parameters, IDictionary additionalBinaryDataProperties) + { + Name = name; + Description = description; + Parameters = parameters; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The name of the function to be called. + public string Name { get; } + + /// A description of what the function does, used by the model to choose when and how to call the function. + public string Description { get; } + + /// + /// The parameters the functions accepts, described as a JSON Schema object. + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData Parameters { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiManagedAuthDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiManagedAuthDetails.Serialization.cs new file mode 100644 index 000000000000..48dde65db186 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiManagedAuthDetails.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Security details for OpenApi managed_identity authentication. + internal partial class OpenApiManagedAuthDetails : OpenApiAuthDetails, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal OpenApiManagedAuthDetails() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiManagedAuthDetails)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("security_scheme"u8); + writer.WriteObjectValue(SecurityScheme, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + OpenApiManagedAuthDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (OpenApiManagedAuthDetails)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override OpenApiAuthDetails JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiManagedAuthDetails)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenApiManagedAuthDetails(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OpenApiManagedAuthDetails DeserializeOpenApiManagedAuthDetails(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenApiAuthType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + OpenApiManagedSecurityScheme securityScheme = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new OpenApiAuthType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("security_scheme"u8)) + { + securityScheme = OpenApiManagedSecurityScheme.DeserializeOpenApiManagedSecurityScheme(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new OpenApiManagedAuthDetails(@type, additionalBinaryDataProperties, securityScheme); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(OpenApiManagedAuthDetails)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + OpenApiManagedAuthDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (OpenApiManagedAuthDetails)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override OpenApiAuthDetails PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeOpenApiManagedAuthDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenApiManagedAuthDetails)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiManagedAuthDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiManagedAuthDetails.cs new file mode 100644 index 000000000000..bf20fbc1774d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiManagedAuthDetails.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Security details for OpenApi managed_identity authentication. + internal partial class OpenApiManagedAuthDetails : OpenApiAuthDetails + { + /// Initializes a new instance of . + /// Connection auth security details. + /// is null. + public OpenApiManagedAuthDetails(OpenApiManagedSecurityScheme securityScheme) : base(OpenApiAuthType.ManagedIdentity) + { + Argument.AssertNotNull(securityScheme, nameof(securityScheme)); + + SecurityScheme = securityScheme; + } + + /// Initializes a new instance of . + /// The type of authentication, must be anonymous/project_connection/managed_identity. + /// Keeps track of any properties unknown to the library. + /// Connection auth security details. + internal OpenApiManagedAuthDetails(OpenApiAuthType @type, IDictionary additionalBinaryDataProperties, OpenApiManagedSecurityScheme securityScheme) : base(@type, additionalBinaryDataProperties) + { + SecurityScheme = securityScheme; + } + + /// Connection auth security details. + public OpenApiManagedSecurityScheme SecurityScheme { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiManagedSecurityScheme.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiManagedSecurityScheme.Serialization.cs new file mode 100644 index 000000000000..08b423b1fc47 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiManagedSecurityScheme.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Security scheme for OpenApi managed_identity authentication. + internal partial class OpenApiManagedSecurityScheme : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal OpenApiManagedSecurityScheme() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiManagedSecurityScheme)} does not support writing '{format}' format."); + } + writer.WritePropertyName("audience"u8); + writer.WriteStringValue(Audience); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + OpenApiManagedSecurityScheme IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual OpenApiManagedSecurityScheme JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiManagedSecurityScheme)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenApiManagedSecurityScheme(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OpenApiManagedSecurityScheme DeserializeOpenApiManagedSecurityScheme(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string audience = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("audience"u8)) + { + audience = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new OpenApiManagedSecurityScheme(audience, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(OpenApiManagedSecurityScheme)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + OpenApiManagedSecurityScheme IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual OpenApiManagedSecurityScheme PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeOpenApiManagedSecurityScheme(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenApiManagedSecurityScheme)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiManagedSecurityScheme.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiManagedSecurityScheme.cs new file mode 100644 index 000000000000..7a2316217d44 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiManagedSecurityScheme.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Security scheme for OpenApi managed_identity authentication. + internal partial class OpenApiManagedSecurityScheme + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Authentication scope for managed_identity auth type. + /// is null. + public OpenApiManagedSecurityScheme(string audience) + { + Argument.AssertNotNull(audience, nameof(audience)); + + Audience = audience; + } + + /// Initializes a new instance of . + /// Authentication scope for managed_identity auth type. + /// Keeps track of any properties unknown to the library. + internal OpenApiManagedSecurityScheme(string audience, IDictionary additionalBinaryDataProperties) + { + Audience = audience; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Authentication scope for managed_identity auth type. + public string Audience { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiProjectConnectionAuthDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiProjectConnectionAuthDetails.Serialization.cs new file mode 100644 index 000000000000..d5bcef149ac3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiProjectConnectionAuthDetails.Serialization.cs @@ -0,0 +1,131 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Security details for OpenApi project connection authentication. + internal partial class OpenApiProjectConnectionAuthDetails : OpenApiAuthDetails, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal OpenApiProjectConnectionAuthDetails() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiProjectConnectionAuthDetails)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("security_scheme"u8); + writer.WriteObjectValue(SecurityScheme, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + OpenApiProjectConnectionAuthDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (OpenApiProjectConnectionAuthDetails)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override OpenApiAuthDetails JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiProjectConnectionAuthDetails)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenApiProjectConnectionAuthDetails(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OpenApiProjectConnectionAuthDetails DeserializeOpenApiProjectConnectionAuthDetails(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenApiAuthType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + OpenApiProjectConnectionSecurityScheme securityScheme = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new OpenApiAuthType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("security_scheme"u8)) + { + securityScheme = OpenApiProjectConnectionSecurityScheme.DeserializeOpenApiProjectConnectionSecurityScheme(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new OpenApiProjectConnectionAuthDetails(@type, additionalBinaryDataProperties, securityScheme); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(OpenApiProjectConnectionAuthDetails)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + OpenApiProjectConnectionAuthDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (OpenApiProjectConnectionAuthDetails)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override OpenApiAuthDetails PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeOpenApiProjectConnectionAuthDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenApiProjectConnectionAuthDetails)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiProjectConnectionAuthDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiProjectConnectionAuthDetails.cs new file mode 100644 index 000000000000..c36cea6d4eb0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiProjectConnectionAuthDetails.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Security details for OpenApi project connection authentication. + internal partial class OpenApiProjectConnectionAuthDetails : OpenApiAuthDetails + { + /// Initializes a new instance of . + /// Project connection auth security details. + /// is null. + public OpenApiProjectConnectionAuthDetails(OpenApiProjectConnectionSecurityScheme securityScheme) : base(OpenApiAuthType.ProjectConnection) + { + Argument.AssertNotNull(securityScheme, nameof(securityScheme)); + + SecurityScheme = securityScheme; + } + + /// Initializes a new instance of . + /// The type of authentication, must be anonymous/project_connection/managed_identity. + /// Keeps track of any properties unknown to the library. + /// Project connection auth security details. + internal OpenApiProjectConnectionAuthDetails(OpenApiAuthType @type, IDictionary additionalBinaryDataProperties, OpenApiProjectConnectionSecurityScheme securityScheme) : base(@type, additionalBinaryDataProperties) + { + SecurityScheme = securityScheme; + } + + /// Project connection auth security details. + public OpenApiProjectConnectionSecurityScheme SecurityScheme { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiProjectConnectionSecurityScheme.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiProjectConnectionSecurityScheme.Serialization.cs new file mode 100644 index 000000000000..1688789e2d69 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiProjectConnectionSecurityScheme.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Security scheme for OpenApi managed_identity authentication. + internal partial class OpenApiProjectConnectionSecurityScheme : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal OpenApiProjectConnectionSecurityScheme() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiProjectConnectionSecurityScheme)} does not support writing '{format}' format."); + } + writer.WritePropertyName("project_connection_id"u8); + writer.WriteStringValue(ProjectConnectionId); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + OpenApiProjectConnectionSecurityScheme IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual OpenApiProjectConnectionSecurityScheme JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiProjectConnectionSecurityScheme)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenApiProjectConnectionSecurityScheme(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static OpenApiProjectConnectionSecurityScheme DeserializeOpenApiProjectConnectionSecurityScheme(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string projectConnectionId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("project_connection_id"u8)) + { + projectConnectionId = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new OpenApiProjectConnectionSecurityScheme(projectConnectionId, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(OpenApiProjectConnectionSecurityScheme)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + OpenApiProjectConnectionSecurityScheme IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual OpenApiProjectConnectionSecurityScheme PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeOpenApiProjectConnectionSecurityScheme(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenApiProjectConnectionSecurityScheme)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiProjectConnectionSecurityScheme.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiProjectConnectionSecurityScheme.cs new file mode 100644 index 000000000000..d0b549b4029b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiProjectConnectionSecurityScheme.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Security scheme for OpenApi managed_identity authentication. + internal partial class OpenApiProjectConnectionSecurityScheme + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Project connection id for Project Connection auth type. + /// is null. + public OpenApiProjectConnectionSecurityScheme(string projectConnectionId) + { + Argument.AssertNotNull(projectConnectionId, nameof(projectConnectionId)); + + ProjectConnectionId = projectConnectionId; + } + + /// Initializes a new instance of . + /// Project connection id for Project Connection auth type. + /// Keeps track of any properties unknown to the library. + internal OpenApiProjectConnectionSecurityScheme(string projectConnectionId, IDictionary additionalBinaryDataProperties) + { + ProjectConnectionId = projectConnectionId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Project connection id for Project Connection auth type. + public string ProjectConnectionId { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OperationStatus.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OperationStatus.cs new file mode 100644 index 000000000000..0c2933f91a12 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OperationStatus.cs @@ -0,0 +1,83 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects; + +namespace Azure.Core.Foundations +{ + /// Enum describing allowed operation states. + public readonly partial struct OperationStatus : IEquatable + { + private readonly string _value; + /// The operation has not started. + private const string NotStartedValue = "NotStarted"; + /// The operation is in progress. + private const string RunningValue = "Running"; + /// The operation has completed successfully. + private const string SucceededValue = "Succeeded"; + /// The operation has failed. + private const string FailedValue = "Failed"; + /// The operation has been canceled by the user. + private const string CanceledValue = "Canceled"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public OperationStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// The operation has not started. + public static OperationStatus NotStarted { get; } = new OperationStatus(NotStartedValue); + + /// The operation is in progress. + public static OperationStatus Running { get; } = new OperationStatus(RunningValue); + + /// The operation has completed successfully. + public static OperationStatus Succeeded { get; } = new OperationStatus(SucceededValue); + + /// The operation has failed. + public static OperationStatus Failed { get; } = new OperationStatus(FailedValue); + + /// The operation has been canceled by the user. + public static OperationStatus Canceled { get; } = new OperationStatus(CanceledValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(OperationStatus left, OperationStatus right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(OperationStatus left, OperationStatus right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator OperationStatus(string value) => new OperationStatus(value); + + /// Converts a string to a . + /// The value. + public static implicit operator OperationStatus?(string value) => value == null ? null : new OperationStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OperationStatus other && Equals(other); + + /// + public bool Equals(OperationStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/PagedEvaluationRule.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/PagedEvaluationRule.Serialization.cs new file mode 100644 index 000000000000..4e804afb037f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/PagedEvaluationRule.Serialization.cs @@ -0,0 +1,175 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace Azure.Core.Foundations +{ + /// Paged collection of EvaluationRule items. + internal partial class PagedEvaluationRule : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal PagedEvaluationRule() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedEvaluationRule)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (EvaluationRule item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + PagedEvaluationRule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PagedEvaluationRule JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedEvaluationRule)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePagedEvaluationRule(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PagedEvaluationRule DeserializePagedEvaluationRule(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + string clientRequestId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(EvaluationRule.DeserializeEvaluationRule(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PagedEvaluationRule(value, nextLink, clientRequestId, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(PagedEvaluationRule)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + PagedEvaluationRule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PagedEvaluationRule PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializePagedEvaluationRule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PagedEvaluationRule)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator PagedEvaluationRule(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePagedEvaluationRule(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/PagedEvaluationRule.cs b/sdk/ai/Azure.AI.Projects/src/Generated/PagedEvaluationRule.cs new file mode 100644 index 000000000000..48752b6fad7a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/PagedEvaluationRule.cs @@ -0,0 +1,47 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects; + +namespace Azure.Core.Foundations +{ + /// Paged collection of EvaluationRule items. + internal partial class PagedEvaluationRule + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The EvaluationRule items on this page. + internal PagedEvaluationRule(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The EvaluationRule items on this page. + /// The link to the next page of items. + /// An opaque, globally-unique, client-generated string identifier for the request. + /// Keeps track of any properties unknown to the library. + internal PagedEvaluationRule(IList value, Uri nextLink, string clientRequestId, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + ClientRequestId = clientRequestId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The EvaluationRule items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + + /// An opaque, globally-unique, client-generated string identifier for the request. + public string ClientRequestId { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/PagedEvaluationTaxonomy.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/PagedEvaluationTaxonomy.Serialization.cs new file mode 100644 index 000000000000..7fd92d9f8da2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/PagedEvaluationTaxonomy.Serialization.cs @@ -0,0 +1,175 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace Azure.Core.Foundations +{ + /// Paged collection of EvaluationTaxonomy items. + internal partial class PagedEvaluationTaxonomy : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal PagedEvaluationTaxonomy() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedEvaluationTaxonomy)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (EvaluationTaxonomy item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + PagedEvaluationTaxonomy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PagedEvaluationTaxonomy JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedEvaluationTaxonomy)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePagedEvaluationTaxonomy(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PagedEvaluationTaxonomy DeserializePagedEvaluationTaxonomy(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + string clientRequestId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(EvaluationTaxonomy.DeserializeEvaluationTaxonomy(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PagedEvaluationTaxonomy(value, nextLink, clientRequestId, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(PagedEvaluationTaxonomy)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + PagedEvaluationTaxonomy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PagedEvaluationTaxonomy PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializePagedEvaluationTaxonomy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PagedEvaluationTaxonomy)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator PagedEvaluationTaxonomy(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePagedEvaluationTaxonomy(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/PagedEvaluationTaxonomy.cs b/sdk/ai/Azure.AI.Projects/src/Generated/PagedEvaluationTaxonomy.cs new file mode 100644 index 000000000000..f94911977c0e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/PagedEvaluationTaxonomy.cs @@ -0,0 +1,47 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects; + +namespace Azure.Core.Foundations +{ + /// Paged collection of EvaluationTaxonomy items. + internal partial class PagedEvaluationTaxonomy + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The EvaluationTaxonomy items on this page. + internal PagedEvaluationTaxonomy(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The EvaluationTaxonomy items on this page. + /// The link to the next page of items. + /// An opaque, globally-unique, client-generated string identifier for the request. + /// Keeps track of any properties unknown to the library. + internal PagedEvaluationTaxonomy(IList value, Uri nextLink, string clientRequestId, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + ClientRequestId = clientRequestId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The EvaluationTaxonomy items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + + /// An opaque, globally-unique, client-generated string identifier for the request. + public string ClientRequestId { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/PagedEvaluatorVersion.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/PagedEvaluatorVersion.Serialization.cs new file mode 100644 index 000000000000..d3d8a6795661 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/PagedEvaluatorVersion.Serialization.cs @@ -0,0 +1,174 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace Azure.Core +{ + /// Paged collection of EvaluatorVersion items. + internal partial class PagedEvaluatorVersion : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal PagedEvaluatorVersion() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedEvaluatorVersion)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (EvaluatorVersion item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + PagedEvaluatorVersion IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PagedEvaluatorVersion JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedEvaluatorVersion)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePagedEvaluatorVersion(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PagedEvaluatorVersion DeserializePagedEvaluatorVersion(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(EvaluatorVersion.DeserializeEvaluatorVersion(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PagedEvaluatorVersion(value, nextLink, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(PagedEvaluatorVersion)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + PagedEvaluatorVersion IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PagedEvaluatorVersion PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializePagedEvaluatorVersion(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PagedEvaluatorVersion)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator PagedEvaluatorVersion(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePagedEvaluatorVersion(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/PagedEvaluatorVersion.cs b/sdk/ai/Azure.AI.Projects/src/Generated/PagedEvaluatorVersion.cs new file mode 100644 index 000000000000..a9d89fe21b1e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/PagedEvaluatorVersion.cs @@ -0,0 +1,42 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects; + +namespace Azure.Core +{ + /// Paged collection of EvaluatorVersion items. + internal partial class PagedEvaluatorVersion + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The EvaluatorVersion items on this page. + internal PagedEvaluatorVersion(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The EvaluatorVersion items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal PagedEvaluatorVersion(IList value, Uri nextLink, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The EvaluatorVersion items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/PagedInsight.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/PagedInsight.Serialization.cs new file mode 100644 index 000000000000..67fb688caa51 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/PagedInsight.Serialization.cs @@ -0,0 +1,175 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace Azure.Core.Foundations +{ + /// Paged collection of Insight items. + internal partial class PagedInsight : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal PagedInsight() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedInsight)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (Insight item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + PagedInsight IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PagedInsight JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedInsight)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePagedInsight(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PagedInsight DeserializePagedInsight(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + string clientRequestId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(Insight.DeserializeInsight(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PagedInsight(value, nextLink, clientRequestId, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(PagedInsight)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + PagedInsight IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PagedInsight PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializePagedInsight(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PagedInsight)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator PagedInsight(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePagedInsight(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/PagedInsight.cs b/sdk/ai/Azure.AI.Projects/src/Generated/PagedInsight.cs new file mode 100644 index 000000000000..4fa97febcf36 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/PagedInsight.cs @@ -0,0 +1,47 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects; + +namespace Azure.Core.Foundations +{ + /// Paged collection of Insight items. + internal partial class PagedInsight + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The Insight items on this page. + internal PagedInsight(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The Insight items on this page. + /// The link to the next page of items. + /// An opaque, globally-unique, client-generated string identifier for the request. + /// Keeps track of any properties unknown to the library. + internal PagedInsight(IList value, Uri nextLink, string clientRequestId, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + ClientRequestId = clientRequestId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The Insight items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + + /// An opaque, globally-unique, client-generated string identifier for the request. + public string ClientRequestId { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/PagedRedTeam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/PagedRedTeam.Serialization.cs new file mode 100644 index 000000000000..cbcd786a8a67 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/PagedRedTeam.Serialization.cs @@ -0,0 +1,175 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace Azure.Core.Foundations +{ + /// Paged collection of RedTeam items. + internal partial class PagedRedTeam : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal PagedRedTeam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedRedTeam)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (RedTeam item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + PagedRedTeam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PagedRedTeam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedRedTeam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePagedRedTeam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PagedRedTeam DeserializePagedRedTeam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + string clientRequestId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(RedTeam.DeserializeRedTeam(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PagedRedTeam(value, nextLink, clientRequestId, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(PagedRedTeam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + PagedRedTeam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PagedRedTeam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializePagedRedTeam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PagedRedTeam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator PagedRedTeam(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePagedRedTeam(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/PagedRedTeam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/PagedRedTeam.cs new file mode 100644 index 000000000000..c98061f6aabf --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/PagedRedTeam.cs @@ -0,0 +1,47 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects; + +namespace Azure.Core.Foundations +{ + /// Paged collection of RedTeam items. + internal partial class PagedRedTeam + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The RedTeam items on this page. + internal PagedRedTeam(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The RedTeam items on this page. + /// The link to the next page of items. + /// An opaque, globally-unique, client-generated string identifier for the request. + /// Keeps track of any properties unknown to the library. + internal PagedRedTeam(IList value, Uri nextLink, string clientRequestId, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + ClientRequestId = clientRequestId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The RedTeam items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + + /// An opaque, globally-unique, client-generated string identifier for the request. + public string ClientRequestId { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/PagedSchedule.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/PagedSchedule.Serialization.cs new file mode 100644 index 000000000000..a52a61f684f8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/PagedSchedule.Serialization.cs @@ -0,0 +1,175 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace Azure.Core.Foundations +{ + /// Paged collection of Schedule items. + internal partial class PagedSchedule : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal PagedSchedule() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedSchedule)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (Schedule item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + PagedSchedule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PagedSchedule JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedSchedule)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePagedSchedule(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PagedSchedule DeserializePagedSchedule(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + string clientRequestId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(Schedule.DeserializeSchedule(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PagedSchedule(value, nextLink, clientRequestId, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(PagedSchedule)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + PagedSchedule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PagedSchedule PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializePagedSchedule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PagedSchedule)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator PagedSchedule(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePagedSchedule(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/PagedSchedule.cs b/sdk/ai/Azure.AI.Projects/src/Generated/PagedSchedule.cs new file mode 100644 index 000000000000..45031e0121a6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/PagedSchedule.cs @@ -0,0 +1,47 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects; + +namespace Azure.Core.Foundations +{ + /// Paged collection of Schedule items. + internal partial class PagedSchedule + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The Schedule items on this page. + internal PagedSchedule(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The Schedule items on this page. + /// The link to the next page of items. + /// An opaque, globally-unique, client-generated string identifier for the request. + /// Keeps track of any properties unknown to the library. + internal PagedSchedule(IList value, Uri nextLink, string clientRequestId, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + ClientRequestId = clientRequestId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The Schedule items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + + /// An opaque, globally-unique, client-generated string identifier for the request. + public string ClientRequestId { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/PagedScheduleRun.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/PagedScheduleRun.Serialization.cs new file mode 100644 index 000000000000..7ab483099a91 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/PagedScheduleRun.Serialization.cs @@ -0,0 +1,175 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace Azure.Core.Foundations +{ + /// Paged collection of ScheduleRun items. + internal partial class PagedScheduleRun : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal PagedScheduleRun() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedScheduleRun)} does not support writing '{format}' format."); + } + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (ScheduleRun item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + PagedScheduleRun IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PagedScheduleRun JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PagedScheduleRun)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePagedScheduleRun(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PagedScheduleRun DeserializePagedScheduleRun(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList value = default; + Uri nextLink = default; + string clientRequestId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ScheduleRun.DeserializeScheduleRun(item, options)); + } + value = array; + continue; + } + if (prop.NameEquals("nextLink"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PagedScheduleRun(value, nextLink, clientRequestId, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(PagedScheduleRun)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + PagedScheduleRun IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PagedScheduleRun PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializePagedScheduleRun(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PagedScheduleRun)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator PagedScheduleRun(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePagedScheduleRun(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/PagedScheduleRun.cs b/sdk/ai/Azure.AI.Projects/src/Generated/PagedScheduleRun.cs new file mode 100644 index 000000000000..6be22a6d7d20 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/PagedScheduleRun.cs @@ -0,0 +1,47 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.AI.Projects; + +namespace Azure.Core.Foundations +{ + /// Paged collection of ScheduleRun items. + internal partial class PagedScheduleRun + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The ScheduleRun items on this page. + internal PagedScheduleRun(IEnumerable value) + { + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The ScheduleRun items on this page. + /// The link to the next page of items. + /// An opaque, globally-unique, client-generated string identifier for the request. + /// Keeps track of any properties unknown to the library. + internal PagedScheduleRun(IList value, Uri nextLink, string clientRequestId, IDictionary additionalBinaryDataProperties) + { + Value = value; + NextLink = nextLink; + ClientRequestId = clientRequestId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The ScheduleRun items on this page. + public IList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } + + /// An opaque, globally-unique, client-generated string identifier for the request. + public string ClientRequestId { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/PromptAgentDefinitionText.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/PromptAgentDefinitionText.Serialization.cs new file mode 100644 index 000000000000..2a3b1f68509a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/PromptAgentDefinitionText.Serialization.cs @@ -0,0 +1,142 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// The PromptAgentDefinitionText. + internal partial class PromptAgentDefinitionText : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PromptAgentDefinitionText)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Format)) + { + writer.WritePropertyName("format"u8); + writer.WriteObjectValue(Format, options); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + PromptAgentDefinitionText IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual PromptAgentDefinitionText JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PromptAgentDefinitionText)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePromptAgentDefinitionText(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PromptAgentDefinitionText DeserializePromptAgentDefinitionText(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalResponseTextFormatConfiguration format = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("format"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + format = InternalResponseTextFormatConfiguration.DeserializeInternalResponseTextFormatConfiguration(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PromptAgentDefinitionText(format, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(PromptAgentDefinitionText)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + PromptAgentDefinitionText IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual PromptAgentDefinitionText PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializePromptAgentDefinitionText(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PromptAgentDefinitionText)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/PromptAgentDefinitionText.cs b/sdk/ai/Azure.AI.Projects/src/Generated/PromptAgentDefinitionText.cs new file mode 100644 index 000000000000..dda04efcd740 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/PromptAgentDefinitionText.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// The PromptAgentDefinitionText. + internal partial class PromptAgentDefinitionText + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public PromptAgentDefinitionText() + { + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal PromptAgentDefinitionText(InternalResponseTextFormatConfiguration format, IDictionary additionalBinaryDataProperties) + { + Format = format; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets or sets the Format. + public InternalResponseTextFormatConfiguration Format { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/PromptBasedEvaluatorDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/PromptBasedEvaluatorDefinition.Serialization.cs new file mode 100644 index 000000000000..30083198b997 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/PromptBasedEvaluatorDefinition.Serialization.cs @@ -0,0 +1,172 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Prompt-based evaluator. + public partial class PromptBasedEvaluatorDefinition : EvaluatorDefinition, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal PromptBasedEvaluatorDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PromptBasedEvaluatorDefinition)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("prompt_text"u8); + writer.WriteStringValue(PromptText); + } + + /// The JSON reader. + /// The client options for reading and writing models. + PromptBasedEvaluatorDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (PromptBasedEvaluatorDefinition)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override EvaluatorDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PromptBasedEvaluatorDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePromptBasedEvaluatorDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static PromptBasedEvaluatorDefinition DeserializePromptBasedEvaluatorDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + EvaluatorDefinitionType @type = default; + BinaryData initParameters = default; + BinaryData dataSchema = default; + IDictionary metrics = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string promptText = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new EvaluatorDefinitionType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("init_parameters"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + initParameters = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("data_schema"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dataSchema = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("metrics"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + dictionary.Add(prop0.Name, EvaluatorMetric.DeserializeEvaluatorMetric(prop0.Value, options)); + } + metrics = dictionary; + continue; + } + if (prop.NameEquals("prompt_text"u8)) + { + promptText = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PromptBasedEvaluatorDefinition( + @type, + initParameters, + dataSchema, + metrics ?? new ChangeTrackingDictionary(), + additionalBinaryDataProperties, + promptText); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(PromptBasedEvaluatorDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + PromptBasedEvaluatorDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (PromptBasedEvaluatorDefinition)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override EvaluatorDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializePromptBasedEvaluatorDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PromptBasedEvaluatorDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/PromptBasedEvaluatorDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/PromptBasedEvaluatorDefinition.cs new file mode 100644 index 000000000000..b63177cc7512 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/PromptBasedEvaluatorDefinition.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Prompt-based evaluator. + public partial class PromptBasedEvaluatorDefinition : EvaluatorDefinition + { + /// Initializes a new instance of . + /// The prompt text used for evaluation. + /// is null. + public PromptBasedEvaluatorDefinition(string promptText) : base(EvaluatorDefinitionType.Prompt) + { + Argument.AssertNotNull(promptText, nameof(promptText)); + + PromptText = promptText; + } + + /// Initializes a new instance of . + /// The type of evaluator definition. + /// The JSON schema (Draft 2020-12) for the evaluator's input parameters. This includes parameters like type, properties, required. + /// The JSON schema (Draft 2020-12) for the evaluator's input data. This includes parameters like type, properties, required. + /// List of output metrics produced by this evaluator. + /// Keeps track of any properties unknown to the library. + /// The prompt text used for evaluation. + internal PromptBasedEvaluatorDefinition(EvaluatorDefinitionType @type, BinaryData initParameters, BinaryData dataSchema, IDictionary metrics, IDictionary additionalBinaryDataProperties, string promptText) : base(@type, initParameters, dataSchema, metrics, additionalBinaryDataProperties) + { + PromptText = promptText; + } + + /// The prompt text used for evaluation. + public string PromptText { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ProtocolVersionRecord.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ProtocolVersionRecord.Serialization.cs new file mode 100644 index 000000000000..f4a4e40e6f98 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ProtocolVersionRecord.Serialization.cs @@ -0,0 +1,147 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// A record mapping for a single protocol and its version. + internal partial class ProtocolVersionRecord : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ProtocolVersionRecord() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProtocolVersionRecord)} does not support writing '{format}' format."); + } + writer.WritePropertyName("protocol"u8); + writer.WriteStringValue(Protocol.ToString()); + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ProtocolVersionRecord IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ProtocolVersionRecord JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProtocolVersionRecord)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProtocolVersionRecord(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ProtocolVersionRecord DeserializeProtocolVersionRecord(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InternalAgentProtocol protocol = default; + string version = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("protocol"u8)) + { + protocol = new InternalAgentProtocol(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("version"u8)) + { + version = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ProtocolVersionRecord(protocol, version, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(ProtocolVersionRecord)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ProtocolVersionRecord IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ProtocolVersionRecord PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeProtocolVersionRecord(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProtocolVersionRecord)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ProtocolVersionRecord.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ProtocolVersionRecord.cs new file mode 100644 index 000000000000..de5e0b4fe5aa --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ProtocolVersionRecord.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// A record mapping for a single protocol and its version. + internal partial class ProtocolVersionRecord + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The protocol type. + /// The version string for the protocol, e.g. 'v0.1.1'. + /// is null. + public ProtocolVersionRecord(InternalAgentProtocol protocol, string version) + { + Argument.AssertNotNull(version, nameof(version)); + + Protocol = protocol; + Version = version; + } + + /// Initializes a new instance of . + /// The protocol type. + /// The version string for the protocol, e.g. 'v0.1.1'. + /// Keeps track of any properties unknown to the library. + internal ProtocolVersionRecord(InternalAgentProtocol protocol, string version, IDictionary additionalBinaryDataProperties) + { + Protocol = protocol; + Version = version; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The protocol type. + public InternalAgentProtocol Protocol { get; set; } + + /// The version string for the protocol, e.g. 'v0.1.1'. + public string Version { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RaiConfig.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RaiConfig.Serialization.cs new file mode 100644 index 000000000000..2bdad501c90d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/RaiConfig.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Configuration for Responsible AI (RAI) content filtering and safety features. + internal partial class RaiConfig : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal RaiConfig() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RaiConfig)} does not support writing '{format}' format."); + } + writer.WritePropertyName("rai_policy_name"u8); + writer.WriteStringValue(RaiPolicyName); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + RaiConfig IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual RaiConfig JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RaiConfig)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRaiConfig(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static RaiConfig DeserializeRaiConfig(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string raiPolicyName = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("rai_policy_name"u8)) + { + raiPolicyName = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new RaiConfig(raiPolicyName, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(RaiConfig)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + RaiConfig IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual RaiConfig PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeRaiConfig(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RaiConfig)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RaiConfig.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RaiConfig.cs new file mode 100644 index 000000000000..d295f34242d7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/RaiConfig.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Configuration for Responsible AI (RAI) content filtering and safety features. + internal partial class RaiConfig + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The name of the RAI policy to apply. + /// is null. + public RaiConfig(string raiPolicyName) + { + Argument.AssertNotNull(raiPolicyName, nameof(raiPolicyName)); + + RaiPolicyName = raiPolicyName; + } + + /// Initializes a new instance of . + /// The name of the RAI policy to apply. + /// Keeps track of any properties unknown to the library. + internal RaiConfig(string raiPolicyName, IDictionary additionalBinaryDataProperties) + { + RaiPolicyName = raiPolicyName; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The name of the RAI policy to apply. + public string RaiPolicyName { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RankingOptionsRanker.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RankingOptionsRanker.cs new file mode 100644 index 000000000000..81b8cb64deee --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/RankingOptionsRanker.cs @@ -0,0 +1,65 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal readonly partial struct RankingOptionsRanker : IEquatable + { + private readonly string _value; + private const string AutoValue = "auto"; + private const string Default20241115Value = "default-2024-11-15"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public RankingOptionsRanker(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Auto. + public static RankingOptionsRanker Auto { get; } = new RankingOptionsRanker(AutoValue); + + /// Gets the Default20241115. + public static RankingOptionsRanker Default20241115 { get; } = new RankingOptionsRanker(Default20241115Value); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(RankingOptionsRanker left, RankingOptionsRanker right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(RankingOptionsRanker left, RankingOptionsRanker right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator RankingOptionsRanker(string value) => new RankingOptionsRanker(value); + + /// Converts a string to a . + /// The value. + public static implicit operator RankingOptionsRanker?(string value) => value == null ? null : new RankingOptionsRanker(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RankingOptionsRanker other && Equals(other); + + /// + public bool Equals(RankingOptionsRanker other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ReasoningEffort.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ReasoningEffort.cs new file mode 100644 index 000000000000..a486f37ede16 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ReasoningEffort.cs @@ -0,0 +1,69 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal readonly partial struct ReasoningEffort : IEquatable + { + private readonly string _value; + private const string LowValue = "low"; + private const string MediumValue = "medium"; + private const string HighValue = "high"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ReasoningEffort(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Low. + public static ReasoningEffort Low { get; } = new ReasoningEffort(LowValue); + + /// Gets the Medium. + public static ReasoningEffort Medium { get; } = new ReasoningEffort(MediumValue); + + /// Gets the High. + public static ReasoningEffort High { get; } = new ReasoningEffort(HighValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ReasoningEffort left, ReasoningEffort right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ReasoningEffort left, ReasoningEffort right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ReasoningEffort(string value) => new ReasoningEffort(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ReasoningEffort?(string value) => value == null ? null : new ReasoningEffort(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ReasoningEffort other && Equals(other); + + /// + public bool Equals(ReasoningEffort other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ReasoningGenerateSummary.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ReasoningGenerateSummary.cs new file mode 100644 index 000000000000..ffec7036546d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ReasoningGenerateSummary.cs @@ -0,0 +1,69 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal readonly partial struct ReasoningGenerateSummary : IEquatable + { + private readonly string _value; + private const string AutoValue = "auto"; + private const string ConciseValue = "concise"; + private const string DetailedValue = "detailed"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ReasoningGenerateSummary(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Auto. + public static ReasoningGenerateSummary Auto { get; } = new ReasoningGenerateSummary(AutoValue); + + /// Gets the Concise. + public static ReasoningGenerateSummary Concise { get; } = new ReasoningGenerateSummary(ConciseValue); + + /// Gets the Detailed. + public static ReasoningGenerateSummary Detailed { get; } = new ReasoningGenerateSummary(DetailedValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ReasoningGenerateSummary left, ReasoningGenerateSummary right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ReasoningGenerateSummary left, ReasoningGenerateSummary right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ReasoningGenerateSummary(string value) => new ReasoningGenerateSummary(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ReasoningGenerateSummary?(string value) => value == null ? null : new ReasoningGenerateSummary(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ReasoningGenerateSummary other && Equals(other); + + /// + public bool Equals(ReasoningGenerateSummary other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ReasoningItemSummaryPartType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ReasoningItemSummaryPartType.cs new file mode 100644 index 000000000000..92ea00e21c6b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ReasoningItemSummaryPartType.cs @@ -0,0 +1,62 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects; + +namespace OpenAI +{ + /// + internal readonly partial struct ReasoningItemSummaryPartType : IEquatable + { + private readonly string _value; + private const string SummaryTextValue = "summary_text"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ReasoningItemSummaryPartType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the SummaryText. + public static ReasoningItemSummaryPartType SummaryText { get; } = new ReasoningItemSummaryPartType(SummaryTextValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ReasoningItemSummaryPartType left, ReasoningItemSummaryPartType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ReasoningItemSummaryPartType left, ReasoningItemSummaryPartType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ReasoningItemSummaryPartType(string value) => new ReasoningItemSummaryPartType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ReasoningItemSummaryPartType?(string value) => value == null ? null : new ReasoningItemSummaryPartType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ReasoningItemSummaryPartType other && Equals(other); + + /// + public bool Equals(ReasoningItemSummaryPartType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ReasoningSummary.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ReasoningSummary.cs new file mode 100644 index 000000000000..84977371845a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ReasoningSummary.cs @@ -0,0 +1,69 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal readonly partial struct ReasoningSummary : IEquatable + { + private readonly string _value; + private const string AutoValue = "auto"; + private const string ConciseValue = "concise"; + private const string DetailedValue = "detailed"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ReasoningSummary(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Auto. + public static ReasoningSummary Auto { get; } = new ReasoningSummary(AutoValue); + + /// Gets the Concise. + public static ReasoningSummary Concise { get; } = new ReasoningSummary(ConciseValue); + + /// Gets the Detailed. + public static ReasoningSummary Detailed { get; } = new ReasoningSummary(DetailedValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ReasoningSummary left, ReasoningSummary right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ReasoningSummary left, ReasoningSummary right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ReasoningSummary(string value) => new ReasoningSummary(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ReasoningSummary?(string value) => value == null ? null : new ReasoningSummary(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ReasoningSummary other && Equals(other); + + /// + public bool Equals(ReasoningSummary other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceSchedule.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceSchedule.Serialization.cs new file mode 100644 index 000000000000..9cf170e5eac3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceSchedule.Serialization.cs @@ -0,0 +1,142 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// + /// Recurrence schedule model. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , and . + /// + [PersistableModelProxy(typeof(UnknownRecurrenceSchedule))] + public abstract partial class RecurrenceSchedule : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal RecurrenceSchedule() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RecurrenceSchedule)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + RecurrenceSchedule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual RecurrenceSchedule JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RecurrenceSchedule)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRecurrenceSchedule(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static RecurrenceSchedule DeserializeRecurrenceSchedule(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "Hourly": + return HourlyRecurrenceSchedule.DeserializeHourlyRecurrenceSchedule(element, options); + case "Daily": + return DailyRecurrenceSchedule.DeserializeDailyRecurrenceSchedule(element, options); + case "Weekly": + return WeeklyRecurrenceSchedule.DeserializeWeeklyRecurrenceSchedule(element, options); + case "Monthly": + return MonthlyRecurrenceSchedule.DeserializeMonthlyRecurrenceSchedule(element, options); + } + } + return UnknownRecurrenceSchedule.DeserializeUnknownRecurrenceSchedule(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(RecurrenceSchedule)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + RecurrenceSchedule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual RecurrenceSchedule PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeRecurrenceSchedule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RecurrenceSchedule)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceSchedule.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceSchedule.cs new file mode 100644 index 000000000000..562d41edb30d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceSchedule.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// + /// Recurrence schedule model. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , , and . + /// + public abstract partial class RecurrenceSchedule + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Recurrence type for the recurrence schedule. + private protected RecurrenceSchedule(RecurrenceType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// Recurrence type for the recurrence schedule. + /// Keeps track of any properties unknown to the library. + internal RecurrenceSchedule(RecurrenceType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Recurrence type for the recurrence schedule. + internal RecurrenceType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceTrigger.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceTrigger.Serialization.cs new file mode 100644 index 000000000000..8dac62697d8c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceTrigger.Serialization.cs @@ -0,0 +1,179 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Recurrence based trigger. + public partial class RecurrenceTrigger : Trigger, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal RecurrenceTrigger() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RecurrenceTrigger)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(StartTime)) + { + writer.WritePropertyName("startTime"u8); + writer.WriteStringValue(StartTime); + } + if (Optional.IsDefined(EndTime)) + { + writer.WritePropertyName("endTime"u8); + writer.WriteStringValue(EndTime); + } + if (Optional.IsDefined(TimeZone)) + { + writer.WritePropertyName("timeZone"u8); + writer.WriteStringValue(TimeZone); + } + writer.WritePropertyName("interval"u8); + writer.WriteNumberValue(Interval); + writer.WritePropertyName("schedule"u8); + writer.WriteObjectValue(Schedule, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + RecurrenceTrigger IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (RecurrenceTrigger)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override Trigger JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RecurrenceTrigger)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRecurrenceTrigger(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static RecurrenceTrigger DeserializeRecurrenceTrigger(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TriggerType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string startTime = default; + string endTime = default; + string timeZone = default; + int interval = default; + RecurrenceSchedule schedule = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new TriggerType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("startTime"u8)) + { + startTime = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("endTime"u8)) + { + endTime = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("timeZone"u8)) + { + timeZone = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("interval"u8)) + { + interval = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("schedule"u8)) + { + schedule = RecurrenceSchedule.DeserializeRecurrenceSchedule(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new RecurrenceTrigger( + @type, + additionalBinaryDataProperties, + startTime, + endTime, + timeZone, + interval, + schedule); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(RecurrenceTrigger)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + RecurrenceTrigger IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (RecurrenceTrigger)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override Trigger PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeRecurrenceTrigger(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RecurrenceTrigger)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceTrigger.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceTrigger.cs new file mode 100644 index 000000000000..36be51b4b8bc --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceTrigger.cs @@ -0,0 +1,57 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Recurrence based trigger. + public partial class RecurrenceTrigger : Trigger + { + /// Initializes a new instance of . + /// Interval for the recurrence schedule. + /// Recurrence schedule for the recurrence trigger. + /// is null. + public RecurrenceTrigger(int interval, RecurrenceSchedule schedule) : base(TriggerType.Recurrence) + { + Argument.AssertNotNull(schedule, nameof(schedule)); + + Interval = interval; + Schedule = schedule; + } + + /// Initializes a new instance of . + /// Type of the trigger. + /// Keeps track of any properties unknown to the library. + /// Start time for the recurrence schedule in ISO 8601 format. + /// End time for the recurrence schedule in ISO 8601 format. + /// Time zone for the recurrence schedule. + /// Interval for the recurrence schedule. + /// Recurrence schedule for the recurrence trigger. + internal RecurrenceTrigger(TriggerType @type, IDictionary additionalBinaryDataProperties, string startTime, string endTime, string timeZone, int interval, RecurrenceSchedule schedule) : base(@type, additionalBinaryDataProperties) + { + StartTime = startTime; + EndTime = endTime; + TimeZone = timeZone; + Interval = interval; + Schedule = schedule; + } + + /// Start time for the recurrence schedule in ISO 8601 format. + public string StartTime { get; set; } + + /// End time for the recurrence schedule in ISO 8601 format. + public string EndTime { get; set; } + + /// Time zone for the recurrence schedule. + public string TimeZone { get; set; } + + /// Interval for the recurrence schedule. + public int Interval { get; set; } + + /// Recurrence schedule for the recurrence trigger. + public RecurrenceSchedule Schedule { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceType.cs new file mode 100644 index 000000000000..3eefdfc27dfc --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/RecurrenceType.cs @@ -0,0 +1,77 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// Recurrence type. + internal readonly partial struct RecurrenceType : IEquatable + { + private readonly string _value; + /// Hourly recurrence pattern. + private const string HourlyValue = "Hourly"; + /// Daily recurrence pattern. + private const string DailyValue = "Daily"; + /// Weekly recurrence pattern. + private const string WeeklyValue = "Weekly"; + /// Monthly recurrence pattern. + private const string MonthlyValue = "Monthly"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public RecurrenceType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Hourly recurrence pattern. + public static RecurrenceType Hourly { get; } = new RecurrenceType(HourlyValue); + + /// Daily recurrence pattern. + public static RecurrenceType Daily { get; } = new RecurrenceType(DailyValue); + + /// Weekly recurrence pattern. + public static RecurrenceType Weekly { get; } = new RecurrenceType(WeeklyValue); + + /// Monthly recurrence pattern. + public static RecurrenceType Monthly { get; } = new RecurrenceType(MonthlyValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(RecurrenceType left, RecurrenceType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(RecurrenceType left, RecurrenceType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator RecurrenceType(string value) => new RecurrenceType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator RecurrenceType?(string value) => value == null ? null : new RecurrenceType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RecurrenceType other && Equals(other); + + /// + public bool Equals(RecurrenceType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RedTeam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RedTeam.Serialization.cs new file mode 100644 index 000000000000..8aaa330e4262 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/RedTeam.Serialization.cs @@ -0,0 +1,370 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Red team details. + public partial class RedTeam : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal RedTeam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RedTeam)} does not support writing '{format}' format."); + } + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (Optional.IsDefined(NumTurns)) + { + writer.WritePropertyName("numTurns"u8); + writer.WriteNumberValue(NumTurns.Value); + } + if (Optional.IsCollectionDefined(AttackStrategies)) + { + writer.WritePropertyName("attackStrategies"u8); + writer.WriteStartArray(); + foreach (AttackStrategy item in AttackStrategies) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(SimulationOnly)) + { + writer.WritePropertyName("simulationOnly"u8); + writer.WriteBooleanValue(SimulationOnly.Value); + } + if (Optional.IsCollectionDefined(RiskCategories)) + { + writer.WritePropertyName("riskCategories"u8); + writer.WriteStartArray(); + foreach (RiskCategory item in RiskCategories) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(ApplicationScenario)) + { + writer.WritePropertyName("applicationScenario"u8); + writer.WriteStringValue(ApplicationScenario); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsCollectionDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + foreach (var item in Properties) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status); + } + writer.WritePropertyName("target"u8); + writer.WriteObjectValue(Target, options); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + RedTeam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual RedTeam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RedTeam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRedTeam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static RedTeam DeserializeRedTeam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string displayName = default; + int? numTurns = default; + IList attackStrategies = default; + bool? simulationOnly = default; + IList riskCategories = default; + string applicationScenario = default; + IDictionary tags = default; + IDictionary properties = default; + string status = default; + TargetConfig target = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("displayName"u8)) + { + displayName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("numTurns"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + numTurns = prop.Value.GetInt32(); + continue; + } + if (prop.NameEquals("attackStrategies"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(new AttackStrategy(item.GetString())); + } + attackStrategies = array; + continue; + } + if (prop.NameEquals("simulationOnly"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + simulationOnly = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("riskCategories"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(new RiskCategory(item.GetString())); + } + riskCategories = array; + continue; + } + if (prop.NameEquals("applicationScenario"u8)) + { + applicationScenario = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("tags"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + tags = dictionary; + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + properties = dictionary; + continue; + } + if (prop.NameEquals("status"u8)) + { + status = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("target"u8)) + { + target = TargetConfig.DeserializeTargetConfig(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new RedTeam( + name, + displayName, + numTurns, + attackStrategies ?? new ChangeTrackingList(), + simulationOnly, + riskCategories ?? new ChangeTrackingList(), + applicationScenario, + tags ?? new ChangeTrackingDictionary(), + properties ?? new ChangeTrackingDictionary(), + status, + target, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(RedTeam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + RedTeam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual RedTeam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeRedTeam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RedTeam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(RedTeam redTeam) + { + if (redTeam == null) + { + return null; + } + return BinaryContent.Create(redTeam, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + public static explicit operator RedTeam(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRedTeam(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RedTeam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RedTeam.cs new file mode 100644 index 000000000000..a62def40f0cb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/RedTeam.cs @@ -0,0 +1,92 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Red team details. + public partial class RedTeam + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Target configuration for the red-team run. + /// is null. + public RedTeam(TargetConfig target) + { + Argument.AssertNotNull(target, nameof(target)); + + AttackStrategies = new ChangeTrackingList(); + RiskCategories = new ChangeTrackingList(); + Tags = new ChangeTrackingDictionary(); + Properties = new ChangeTrackingDictionary(); + Target = target; + } + + /// Initializes a new instance of . + /// Identifier of the red team run. + /// Name of the red-team run. + /// Number of simulation rounds. + /// List of attack strategies or nested lists of attack strategies. + /// Simulation-only or Simulation + Evaluation. Default false, if true the scan outputs conversation not evaluation result. + /// List of risk categories to generate attack objectives for. + /// Application scenario for the red team operation, to generate scenario specific attacks. + /// Red team's tags. Unlike properties, tags are fully mutable. + /// Red team's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. + /// Status of the red-team. It is set by service and is read-only. + /// Target configuration for the red-team run. + /// Keeps track of any properties unknown to the library. + internal RedTeam(string name, string displayName, int? numTurns, IList attackStrategies, bool? simulationOnly, IList riskCategories, string applicationScenario, IDictionary tags, IDictionary properties, string status, TargetConfig target, IDictionary additionalBinaryDataProperties) + { + Name = name; + DisplayName = displayName; + NumTurns = numTurns; + AttackStrategies = attackStrategies; + SimulationOnly = simulationOnly; + RiskCategories = riskCategories; + ApplicationScenario = applicationScenario; + Tags = tags; + Properties = properties; + Status = status; + Target = target; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Identifier of the red team run. + public string Name { get; } + + /// Name of the red-team run. + public string DisplayName { get; set; } + + /// Number of simulation rounds. + public int? NumTurns { get; set; } + + /// List of attack strategies or nested lists of attack strategies. + public IList AttackStrategies { get; } + + /// Simulation-only or Simulation + Evaluation. Default false, if true the scan outputs conversation not evaluation result. + public bool? SimulationOnly { get; set; } + + /// List of risk categories to generate attack objectives for. + public IList RiskCategories { get; } + + /// Application scenario for the red team operation, to generate scenario specific attacks. + public string ApplicationScenario { get; set; } + + /// Red team's tags. Unlike properties, tags are fully mutable. + public IDictionary Tags { get; } + + /// Red team's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. + public IDictionary Properties { get; } + + /// Status of the red-team. It is set by service and is read-only. + public string Status { get; } + + /// Target configuration for the red-team run. + public TargetConfig Target { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RedTeams.RestClient.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RedTeams.RestClient.cs new file mode 100644 index 000000000000..250f04586e6a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/RedTeams.RestClient.cs @@ -0,0 +1,77 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace Azure.AI.Projects +{ + /// + public partial class RedTeams + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier201; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier201 => _pipelineMessageClassifier201 = PipelineMessageClassifier.Create(stackalloc ushort[] { 201 }); + + internal PipelineMessage CreateGetRequest(string name, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/redTeams/runs/", false); + uri.AppendPath(name, true); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + request.Headers.Set("x-ms-client-request-id", request.ClientRequestId); + return message; + } + + internal PipelineMessage CreateGetAllRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/redTeams/runs", false); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + request.Headers.Set("x-ms-client-request-id", request.ClientRequestId); + return message; + } + + internal PipelineMessage CreateNextGetAllRequest(Uri nextPage, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(nextPage); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + request.Headers.Set("x-ms-client-request-id", request.ClientRequestId); + return message; + } + + internal PipelineMessage CreateCreateRequest(BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/redTeams/runs:run", false); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "POST", PipelineMessageClassifier201); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Headers.Set("Accept", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RedTeams.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RedTeams.cs new file mode 100644 index 000000000000..aa6b2df82bfa --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/RedTeams.cs @@ -0,0 +1,226 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; + +namespace Azure.AI.Projects +{ + /// The RedTeams sub-client. + public partial class RedTeams + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of RedTeams for mocking. + protected RedTeams() + { + } + + /// Initializes a new instance of RedTeams. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal RedTeams(ClientPipeline pipeline, Uri endpoint, string apiVersion) + { + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } + + /// + /// [Protocol Method] Get a redteam by name. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Identifier of the red team run. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(string name, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using PipelineMessage message = CreateGetRequest(name, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Get a redteam by name. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Identifier of the red team run. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(string name, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using PipelineMessage message = CreateGetRequest(name, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Get a redteam by name. + /// Identifier of the red team run. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult Get(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + ClientResult result = Get(name, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((RedTeam)result, result.GetRawResponse()); + } + + /// Get a redteam by name. + /// Identifier of the red team run. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + ClientResult result = await GetAsync(name, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((RedTeam)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] List a redteam by name. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual CollectionResult GetAll(RequestOptions options) + { + return new RedTeamsGetAllCollectionResult(this, options); + } + + /// + /// [Protocol Method] List a redteam by name. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual AsyncCollectionResult GetAllAsync(RequestOptions options) + { + return new RedTeamsGetAllAsyncCollectionResult(this, options); + } + + /// List a redteam by name. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual CollectionResult GetAll(CancellationToken cancellationToken = default) + { + return new RedTeamsGetAllCollectionResultOfT(this, cancellationToken.ToRequestOptions()); + } + + /// List a redteam by name. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual AsyncCollectionResult GetAllAsync(CancellationToken cancellationToken = default) + { + return new RedTeamsGetAllAsyncCollectionResultOfT(this, cancellationToken.ToRequestOptions()); + } + + /// + /// [Protocol Method] Creates a redteam run. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Create(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateCreateRequest(content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Creates a redteam run. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task CreateAsync(BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateCreateRequest(content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Creates a redteam run. + /// Redteam to be run. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual ClientResult Create(RedTeam redTeam, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(redTeam, nameof(redTeam)); + + ClientResult result = Create(redTeam, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((RedTeam)result, result.GetRawResponse()); + } + + /// Creates a redteam run. + /// Redteam to be run. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// Service returned a non-success status code. + public virtual async Task> CreateAsync(RedTeam redTeam, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(redTeam, nameof(redTeam)); + + ClientResult result = await CreateAsync(redTeam, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((RedTeam)result, result.GetRawResponse()); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ResponseTextFormatConfigurationType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ResponseTextFormatConfigurationType.cs new file mode 100644 index 000000000000..f30570f02413 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ResponseTextFormatConfigurationType.cs @@ -0,0 +1,84 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects; + +namespace OpenAI +{ + /// + /// An object specifying the format that the model must output. + /// + /// Configuring `{ "type": "json_schema" }` enables Structured Outputs, + /// which ensures the model will match your supplied JSON schema. Learn more in the + /// [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs). + /// + /// The default format is `{ "type": "text" }` with no additional options. + /// + /// **Not recommended for gpt-4o and newer models:** + /// + /// Setting to `{ "type": "json_object" }` enables the older JSON mode, which + /// ensures the message the model generates is valid JSON. Using `json_schema` + /// is preferred for models that support it. + /// + internal readonly partial struct ResponseTextFormatConfigurationType : IEquatable + { + private readonly string _value; + private const string TextValue = "text"; + private const string JsonSchemaValue = "json_schema"; + private const string JsonObjectValue = "json_object"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ResponseTextFormatConfigurationType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Text. + public static ResponseTextFormatConfigurationType Text { get; } = new ResponseTextFormatConfigurationType(TextValue); + + /// Gets the JsonSchema. + public static ResponseTextFormatConfigurationType JsonSchema { get; } = new ResponseTextFormatConfigurationType(JsonSchemaValue); + + /// Gets the JsonObject. + public static ResponseTextFormatConfigurationType JsonObject { get; } = new ResponseTextFormatConfigurationType(JsonObjectValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ResponseTextFormatConfigurationType left, ResponseTextFormatConfigurationType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ResponseTextFormatConfigurationType left, ResponseTextFormatConfigurationType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ResponseTextFormatConfigurationType(string value) => new ResponseTextFormatConfigurationType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ResponseTextFormatConfigurationType?(string value) => value == null ? null : new ResponseTextFormatConfigurationType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ResponseTextFormatConfigurationType other && Equals(other); + + /// + public bool Equals(ResponseTextFormatConfigurationType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ResponsesMessageRole.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ResponsesMessageRole.cs new file mode 100644 index 000000000000..d629a2283d71 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ResponsesMessageRole.cs @@ -0,0 +1,73 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal readonly partial struct ResponsesMessageRole : IEquatable + { + private readonly string _value; + private const string SystemValue = "system"; + private const string DeveloperValue = "developer"; + private const string UserValue = "user"; + private const string AssistantValue = "assistant"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ResponsesMessageRole(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the System. + public static ResponsesMessageRole System { get; } = new ResponsesMessageRole(SystemValue); + + /// Gets the Developer. + public static ResponsesMessageRole Developer { get; } = new ResponsesMessageRole(DeveloperValue); + + /// Gets the User. + public static ResponsesMessageRole User { get; } = new ResponsesMessageRole(UserValue); + + /// Gets the Assistant. + public static ResponsesMessageRole Assistant { get; } = new ResponsesMessageRole(AssistantValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ResponsesMessageRole left, ResponsesMessageRole right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ResponsesMessageRole left, ResponsesMessageRole right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ResponsesMessageRole(string value) => new ResponsesMessageRole(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ResponsesMessageRole?(string value) => value == null ? null : new ResponsesMessageRole(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ResponsesMessageRole other && Equals(other); + + /// + public bool Equals(ResponsesMessageRole other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RiskCategory.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RiskCategory.cs new file mode 100644 index 000000000000..5fbf117f0e61 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/RiskCategory.cs @@ -0,0 +1,107 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// Risk category for the attack objective. + public readonly partial struct RiskCategory : IEquatable + { + private readonly string _value; + /// Represents content related to hate or unfairness. + private const string HateUnfairnessValue = "HateUnfairness"; + /// Represents content related to violence. + private const string ViolenceValue = "Violence"; + /// Represents content of a sexual nature. + private const string SexualValue = "Sexual"; + /// Represents content related to self-harm. + private const string SelfHarmValue = "SelfHarm"; + /// Represents content that involves illegal activities. + private const string ProtectedMaterialValue = "ProtectedMaterial"; + /// Represents content that contains vulnerabilities in code. + private const string CodeVulnerabilityValue = "CodeVulnerability"; + /// Represents content that lacks a solid grounding in fact. + private const string UngroundedAttributesValue = "UngroundedAttributes"; + /// Represents content that involves prohibited actions. + private const string ProhibitedActionsValue = "ProhibitedActions"; + /// Represents content that involves sensitive data leakage. + private const string SensitiveDataLeakageValue = "SensitiveDataLeakage"; + /// Represents content that involves task adherence. + private const string TaskAdherenceValue = "TaskAdherence"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public RiskCategory(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Represents content related to hate or unfairness. + public static RiskCategory HateUnfairness { get; } = new RiskCategory(HateUnfairnessValue); + + /// Represents content related to violence. + public static RiskCategory Violence { get; } = new RiskCategory(ViolenceValue); + + /// Represents content of a sexual nature. + public static RiskCategory Sexual { get; } = new RiskCategory(SexualValue); + + /// Represents content related to self-harm. + public static RiskCategory SelfHarm { get; } = new RiskCategory(SelfHarmValue); + + /// Represents content that involves illegal activities. + public static RiskCategory ProtectedMaterial { get; } = new RiskCategory(ProtectedMaterialValue); + + /// Represents content that contains vulnerabilities in code. + public static RiskCategory CodeVulnerability { get; } = new RiskCategory(CodeVulnerabilityValue); + + /// Represents content that lacks a solid grounding in fact. + public static RiskCategory UngroundedAttributes { get; } = new RiskCategory(UngroundedAttributesValue); + + /// Represents content that involves prohibited actions. + public static RiskCategory ProhibitedActions { get; } = new RiskCategory(ProhibitedActionsValue); + + /// Represents content that involves sensitive data leakage. + public static RiskCategory SensitiveDataLeakage { get; } = new RiskCategory(SensitiveDataLeakageValue); + + /// Represents content that involves task adherence. + public static RiskCategory TaskAdherence { get; } = new RiskCategory(TaskAdherenceValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(RiskCategory left, RiskCategory right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(RiskCategory left, RiskCategory right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator RiskCategory(string value) => new RiskCategory(value); + + /// Converts a string to a . + /// The value. + public static implicit operator RiskCategory?(string value) => value == null ? null : new RiskCategory(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RiskCategory other && Equals(other); + + /// + public bool Equals(RiskCategory other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/SampleType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/SampleType.cs new file mode 100644 index 000000000000..2dd0a0f19637 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/SampleType.cs @@ -0,0 +1,62 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// The type of sample used in the analysis. + internal readonly partial struct SampleType : IEquatable + { + private readonly string _value; + /// A sample from the evaluation result. + private const string EvaluationResultSampleValue = "EvaluationResultSample"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public SampleType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// A sample from the evaluation result. + public static SampleType EvaluationResultSample { get; } = new SampleType(EvaluationResultSampleValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(SampleType left, SampleType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(SampleType left, SampleType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator SampleType(string value) => new SampleType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator SampleType?(string value) => value == null ? null : new SampleType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is SampleType other && Equals(other); + + /// + public bool Equals(SampleType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Schedule.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Schedule.Serialization.cs new file mode 100644 index 000000000000..181abbecf69a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Schedule.Serialization.cs @@ -0,0 +1,343 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Schedule model. + public partial class Schedule : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal Schedule() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Schedule)} does not support writing '{format}' format."); + } + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("enabled"u8); + writer.WriteBooleanValue(Enabled); + if (options.Format != "W" && Optional.IsDefined(ProvisioningStatus)) + { + writer.WritePropertyName("provisioningStatus"u8); + writer.WriteStringValue(ProvisioningStatus.Value.ToString()); + } + writer.WritePropertyName("trigger"u8); + writer.WriteObjectValue(Trigger, options); + writer.WritePropertyName("task"u8); + writer.WriteObjectValue(Task, options); + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsCollectionDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + foreach (var item in Properties) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W") + { + writer.WritePropertyName("systemData"u8); + writer.WriteStartObject(); + foreach (var item in SystemData) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + Schedule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual Schedule JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Schedule)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSchedule(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static Schedule DeserializeSchedule(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string displayName = default; + string description = default; + bool enabled = default; + ScheduleProvisioningStatus? provisioningStatus = default; + Trigger trigger = default; + ScheduleTask task = default; + IDictionary tags = default; + IDictionary properties = default; + IReadOnlyDictionary systemData = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("displayName"u8)) + { + displayName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("enabled"u8)) + { + enabled = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("provisioningStatus"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningStatus = new ScheduleProvisioningStatus(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("trigger"u8)) + { + trigger = Trigger.DeserializeTrigger(prop.Value, options); + continue; + } + if (prop.NameEquals("task"u8)) + { + task = ScheduleTask.DeserializeScheduleTask(prop.Value, options); + continue; + } + if (prop.NameEquals("tags"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + tags = dictionary; + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + properties = dictionary; + continue; + } + if (prop.NameEquals("systemData"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + systemData = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new Schedule( + id, + displayName, + description, + enabled, + provisioningStatus, + trigger, + task, + tags ?? new ChangeTrackingDictionary(), + properties ?? new ChangeTrackingDictionary(), + systemData, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(Schedule)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + Schedule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual Schedule PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeSchedule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Schedule)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(Schedule schedule) + { + if (schedule == null) + { + return null; + } + return BinaryContent.Create(schedule, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + public static explicit operator Schedule(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSchedule(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Schedule.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Schedule.cs new file mode 100644 index 000000000000..874e4a388ca4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Schedule.cs @@ -0,0 +1,91 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Schedule model. + public partial class Schedule + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Enabled status of the schedule. + /// Trigger for the schedule. + /// Task for the schedule. + /// or is null. + public Schedule(bool enabled, Trigger trigger, ScheduleTask task) + { + Argument.AssertNotNull(trigger, nameof(trigger)); + Argument.AssertNotNull(task, nameof(task)); + + Enabled = enabled; + Trigger = trigger; + Task = task; + Tags = new ChangeTrackingDictionary(); + Properties = new ChangeTrackingDictionary(); + SystemData = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Identifier of the schedule. + /// Name of the schedule. + /// Description of the schedule. + /// Enabled status of the schedule. + /// Provisioning status of the schedule. + /// Trigger for the schedule. + /// Task for the schedule. + /// Schedule's tags. Unlike properties, tags are fully mutable. + /// Schedule's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. + /// System metadata for the resource. + /// Keeps track of any properties unknown to the library. + internal Schedule(string id, string displayName, string description, bool enabled, ScheduleProvisioningStatus? provisioningStatus, Trigger trigger, ScheduleTask task, IDictionary tags, IDictionary properties, IReadOnlyDictionary systemData, IDictionary additionalBinaryDataProperties) + { + Id = id; + DisplayName = displayName; + Description = description; + Enabled = enabled; + ProvisioningStatus = provisioningStatus; + Trigger = trigger; + Task = task; + Tags = tags; + Properties = properties; + SystemData = systemData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Identifier of the schedule. + public string Id { get; } + + /// Name of the schedule. + public string DisplayName { get; set; } + + /// Description of the schedule. + public string Description { get; set; } + + /// Enabled status of the schedule. + public bool Enabled { get; set; } + + /// Provisioning status of the schedule. + public ScheduleProvisioningStatus? ProvisioningStatus { get; } + + /// Trigger for the schedule. + public Trigger Trigger { get; set; } + + /// Task for the schedule. + public ScheduleTask Task { get; set; } + + /// Schedule's tags. Unlike properties, tags are fully mutable. + public IDictionary Tags { get; } + + /// Schedule's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. + public IDictionary Properties { get; } + + /// System metadata for the resource. + public IReadOnlyDictionary SystemData { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ScheduleProvisioningStatus.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ScheduleProvisioningStatus.cs new file mode 100644 index 000000000000..163a41b448f9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ScheduleProvisioningStatus.cs @@ -0,0 +1,82 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// Schedule provisioning status. + public readonly partial struct ScheduleProvisioningStatus : IEquatable + { + private readonly string _value; + /// Represents the creation status of the schedule. + private const string CreatingValue = "Creating"; + /// Represents the updating status of the schedule. + private const string UpdatingValue = "Updating"; + /// Represents the deleting status of the schedule. + private const string DeletingValue = "Deleting"; + /// Represents the succeeded status of the schedule. + private const string SucceededValue = "Succeeded"; + /// Represents the failed status of the schedule. + private const string FailedValue = "Failed"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ScheduleProvisioningStatus(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Represents the creation status of the schedule. + public static ScheduleProvisioningStatus Creating { get; } = new ScheduleProvisioningStatus(CreatingValue); + + /// Represents the updating status of the schedule. + public static ScheduleProvisioningStatus Updating { get; } = new ScheduleProvisioningStatus(UpdatingValue); + + /// Represents the deleting status of the schedule. + public static ScheduleProvisioningStatus Deleting { get; } = new ScheduleProvisioningStatus(DeletingValue); + + /// Represents the succeeded status of the schedule. + public static ScheduleProvisioningStatus Succeeded { get; } = new ScheduleProvisioningStatus(SucceededValue); + + /// Represents the failed status of the schedule. + public static ScheduleProvisioningStatus Failed { get; } = new ScheduleProvisioningStatus(FailedValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ScheduleProvisioningStatus left, ScheduleProvisioningStatus right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ScheduleProvisioningStatus left, ScheduleProvisioningStatus right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ScheduleProvisioningStatus(string value) => new ScheduleProvisioningStatus(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ScheduleProvisioningStatus?(string value) => value == null ? null : new ScheduleProvisioningStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ScheduleProvisioningStatus other && Equals(other); + + /// + public bool Equals(ScheduleProvisioningStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ScheduleRun.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ScheduleRun.Serialization.cs new file mode 100644 index 000000000000..6adf36f1225a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ScheduleRun.Serialization.cs @@ -0,0 +1,233 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Schedule run model. + public partial class ScheduleRun : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ScheduleRun() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ScheduleRun)} does not support writing '{format}' format."); + } + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(RunId); + } + writer.WritePropertyName("scheduleId"u8); + writer.WriteStringValue(ScheduleId); + if (options.Format != "W") + { + writer.WritePropertyName("success"u8); + writer.WriteBooleanValue(Success); + } + if (Optional.IsDefined(TriggerTime)) + { + writer.WritePropertyName("triggerTime"u8); + writer.WriteStringValue(TriggerTime); + } + if (options.Format != "W" && Optional.IsDefined(Error)) + { + writer.WritePropertyName("error"u8); + writer.WriteStringValue(Error); + } + if (options.Format != "W") + { + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + foreach (var item in Properties) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ScheduleRun IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ScheduleRun JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ScheduleRun)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeScheduleRun(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ScheduleRun DeserializeScheduleRun(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string runId = default; + string scheduleId = default; + bool success = default; + string triggerTime = default; + string error = default; + IReadOnlyDictionary properties = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + runId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("scheduleId"u8)) + { + scheduleId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("success"u8)) + { + success = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("triggerTime"u8)) + { + triggerTime = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("error"u8)) + { + error = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("properties"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + properties = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ScheduleRun( + runId, + scheduleId, + success, + triggerTime, + error, + properties, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(ScheduleRun)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ScheduleRun IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ScheduleRun PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeScheduleRun(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ScheduleRun)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + public static explicit operator ScheduleRun(ClientResult result) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeScheduleRun(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ScheduleRun.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ScheduleRun.cs new file mode 100644 index 000000000000..0a5a9750f492 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ScheduleRun.cs @@ -0,0 +1,61 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Schedule run model. + public partial class ScheduleRun + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Identifier of the schedule. + internal ScheduleRun(string scheduleId) + { + ScheduleId = scheduleId; + Properties = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Identifier of the schedule run. + /// Identifier of the schedule. + /// Trigger success status of the schedule run. + /// Trigger time of the schedule run. + /// Error information for the schedule run. + /// Properties of the schedule run. + /// Keeps track of any properties unknown to the library. + internal ScheduleRun(string runId, string scheduleId, bool success, string triggerTime, string error, IReadOnlyDictionary properties, IDictionary additionalBinaryDataProperties) + { + RunId = runId; + ScheduleId = scheduleId; + Success = success; + TriggerTime = triggerTime; + Error = error; + Properties = properties; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Identifier of the schedule run. + public string RunId { get; } + + /// Identifier of the schedule. + public string ScheduleId { get; } + + /// Trigger success status of the schedule run. + public bool Success { get; } + + /// Trigger time of the schedule run. + public string TriggerTime { get; } + + /// Error information for the schedule run. + public string Error { get; } + + /// Properties of the schedule run. + public IReadOnlyDictionary Properties { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ScheduleTask.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ScheduleTask.Serialization.cs new file mode 100644 index 000000000000..bec18445be78 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ScheduleTask.Serialization.cs @@ -0,0 +1,154 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// + /// Schedule task model. + /// Please note this is the abstract base class. The derived classes available for instantiation are: and . + /// + [PersistableModelProxy(typeof(UnknownScheduleTask))] + public abstract partial class ScheduleTask : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ScheduleTask() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ScheduleTask)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (Optional.IsCollectionDefined(Configuration)) + { + writer.WritePropertyName("configuration"u8); + writer.WriteStartObject(); + foreach (var item in Configuration) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ScheduleTask IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ScheduleTask JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ScheduleTask)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeScheduleTask(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ScheduleTask DeserializeScheduleTask(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "Evaluation": + return EvaluationScheduleTask.DeserializeEvaluationScheduleTask(element, options); + case "Insight": + return InsightScheduleTask.DeserializeInsightScheduleTask(element, options); + } + } + return UnknownScheduleTask.DeserializeUnknownScheduleTask(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(ScheduleTask)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ScheduleTask IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ScheduleTask PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeScheduleTask(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ScheduleTask)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ScheduleTask.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ScheduleTask.cs new file mode 100644 index 000000000000..0b611bed6bae --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ScheduleTask.cs @@ -0,0 +1,44 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// + /// Schedule task model. + /// Please note this is the abstract base class. The derived classes available for instantiation are: and . + /// + public abstract partial class ScheduleTask + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Type of the task. + private protected ScheduleTask(ScheduleTaskType @type) + { + Type = @type; + Configuration = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Type of the task. + /// Configuration for the task. + /// Keeps track of any properties unknown to the library. + internal ScheduleTask(ScheduleTaskType @type, IDictionary configuration, IDictionary additionalBinaryDataProperties) + { + Type = @type; + Configuration = configuration; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Type of the task. + internal ScheduleTaskType Type { get; set; } + + /// Configuration for the task. + public IDictionary Configuration { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ScheduleTaskType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ScheduleTaskType.cs new file mode 100644 index 000000000000..bac0daf13455 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ScheduleTaskType.cs @@ -0,0 +1,67 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// Type of the task. + internal readonly partial struct ScheduleTaskType : IEquatable + { + private readonly string _value; + /// Evaluation task. + private const string EvaluationValue = "Evaluation"; + /// Insight task. + private const string InsightValue = "Insight"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ScheduleTaskType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Evaluation task. + public static ScheduleTaskType Evaluation { get; } = new ScheduleTaskType(EvaluationValue); + + /// Insight task. + public static ScheduleTaskType Insight { get; } = new ScheduleTaskType(InsightValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ScheduleTaskType left, ScheduleTaskType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ScheduleTaskType left, ScheduleTaskType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ScheduleTaskType(string value) => new ScheduleTaskType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ScheduleTaskType?(string value) => value == null ? null : new ScheduleTaskType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ScheduleTaskType other && Equals(other); + + /// + public bool Equals(ScheduleTaskType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Schedules.RestClient.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Schedules.RestClient.cs new file mode 100644 index 000000000000..3c6120539a37 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Schedules.RestClient.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace Azure.AI.Projects +{ + /// + public partial class Schedules + { + private static PipelineMessageClassifier _pipelineMessageClassifier200; + private static PipelineMessageClassifier _pipelineMessageClassifier200201; + private static PipelineMessageClassifier _pipelineMessageClassifier204; + + private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); + + private static PipelineMessageClassifier PipelineMessageClassifier200201 => _pipelineMessageClassifier200201 = PipelineMessageClassifier.Create(stackalloc ushort[] { 200, 201 }); + + private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 = PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); + + internal PipelineMessage CreateDeleteRequest(string id, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/schedules/", false); + uri.AppendPath(id, true); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "DELETE", PipelineMessageClassifier204); + PipelineRequest request = message.Request; + message.Apply(options); + request.Headers.Set("x-ms-client-request-id", request.ClientRequestId); + return message; + } + + internal PipelineMessage CreateGetRequest(string id, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/schedules/", false); + uri.AppendPath(id, true); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + request.Headers.Set("x-ms-client-request-id", request.ClientRequestId); + return message; + } + + internal PipelineMessage CreateGetAllRequest(RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/schedules", false); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + request.Headers.Set("x-ms-client-request-id", request.ClientRequestId); + return message; + } + + internal PipelineMessage CreateNextGetAllRequest(Uri nextPage, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(nextPage); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + request.Headers.Set("x-ms-client-request-id", request.ClientRequestId); + return message; + } + + internal PipelineMessage CreateCreateOrUpdateRequest(string id, BinaryContent content, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/schedules/", false); + uri.AppendPath(id, true); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "PUT", PipelineMessageClassifier200201); + PipelineRequest request = message.Request; + request.Headers.Set("Content-Type", "application/json"); + request.Headers.Set("Accept", "application/json"); + request.Content = content; + message.Apply(options); + return message; + } + + internal PipelineMessage CreateGetRunRequest(string scheduleId, string runId, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/schedules/", false); + uri.AppendPath(scheduleId, true); + uri.AppendPath("/runs/", false); + uri.AppendPath(runId, true); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + return message; + } + + internal PipelineMessage CreateGetRunsRequest(string id, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/schedules/", false); + uri.AppendPath(id, true); + uri.AppendPath("/runs", false); + uri.AppendQuery("api-version", _apiVersion, true); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + request.Headers.Set("x-ms-client-request-id", request.ClientRequestId); + return message; + } + + internal PipelineMessage CreateNextGetRunsRequest(Uri nextPage, string id, RequestOptions options) + { + ClientUriBuilder uri = new ClientUriBuilder(); + uri.Reset(nextPage); + PipelineMessage message = Pipeline.CreateMessage(uri.ToUri(), "GET", PipelineMessageClassifier200); + PipelineRequest request = message.Request; + request.Headers.Set("Accept", "application/json"); + message.Apply(options); + request.Headers.Set("x-ms-client-request-id", request.ClientRequestId); + return message; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Schedules.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Schedules.cs new file mode 100644 index 000000000000..f5982e11074f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Schedules.cs @@ -0,0 +1,456 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; + +namespace Azure.AI.Projects +{ + /// The Schedules sub-client. + public partial class Schedules + { + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of Schedules for mocking. + protected Schedules() + { + } + + /// Initializes a new instance of Schedules. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal Schedules(ClientPipeline pipeline, Uri endpoint, string apiVersion) + { + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; + } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public ClientPipeline Pipeline { get; } + + /// + /// [Protocol Method] Delete a schedule. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Identifier of the schedule. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Delete(string id, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + using PipelineMessage message = CreateDeleteRequest(id, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Delete a schedule. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Identifier of the schedule. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task DeleteAsync(string id, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + using PipelineMessage message = CreateDeleteRequest(id, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Delete a schedule. + /// Identifier of the schedule. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult Delete(string id, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + return Delete(id, cancellationToken.ToRequestOptions()); + } + + /// Delete a schedule. + /// Identifier of the schedule. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task DeleteAsync(string id, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + return await DeleteAsync(id, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + } + + /// + /// [Protocol Method] Get a schedule by id. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Identifier of the schedule. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult Get(string id, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + using PipelineMessage message = CreateGetRequest(id, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Get a schedule by id. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Identifier of the schedule. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetAsync(string id, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + using PipelineMessage message = CreateGetRequest(id, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Get a schedule by id. + /// Identifier of the schedule. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult Get(string id, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + ClientResult result = Get(id, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Schedule)result, result.GetRawResponse()); + } + + /// Get a schedule by id. + /// Identifier of the schedule. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> GetAsync(string id, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + ClientResult result = await GetAsync(id, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Schedule)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] List all schedules. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual CollectionResult GetAll(RequestOptions options) + { + return new SchedulesGetAllCollectionResult(this, options); + } + + /// + /// [Protocol Method] List all schedules. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual AsyncCollectionResult GetAllAsync(RequestOptions options) + { + return new SchedulesGetAllAsyncCollectionResult(this, options); + } + + /// List all schedules. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual CollectionResult GetAll(CancellationToken cancellationToken = default) + { + return new SchedulesGetAllCollectionResultOfT(this, cancellationToken.ToRequestOptions()); + } + + /// List all schedules. + /// The cancellation token that can be used to cancel the operation. + /// Service returned a non-success status code. + public virtual AsyncCollectionResult GetAllAsync(CancellationToken cancellationToken = default) + { + return new SchedulesGetAllAsyncCollectionResultOfT(this, cancellationToken.ToRequestOptions()); + } + + /// + /// [Protocol Method] Create or update a schedule by id. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Identifier of the schedule. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult CreateOrUpdate(string id, BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateCreateOrUpdateRequest(id, content, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Create or update a schedule by id. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Identifier of the schedule. + /// The content to send as the body of the request. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task CreateOrUpdateAsync(string id, BinaryContent content, RequestOptions options = null) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + Argument.AssertNotNull(content, nameof(content)); + + using PipelineMessage message = CreateCreateOrUpdateRequest(id, content, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Create or update a schedule by id. + /// Identifier of the schedule. + /// Schedule resource. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult CreateOrUpdate(string id, Schedule schedule, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + Argument.AssertNotNull(schedule, nameof(schedule)); + + ClientResult result = CreateOrUpdate(id, schedule, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((Schedule)result, result.GetRawResponse()); + } + + /// Create or update a schedule by id. + /// Identifier of the schedule. + /// Schedule resource. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> CreateOrUpdateAsync(string id, Schedule schedule, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + Argument.AssertNotNull(schedule, nameof(schedule)); + + ClientResult result = await CreateOrUpdateAsync(id, schedule, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((Schedule)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] Get a schedule run by id. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Identifier of the schedule. + /// Identifier of the schedule run. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual ClientResult GetRun(string scheduleId, string runId, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(scheduleId, nameof(scheduleId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using PipelineMessage message = CreateGetRunRequest(scheduleId, runId, options); + return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options)); + } + + /// + /// [Protocol Method] Get a schedule run by id. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Identifier of the schedule. + /// Identifier of the schedule run. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual async Task GetRunAsync(string scheduleId, string runId, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(scheduleId, nameof(scheduleId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using PipelineMessage message = CreateGetRunRequest(scheduleId, runId, options); + return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); + } + + /// Get a schedule run by id. + /// Identifier of the schedule. + /// Identifier of the schedule run. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual ClientResult GetRun(string scheduleId, string runId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(scheduleId, nameof(scheduleId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + ClientResult result = GetRun(scheduleId, runId, cancellationToken.ToRequestOptions()); + return ClientResult.FromValue((ScheduleRun)result, result.GetRawResponse()); + } + + /// Get a schedule run by id. + /// Identifier of the schedule. + /// Identifier of the schedule run. + /// The cancellation token that can be used to cancel the operation. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual async Task> GetRunAsync(string scheduleId, string runId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(scheduleId, nameof(scheduleId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + ClientResult result = await GetRunAsync(scheduleId, runId, cancellationToken.ToRequestOptions()).ConfigureAwait(false); + return ClientResult.FromValue((ScheduleRun)result, result.GetRawResponse()); + } + + /// + /// [Protocol Method] List all schedule runs. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Identifier of the schedule. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual CollectionResult GetRuns(string id, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + return new SchedulesGetRunsCollectionResult(this, id, options); + } + + /// + /// [Protocol Method] List all schedule runs. + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// Identifier of the schedule. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + public virtual AsyncCollectionResult GetRunsAsync(string id, RequestOptions options) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + return new SchedulesGetRunsAsyncCollectionResult(this, id, options); + } + + /// List all schedule runs. + /// Identifier of the schedule. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual CollectionResult GetRuns(string id, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + return new SchedulesGetRunsCollectionResultOfT(this, id, cancellationToken.ToRequestOptions()); + } + + /// List all schedule runs. + /// Identifier of the schedule. + /// The cancellation token that can be used to cancel the operation. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + public virtual AsyncCollectionResult GetRunsAsync(string id, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(id, nameof(id)); + + return new SchedulesGetRunsAsyncCollectionResultOfT(this, id, cancellationToken.ToRequestOptions()); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/SharepointAgentTool.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/SharepointAgentTool.Serialization.cs new file mode 100644 index 000000000000..8a4f63ec39c3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/SharepointAgentTool.Serialization.cs @@ -0,0 +1,132 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// The input definition information for a sharepoint tool as used to configure an agent. + internal partial class SharepointAgentTool : InternalTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal SharepointAgentTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SharepointAgentTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("sharepoint_grounding_preview"u8); + writer.WriteObjectValue(SharepointGroundingPreview, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + SharepointAgentTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (SharepointAgentTool)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SharepointAgentTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSharepointAgentTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SharepointAgentTool DeserializeSharepointAgentTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + SharepointGroundingToolParameters sharepointGroundingPreview = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("sharepoint_grounding_preview"u8)) + { + sharepointGroundingPreview = SharepointGroundingToolParameters.DeserializeSharepointGroundingToolParameters(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SharepointAgentTool(@type, additionalBinaryDataProperties, sharepointGroundingPreview); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(SharepointAgentTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + SharepointAgentTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (SharepointAgentTool)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeSharepointAgentTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SharepointAgentTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/SharepointAgentTool.cs b/sdk/ai/Azure.AI.Projects/src/Generated/SharepointAgentTool.cs new file mode 100644 index 000000000000..3ecda1f54a85 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/SharepointAgentTool.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using OpenAI; + +namespace Azure.AI.Projects +{ + /// The input definition information for a sharepoint tool as used to configure an agent. + internal partial class SharepointAgentTool : InternalTool + { + /// Initializes a new instance of . + /// The sharepoint grounding tool parameters. + /// is null. + public SharepointAgentTool(SharepointGroundingToolParameters sharepointGroundingPreview) : base(ToolType.SharepointGroundingPreview) + { + Argument.AssertNotNull(sharepointGroundingPreview, nameof(sharepointGroundingPreview)); + + SharepointGroundingPreview = sharepointGroundingPreview; + } + + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The sharepoint grounding tool parameters. + internal SharepointAgentTool(ToolType @type, IDictionary additionalBinaryDataProperties, SharepointGroundingToolParameters sharepointGroundingPreview) : base(@type, additionalBinaryDataProperties) + { + SharepointGroundingPreview = sharepointGroundingPreview; + } + + /// The sharepoint grounding tool parameters. + public SharepointGroundingToolParameters SharepointGroundingPreview { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/SharepointGroundingToolParameters.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/SharepointGroundingToolParameters.Serialization.cs new file mode 100644 index 000000000000..89c64214896b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/SharepointGroundingToolParameters.Serialization.cs @@ -0,0 +1,151 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The sharepoint grounding tool parameters. + internal partial class SharepointGroundingToolParameters : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SharepointGroundingToolParameters)} does not support writing '{format}' format."); + } + if (Optional.IsCollectionDefined(ProjectConnections)) + { + writer.WritePropertyName("project_connections"u8); + writer.WriteStartArray(); + foreach (ToolProjectConnection item in ProjectConnections) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + SharepointGroundingToolParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual SharepointGroundingToolParameters JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SharepointGroundingToolParameters)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSharepointGroundingToolParameters(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static SharepointGroundingToolParameters DeserializeSharepointGroundingToolParameters(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList projectConnections = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("project_connections"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ToolProjectConnection.DeserializeToolProjectConnection(item, options)); + } + projectConnections = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new SharepointGroundingToolParameters(projectConnections ?? new ChangeTrackingList(), additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(SharepointGroundingToolParameters)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + SharepointGroundingToolParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual SharepointGroundingToolParameters PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeSharepointGroundingToolParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SharepointGroundingToolParameters)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/SharepointGroundingToolParameters.cs b/sdk/ai/Azure.AI.Projects/src/Generated/SharepointGroundingToolParameters.cs new file mode 100644 index 000000000000..a27768db5327 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/SharepointGroundingToolParameters.cs @@ -0,0 +1,40 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// The sharepoint grounding tool parameters. + internal partial class SharepointGroundingToolParameters + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public SharepointGroundingToolParameters() + { + ProjectConnections = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// The project connections attached to this tool. There can be a maximum of 1 connection + /// resource attached to the tool. + /// + /// Keeps track of any properties unknown to the library. + internal SharepointGroundingToolParameters(IList projectConnections, IDictionary additionalBinaryDataProperties) + { + ProjectConnections = projectConnections; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// The project connections attached to this tool. There can be a maximum of 1 connection + /// resource attached to the tool. + /// + public IList ProjectConnections { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/StructuredInputDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/StructuredInputDefinition.Serialization.cs new file mode 100644 index 000000000000..5876fe63045b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/StructuredInputDefinition.Serialization.cs @@ -0,0 +1,196 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// An structured input that can participate in prompt template substitutions and tool argument binding. + internal partial class StructuredInputDefinition : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StructuredInputDefinition)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(DefaultValue)) + { + writer.WritePropertyName("default_value"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(DefaultValue); +#else + using (JsonDocument document = JsonDocument.Parse(DefaultValue)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (Optional.IsDefined(Schema)) + { + writer.WritePropertyName("schema"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Schema); +#else + using (JsonDocument document = JsonDocument.Parse(Schema)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (Optional.IsDefined(Required)) + { + writer.WritePropertyName("required"u8); + writer.WriteBooleanValue(Required.Value); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + StructuredInputDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual StructuredInputDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StructuredInputDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStructuredInputDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static StructuredInputDefinition DeserializeStructuredInputDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string description = default; + BinaryData defaultValue = default; + BinaryData schema = default; + bool? @required = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("default_value"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + defaultValue = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("schema"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + schema = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("required"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + @required = prop.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new StructuredInputDefinition(description, defaultValue, schema, @required, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(StructuredInputDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + StructuredInputDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual StructuredInputDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeStructuredInputDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StructuredInputDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/StructuredInputDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/StructuredInputDefinition.cs new file mode 100644 index 000000000000..8bd589131245 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/StructuredInputDefinition.cs @@ -0,0 +1,99 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// An structured input that can participate in prompt template substitutions and tool argument binding. + internal partial class StructuredInputDefinition + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public StructuredInputDefinition() + { + } + + /// Initializes a new instance of . + /// A human-readable description of the input. + /// The default value for the input if no run-time value is provided. + /// The JSON schema for the structured input (optional). + /// Whether the input property is required when the agent is invoked. + /// Keeps track of any properties unknown to the library. + internal StructuredInputDefinition(string description, BinaryData defaultValue, BinaryData schema, bool? @required, IDictionary additionalBinaryDataProperties) + { + Description = description; + DefaultValue = defaultValue; + Schema = schema; + Required = @required; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// A human-readable description of the input. + public string Description { get; set; } + + /// + /// The default value for the input if no run-time value is provided. + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData DefaultValue { get; set; } + + /// + /// The JSON schema for the structured input (optional). + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData Schema { get; set; } + + /// Whether the input property is required when the agent is invoked. + public bool? Required { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/StructuredOutputDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/StructuredOutputDefinition.Serialization.cs new file mode 100644 index 000000000000..dd9964b65cdd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/StructuredOutputDefinition.Serialization.cs @@ -0,0 +1,182 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// A structured output that can be produced by the agent. + internal partial class StructuredOutputDefinition : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal StructuredOutputDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StructuredOutputDefinition)} does not support writing '{format}' format."); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + writer.WritePropertyName("schema"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Schema); +#else + using (JsonDocument document = JsonDocument.Parse(Schema)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + if (Optional.IsDefined(Strict)) + { + writer.WritePropertyName("strict"u8); + writer.WriteBooleanValue(Strict.Value); + } + else + { + writer.WriteNull("strict"u8); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + StructuredOutputDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual StructuredOutputDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StructuredOutputDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStructuredOutputDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static StructuredOutputDefinition DeserializeStructuredOutputDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string description = default; + BinaryData schema = default; + bool? strict = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("schema"u8)) + { + schema = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("strict"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + strict = null; + continue; + } + strict = prop.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new StructuredOutputDefinition(name, description, schema, strict, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(StructuredOutputDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + StructuredOutputDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual StructuredOutputDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeStructuredOutputDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StructuredOutputDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/StructuredOutputDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/StructuredOutputDefinition.cs new file mode 100644 index 000000000000..361ddd64d292 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/StructuredOutputDefinition.cs @@ -0,0 +1,87 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// A structured output that can be produced by the agent. + internal partial class StructuredOutputDefinition + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The name of the structured output. + /// A description of the output to emit. Used by the model to determine when to emit the output. + /// The JSON schema for the structured output. + /// Whether to enforce strict validation. Default `true`. + /// , or is null. + public StructuredOutputDefinition(string name, string description, BinaryData schema, bool? strict) + { + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(description, nameof(description)); + Argument.AssertNotNull(schema, nameof(schema)); + + Name = name; + Description = description; + Schema = schema; + Strict = strict; + } + + /// Initializes a new instance of . + /// The name of the structured output. + /// A description of the output to emit. Used by the model to determine when to emit the output. + /// The JSON schema for the structured output. + /// Whether to enforce strict validation. Default `true`. + /// Keeps track of any properties unknown to the library. + internal StructuredOutputDefinition(string name, string description, BinaryData schema, bool? strict, IDictionary additionalBinaryDataProperties) + { + Name = name; + Description = description; + Schema = schema; + Strict = strict; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The name of the structured output. + public string Name { get; set; } + + /// A description of the output to emit. Used by the model to determine when to emit the output. + public string Description { get; set; } + + /// + /// The JSON schema for the structured output. + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData Schema { get; set; } + + /// Whether to enforce strict validation. Default `true`. + public bool? Strict { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Target.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Target.Serialization.cs new file mode 100644 index 000000000000..114a1dff8e3f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Target.Serialization.cs @@ -0,0 +1,140 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// + /// Base class for targets with discriminator support. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// + [PersistableModelProxy(typeof(UnknownTarget))] + public abstract partial class Target : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal Target() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Target)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + Target IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual Target JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Target)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTarget(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static Target DeserializeTarget(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "azure_ai_agent": + return AzureAIAgentTarget.DeserializeAzureAIAgentTarget(element, options); + case "azure_ai_model": + return AzureAIModelTarget.DeserializeAzureAIModelTarget(element, options); + case "azure_ai_assistant": + return AzureAIAssistantTarget.DeserializeAzureAIAssistantTarget(element, options); + } + } + return UnknownTarget.DeserializeUnknownTarget(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(Target)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + Target IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual Target PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTarget(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Target)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Target.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Target.cs new file mode 100644 index 000000000000..423734bf69ef --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Target.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// + /// Base class for targets with discriminator support. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// + public abstract partial class Target + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// The type of target. + private protected Target(string @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// The type of target. + /// Keeps track of any properties unknown to the library. + internal Target(string @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The type of target. + internal string Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/TargetConfig.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/TargetConfig.Serialization.cs new file mode 100644 index 000000000000..8281bf8f7043 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/TargetConfig.Serialization.cs @@ -0,0 +1,136 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// + /// Abstract class for target configuration. + /// Please note this is the abstract base class. The derived classes available for instantiation are: . + /// + [PersistableModelProxy(typeof(UnknownTargetConfig))] + public abstract partial class TargetConfig : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal TargetConfig() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TargetConfig)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + TargetConfig IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TargetConfig JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TargetConfig)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTargetConfig(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TargetConfig DeserializeTargetConfig(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "AzureOpenAIModel": + return AzureOpenAIModelConfiguration.DeserializeAzureOpenAIModelConfiguration(element, options); + } + } + return UnknownTargetConfig.DeserializeUnknownTargetConfig(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(TargetConfig)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + TargetConfig IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TargetConfig PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTargetConfig(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TargetConfig)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/TargetConfig.cs b/sdk/ai/Azure.AI.Projects/src/Generated/TargetConfig.cs new file mode 100644 index 000000000000..6f9e83c1e67a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/TargetConfig.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// + /// Abstract class for target configuration. + /// Please note this is the abstract base class. The derived classes available for instantiation are: . + /// + public abstract partial class TargetConfig + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Type of the model configuration. + private protected TargetConfig(string @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// Type of the model configuration. + /// Keeps track of any properties unknown to the library. + internal TargetConfig(string @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Type of the model configuration. + internal string Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/TaxonomyCategory.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/TaxonomyCategory.Serialization.cs new file mode 100644 index 000000000000..a676437fd54c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/TaxonomyCategory.Serialization.cs @@ -0,0 +1,229 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Taxonomy category definition. + public partial class TaxonomyCategory : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal TaxonomyCategory() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaxonomyCategory)} does not support writing '{format}' format."); + } + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("riskCategory"u8); + writer.WriteStringValue(RiskCategory.ToString()); + writer.WritePropertyName("subCategories"u8); + writer.WriteStartArray(); + foreach (TaxonomySubCategory item in SubCategories) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsCollectionDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + foreach (var item in Properties) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + TaxonomyCategory IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TaxonomyCategory JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaxonomyCategory)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTaxonomyCategory(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TaxonomyCategory DeserializeTaxonomyCategory(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string name = default; + string description = default; + RiskCategory riskCategory = default; + IList subCategories = default; + IDictionary properties = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("riskCategory"u8)) + { + riskCategory = new RiskCategory(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("subCategories"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(TaxonomySubCategory.DeserializeTaxonomySubCategory(item, options)); + } + subCategories = array; + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + properties = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new TaxonomyCategory( + id, + name, + description, + riskCategory, + subCategories, + properties ?? new ChangeTrackingDictionary(), + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(TaxonomyCategory)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + TaxonomyCategory IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TaxonomyCategory PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTaxonomyCategory(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TaxonomyCategory)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/TaxonomyCategory.cs b/sdk/ai/Azure.AI.Projects/src/Generated/TaxonomyCategory.cs new file mode 100644 index 000000000000..fe435ccbd93e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/TaxonomyCategory.cs @@ -0,0 +1,73 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects +{ + /// Taxonomy category definition. + public partial class TaxonomyCategory + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Unique identifier of the taxonomy category. + /// Name of the taxonomy category. + /// Risk category associated with this taxonomy category. + /// List of taxonomy sub categories. + /// , or is null. + public TaxonomyCategory(string id, string name, RiskCategory riskCategory, IEnumerable subCategories) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(subCategories, nameof(subCategories)); + + Id = id; + Name = name; + RiskCategory = riskCategory; + SubCategories = subCategories.ToList(); + Properties = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Unique identifier of the taxonomy category. + /// Name of the taxonomy category. + /// Description of the taxonomy category. + /// Risk category associated with this taxonomy category. + /// List of taxonomy sub categories. + /// Additional properties for the taxonomy category. + /// Keeps track of any properties unknown to the library. + internal TaxonomyCategory(string id, string name, string description, RiskCategory riskCategory, IList subCategories, IDictionary properties, IDictionary additionalBinaryDataProperties) + { + Id = id; + Name = name; + Description = description; + RiskCategory = riskCategory; + SubCategories = subCategories; + Properties = properties; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Unique identifier of the taxonomy category. + public string Id { get; set; } + + /// Name of the taxonomy category. + public string Name { get; set; } + + /// Description of the taxonomy category. + public string Description { get; set; } + + /// Risk category associated with this taxonomy category. + public RiskCategory RiskCategory { get; set; } + + /// List of taxonomy sub categories. + public IList SubCategories { get; } + + /// Additional properties for the taxonomy category. + public IDictionary Properties { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/TaxonomySubCategory.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/TaxonomySubCategory.Serialization.cs new file mode 100644 index 000000000000..e88f2eaa3e29 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/TaxonomySubCategory.Serialization.cs @@ -0,0 +1,210 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Taxonomy sub-category definition. + public partial class TaxonomySubCategory : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal TaxonomySubCategory() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaxonomySubCategory)} does not support writing '{format}' format."); + } + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + writer.WritePropertyName("enabled"u8); + writer.WriteBooleanValue(Enabled); + if (Optional.IsCollectionDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + foreach (var item in Properties) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + TaxonomySubCategory IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual TaxonomySubCategory JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TaxonomySubCategory)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTaxonomySubCategory(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static TaxonomySubCategory DeserializeTaxonomySubCategory(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string name = default; + string description = default; + bool enabled = default; + IDictionary properties = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("enabled"u8)) + { + enabled = prop.Value.GetBoolean(); + continue; + } + if (prop.NameEquals("properties"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + properties = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new TaxonomySubCategory( + id, + name, + description, + enabled, + properties ?? new ChangeTrackingDictionary(), + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(TaxonomySubCategory)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + TaxonomySubCategory IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual TaxonomySubCategory PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTaxonomySubCategory(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TaxonomySubCategory)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/TaxonomySubCategory.cs b/sdk/ai/Azure.AI.Projects/src/Generated/TaxonomySubCategory.cs new file mode 100644 index 000000000000..a1c88855bd9e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/TaxonomySubCategory.cs @@ -0,0 +1,64 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Taxonomy sub-category definition. + public partial class TaxonomySubCategory + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Unique identifier of the taxonomy sub-category. + /// Name of the taxonomy sub-category. + /// List of taxonomy items under this sub-category. + /// or is null. + public TaxonomySubCategory(string id, string name, bool enabled) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(name, nameof(name)); + + Id = id; + Name = name; + Enabled = enabled; + Properties = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Unique identifier of the taxonomy sub-category. + /// Name of the taxonomy sub-category. + /// Description of the taxonomy sub-category. + /// List of taxonomy items under this sub-category. + /// Additional properties for the taxonomy sub-category. + /// Keeps track of any properties unknown to the library. + internal TaxonomySubCategory(string id, string name, string description, bool enabled, IDictionary properties, IDictionary additionalBinaryDataProperties) + { + Id = id; + Name = name; + Description = description; + Enabled = enabled; + Properties = properties; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Unique identifier of the taxonomy sub-category. + public string Id { get; set; } + + /// Name of the taxonomy sub-category. + public string Name { get; set; } + + /// Description of the taxonomy sub-category. + public string Description { get; set; } + + /// List of taxonomy items under this sub-category. + public bool Enabled { get; set; } + + /// Additional properties for the taxonomy sub-category. + public IDictionary Properties { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ToolDescription.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ToolDescription.Serialization.cs new file mode 100644 index 000000000000..b019b08f950b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ToolDescription.Serialization.cs @@ -0,0 +1,148 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Description of a tool that can be used by an agent. + public partial class ToolDescription : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ToolDescription)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ToolDescription IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ToolDescription JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ToolDescription)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeToolDescription(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ToolDescription DeserializeToolDescription(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string description = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ToolDescription(name, description, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(ToolDescription)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ToolDescription IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ToolDescription PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeToolDescription(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ToolDescription)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ToolDescription.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ToolDescription.cs new file mode 100644 index 000000000000..d634d9cbf85a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ToolDescription.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// Description of a tool that can be used by an agent. + public partial class ToolDescription + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + public ToolDescription() + { + } + + /// Initializes a new instance of . + /// The name of the tool. + /// A brief description of the tool's purpose. + /// Keeps track of any properties unknown to the library. + internal ToolDescription(string name, string description, IDictionary additionalBinaryDataProperties) + { + Name = name; + Description = description; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The name of the tool. + public string Name { get; set; } + + /// A brief description of the tool's purpose. + public string Description { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ToolProjectConnection.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ToolProjectConnection.Serialization.cs new file mode 100644 index 000000000000..9081e1088a81 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ToolProjectConnection.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// A project connection resource. + internal partial class ToolProjectConnection : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal ToolProjectConnection() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ToolProjectConnection)} does not support writing '{format}' format."); + } + writer.WritePropertyName("project_connection_id"u8); + writer.WriteStringValue(ProjectConnectionId); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + ToolProjectConnection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ToolProjectConnection JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ToolProjectConnection)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeToolProjectConnection(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static ToolProjectConnection DeserializeToolProjectConnection(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string projectConnectionId = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("project_connection_id"u8)) + { + projectConnectionId = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ToolProjectConnection(projectConnectionId, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(ToolProjectConnection)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ToolProjectConnection IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ToolProjectConnection PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeToolProjectConnection(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ToolProjectConnection)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ToolProjectConnection.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ToolProjectConnection.cs new file mode 100644 index 000000000000..18fc5e5f43ae --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ToolProjectConnection.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// A project connection resource. + internal partial class ToolProjectConnection + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// A project connection in a ToolProjectConnectionList attached to this tool. + /// is null. + public ToolProjectConnection(string projectConnectionId) + { + Argument.AssertNotNull(projectConnectionId, nameof(projectConnectionId)); + + ProjectConnectionId = projectConnectionId; + } + + /// Initializes a new instance of . + /// A project connection in a ToolProjectConnectionList attached to this tool. + /// Keeps track of any properties unknown to the library. + internal ToolProjectConnection(string projectConnectionId, IDictionary additionalBinaryDataProperties) + { + ProjectConnectionId = projectConnectionId; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// A project connection in a ToolProjectConnectionList attached to this tool. + public string ProjectConnectionId { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ToolType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ToolType.cs new file mode 100644 index 000000000000..17f3707fb9b9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ToolType.cs @@ -0,0 +1,134 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects; + +namespace OpenAI +{ + /// A tool that can be used to generate a response. + internal readonly partial struct ToolType : IEquatable + { + private readonly string _value; + private const string FileSearchValue = "file_search"; + private const string FunctionValue = "function"; + private const string ComputerUsePreviewValue = "computer_use_preview"; + private const string WebSearchPreviewValue = "web_search_preview"; + private const string McpValue = "mcp"; + private const string CodeInterpreterValue = "code_interpreter"; + private const string ImageGenerationValue = "image_generation"; + private const string LocalShellValue = "local_shell"; + private const string BingGroundingValue = "bing_grounding"; + private const string BrowserAutomationPreviewValue = "browser_automation_preview"; + private const string FabricDataagentPreviewValue = "fabric_dataagent_preview"; + private const string SharepointGroundingPreviewValue = "sharepoint_grounding_preview"; + private const string AzureAiSearchValue = "azure_ai_search"; + private const string OpenapiValue = "openapi"; + private const string BingCustomSearchPreviewValue = "bing_custom_search_preview"; + private const string CaptureStructuredOutputsValue = "capture_structured_outputs"; + private const string A2aPreviewValue = "a2a_preview"; + private const string AzureFunctionValue = "azure_function"; + private const string MemorySearchValue = "memory_search"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public ToolType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the FileSearch. + public static ToolType FileSearch { get; } = new ToolType(FileSearchValue); + + /// Gets the Function. + public static ToolType Function { get; } = new ToolType(FunctionValue); + + /// Gets the ComputerUsePreview. + public static ToolType ComputerUsePreview { get; } = new ToolType(ComputerUsePreviewValue); + + /// Gets the WebSearchPreview. + public static ToolType WebSearchPreview { get; } = new ToolType(WebSearchPreviewValue); + + /// Gets the Mcp. + public static ToolType Mcp { get; } = new ToolType(McpValue); + + /// Gets the CodeInterpreter. + public static ToolType CodeInterpreter { get; } = new ToolType(CodeInterpreterValue); + + /// Gets the ImageGeneration. + public static ToolType ImageGeneration { get; } = new ToolType(ImageGenerationValue); + + /// Gets the LocalShell. + public static ToolType LocalShell { get; } = new ToolType(LocalShellValue); + + /// Gets the BingGrounding. + public static ToolType BingGrounding { get; } = new ToolType(BingGroundingValue); + + /// Gets the BrowserAutomationPreview. + public static ToolType BrowserAutomationPreview { get; } = new ToolType(BrowserAutomationPreviewValue); + + /// Gets the FabricDataagentPreview. + public static ToolType FabricDataagentPreview { get; } = new ToolType(FabricDataagentPreviewValue); + + /// Gets the SharepointGroundingPreview. + public static ToolType SharepointGroundingPreview { get; } = new ToolType(SharepointGroundingPreviewValue); + + /// Gets the AzureAiSearch. + public static ToolType AzureAiSearch { get; } = new ToolType(AzureAiSearchValue); + + /// Gets the Openapi. + public static ToolType Openapi { get; } = new ToolType(OpenapiValue); + + /// Gets the BingCustomSearchPreview. + public static ToolType BingCustomSearchPreview { get; } = new ToolType(BingCustomSearchPreviewValue); + + /// Gets the CaptureStructuredOutputs. + public static ToolType CaptureStructuredOutputs { get; } = new ToolType(CaptureStructuredOutputsValue); + + /// Gets the A2aPreview. + public static ToolType A2aPreview { get; } = new ToolType(A2aPreviewValue); + + /// Gets the AzureFunction. + public static ToolType AzureFunction { get; } = new ToolType(AzureFunctionValue); + + /// Gets the MemorySearch. + public static ToolType MemorySearch { get; } = new ToolType(MemorySearchValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(ToolType left, ToolType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(ToolType left, ToolType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator ToolType(string value) => new ToolType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator ToolType?(string value) => value == null ? null : new ToolType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ToolType other && Equals(other); + + /// + public bool Equals(ToolType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/TreatmentEffectType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/TreatmentEffectType.cs new file mode 100644 index 000000000000..c5d435507e07 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/TreatmentEffectType.cs @@ -0,0 +1,82 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// Treatment Effect Type. + public readonly partial struct TreatmentEffectType : IEquatable + { + private readonly string _value; + /// Not enough samples to determine treatment effect. + private const string TooFewSamplesValue = "TooFewSamples"; + /// No significant difference between treatment and baseline. + private const string InconclusiveValue = "Inconclusive"; + /// Indicates the metric changed with statistical significance, but the direction is neutral. + private const string ChangedValue = "Changed"; + /// Indicates the treatment significantly improved the metric compared to baseline. + private const string ImprovedValue = "Improved"; + /// Indicates the treatment significantly degraded the metric compared to baseline. + private const string DegradedValue = "Degraded"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public TreatmentEffectType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Not enough samples to determine treatment effect. + public static TreatmentEffectType TooFewSamples { get; } = new TreatmentEffectType(TooFewSamplesValue); + + /// No significant difference between treatment and baseline. + public static TreatmentEffectType Inconclusive { get; } = new TreatmentEffectType(InconclusiveValue); + + /// Indicates the metric changed with statistical significance, but the direction is neutral. + public static TreatmentEffectType Changed { get; } = new TreatmentEffectType(ChangedValue); + + /// Indicates the treatment significantly improved the metric compared to baseline. + public static TreatmentEffectType Improved { get; } = new TreatmentEffectType(ImprovedValue); + + /// Indicates the treatment significantly degraded the metric compared to baseline. + public static TreatmentEffectType Degraded { get; } = new TreatmentEffectType(DegradedValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(TreatmentEffectType left, TreatmentEffectType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(TreatmentEffectType left, TreatmentEffectType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator TreatmentEffectType(string value) => new TreatmentEffectType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator TreatmentEffectType?(string value) => value == null ? null : new TreatmentEffectType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TreatmentEffectType other && Equals(other); + + /// + public bool Equals(TreatmentEffectType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Trigger.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Trigger.Serialization.cs new file mode 100644 index 000000000000..c7e37c9628a4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Trigger.Serialization.cs @@ -0,0 +1,140 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// + /// Base model for Trigger of the schedule. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// + [PersistableModelProxy(typeof(UnknownTrigger))] + public abstract partial class Trigger : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal Trigger() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Trigger)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + Trigger IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual Trigger JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Trigger)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTrigger(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static Trigger DeserializeTrigger(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "Cron": + return CronTrigger.DeserializeCronTrigger(element, options); + case "Recurrence": + return RecurrenceTrigger.DeserializeRecurrenceTrigger(element, options); + case "OneTime": + return OneTimeTrigger.DeserializeOneTimeTrigger(element, options); + } + } + return UnknownTrigger.DeserializeUnknownTrigger(element, options); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(Trigger)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + Trigger IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual Trigger PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTrigger(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Trigger)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Trigger.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Trigger.cs new file mode 100644 index 000000000000..e814f666e4f2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Trigger.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// + /// Base model for Trigger of the schedule. + /// Please note this is the abstract base class. The derived classes available for instantiation are: , , and . + /// + public abstract partial class Trigger + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// Type of the trigger. + private protected Trigger(TriggerType @type) + { + Type = @type; + } + + /// Initializes a new instance of . + /// Type of the trigger. + /// Keeps track of any properties unknown to the library. + internal Trigger(TriggerType @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Type of the trigger. + internal TriggerType Type { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/TriggerType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/TriggerType.cs new file mode 100644 index 000000000000..3bfc596c9495 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/TriggerType.cs @@ -0,0 +1,72 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.Projects +{ + /// Type of the trigger. + internal readonly partial struct TriggerType : IEquatable + { + private readonly string _value; + /// Cron based trigger. + private const string CronValue = "Cron"; + /// Recurrence based trigger. + private const string RecurrenceValue = "Recurrence"; + /// One-time trigger. + private const string OneTimeValue = "OneTime"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public TriggerType(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Cron based trigger. + public static TriggerType Cron { get; } = new TriggerType(CronValue); + + /// Recurrence based trigger. + public static TriggerType Recurrence { get; } = new TriggerType(RecurrenceValue); + + /// One-time trigger. + public static TriggerType OneTime { get; } = new TriggerType(OneTimeValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(TriggerType left, TriggerType right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(TriggerType left, TriggerType right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator TriggerType(string value) => new TriggerType(value); + + /// Converts a string to a . + /// The value. + public static implicit operator TriggerType?(string value) => value == null ? null : new TriggerType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TriggerType other && Equals(other); + + /// + public bool Equals(TriggerType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownAIProjectDataset.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownAIProjectDataset.cs index 7a2ad9acfd02..a227bcecf9d9 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownAIProjectDataset.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownAIProjectDataset.cs @@ -10,7 +10,7 @@ namespace Azure.AI.Projects internal partial class UnknownAIProjectDataset : AIProjectDataset { /// Initializes a new instance of . - /// URI of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330. + /// URI of the data ([example](https://go.microsoft.com/fwlink/?linkid=2202330)). /// Dataset type. /// Indicates if the dataset holds a reference to the storage, or the dataset manages storage itself. If true, the underlying data will not be deleted when the dataset version is deleted. /// The Azure Storage Account connection name. Required if startPendingUploadVersion was not called before creating the Dataset. diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownAgentDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownAgentDefinition.Serialization.cs new file mode 100644 index 000000000000..ab6ca049d6c9 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownAgentDefinition.Serialization.cs @@ -0,0 +1,132 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + internal partial class UnknownAgentDefinition : InternalAgentDefinition, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownAgentDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAgentDefinition)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalAgentDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalAgentDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAgentDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAgentDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownAgentDefinition DeserializeUnknownAgentDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentKind kind = default; + RaiConfig raiConfig = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("kind"u8)) + { + kind = new AgentKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("rai_config"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + raiConfig = RaiConfig.DeserializeRaiConfig(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownAgentDefinition(kind, raiConfig, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalAgentDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalAgentDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalAgentDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalAgentDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAgentDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownAgentDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownAgentDefinition.cs new file mode 100644 index 000000000000..c4d1ab50cc97 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownAgentDefinition.cs @@ -0,0 +1,20 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + internal partial class UnknownAgentDefinition : InternalAgentDefinition + { + /// Initializes a new instance of . + /// + /// Configuration for Responsible AI (RAI) content filtering and safety features. + /// Keeps track of any properties unknown to the library. + internal UnknownAgentDefinition(AgentKind kind, RaiConfig raiConfig, IDictionary additionalBinaryDataProperties) : base(kind != default ? kind : "unknown", raiConfig, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownAnnotation.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownAnnotation.Serialization.cs new file mode 100644 index 000000000000..02880e1ec4ef --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownAnnotation.Serialization.cs @@ -0,0 +1,123 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class UnknownAnnotation : InternalAnnotation, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownAnnotation() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAnnotation)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalAnnotation JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalAnnotation)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalAnnotation(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownAnnotation DeserializeUnknownAnnotation(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AnnotationType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new AnnotationType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownAnnotation(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalAnnotation)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalAnnotation PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalAnnotation)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownAnnotation.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownAnnotation.cs new file mode 100644 index 000000000000..3d6ece197010 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownAnnotation.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class UnknownAnnotation : InternalAnnotation + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal UnknownAnnotation(AnnotationType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownCodeInterpreterOutput.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownCodeInterpreterOutput.Serialization.cs new file mode 100644 index 000000000000..6500fe748cd0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownCodeInterpreterOutput.Serialization.cs @@ -0,0 +1,123 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class UnknownCodeInterpreterOutput : InternalCodeInterpreterOutput, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownCodeInterpreterOutput() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutput)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalCodeInterpreterOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalCodeInterpreterOutput JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutput)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalCodeInterpreterOutput(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownCodeInterpreterOutput DeserializeUnknownCodeInterpreterOutput(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CodeInterpreterOutputType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToCodeInterpreterOutputType(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownCodeInterpreterOutput(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutput)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalCodeInterpreterOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalCodeInterpreterOutput PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalCodeInterpreterOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalCodeInterpreterOutput)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownCodeInterpreterOutput.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownCodeInterpreterOutput.cs new file mode 100644 index 000000000000..afacd4028ae6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownCodeInterpreterOutput.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class UnknownCodeInterpreterOutput : InternalCodeInterpreterOutput + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal UnknownCodeInterpreterOutput(CodeInterpreterOutputType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownComputerAction.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownComputerAction.Serialization.cs new file mode 100644 index 000000000000..6a60f89ffce5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownComputerAction.Serialization.cs @@ -0,0 +1,123 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class UnknownComputerAction : InternalComputerAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownComputerAction() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerAction)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalComputerAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerAction)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerAction(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownComputerAction DeserializeUnknownComputerAction(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComputerActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToComputerActionType(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownComputerAction(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerAction)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalComputerAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerAction)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownComputerAction.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownComputerAction.cs new file mode 100644 index 000000000000..13160759b2fd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownComputerAction.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class UnknownComputerAction : InternalComputerAction + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal UnknownComputerAction(ComputerActionType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownComputerToolCallOutputItemOutput.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownComputerToolCallOutputItemOutput.Serialization.cs new file mode 100644 index 000000000000..ae4f66df8ba8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownComputerToolCallOutputItemOutput.Serialization.cs @@ -0,0 +1,123 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class UnknownComputerToolCallOutputItemOutput : InternalComputerToolCallOutputItemOutput, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownComputerToolCallOutputItemOutput() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemOutput)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalComputerToolCallOutputItemOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalComputerToolCallOutputItemOutput JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemOutput)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalComputerToolCallOutputItemOutput(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownComputerToolCallOutputItemOutput DeserializeUnknownComputerToolCallOutputItemOutput(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ComputerToolCallOutputItemOutputType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ComputerToolCallOutputItemOutputType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownComputerToolCallOutputItemOutput(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemOutput)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalComputerToolCallOutputItemOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalComputerToolCallOutputItemOutput PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalComputerToolCallOutputItemOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalComputerToolCallOutputItemOutput)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownComputerToolCallOutputItemOutput.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownComputerToolCallOutputItemOutput.cs new file mode 100644 index 000000000000..0ca2f89e123e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownComputerToolCallOutputItemOutput.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class UnknownComputerToolCallOutputItemOutput : InternalComputerToolCallOutputItemOutput + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal UnknownComputerToolCallOutputItemOutput(ComputerToolCallOutputItemOutputType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownEvaluationRuleAction.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownEvaluationRuleAction.Serialization.cs new file mode 100644 index 000000000000..6d90bf77c05c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownEvaluationRuleAction.Serialization.cs @@ -0,0 +1,122 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + internal partial class UnknownEvaluationRuleAction : EvaluationRuleAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownEvaluationRuleAction() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationRuleAction)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + EvaluationRuleAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override EvaluationRuleAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationRuleAction)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEvaluationRuleAction(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownEvaluationRuleAction DeserializeUnknownEvaluationRuleAction(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + EvaluationRuleActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new EvaluationRuleActionType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownEvaluationRuleAction(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(EvaluationRuleAction)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + EvaluationRuleAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override EvaluationRuleAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEvaluationRuleAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EvaluationRuleAction)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownEvaluationRuleAction.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownEvaluationRuleAction.cs new file mode 100644 index 000000000000..53a37ee6ff97 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownEvaluationRuleAction.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + internal partial class UnknownEvaluationRuleAction : EvaluationRuleAction + { + /// Initializes a new instance of . + /// Type of the evaluation action. + /// Keeps track of any properties unknown to the library. + internal UnknownEvaluationRuleAction(EvaluationRuleActionType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownEvaluationTaxonomyInput.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownEvaluationTaxonomyInput.Serialization.cs new file mode 100644 index 000000000000..f5540a95c639 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownEvaluationTaxonomyInput.Serialization.cs @@ -0,0 +1,122 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + internal partial class UnknownEvaluationTaxonomyInput : EvaluationTaxonomyInput, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownEvaluationTaxonomyInput() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationTaxonomyInput)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + EvaluationTaxonomyInput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override EvaluationTaxonomyInput JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluationTaxonomyInput)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEvaluationTaxonomyInput(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownEvaluationTaxonomyInput DeserializeUnknownEvaluationTaxonomyInput(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + EvaluationTaxonomyInputType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new EvaluationTaxonomyInputType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownEvaluationTaxonomyInput(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(EvaluationTaxonomyInput)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + EvaluationTaxonomyInput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override EvaluationTaxonomyInput PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEvaluationTaxonomyInput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EvaluationTaxonomyInput)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownEvaluationTaxonomyInput.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownEvaluationTaxonomyInput.cs new file mode 100644 index 000000000000..c4bbe2fbc616 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownEvaluationTaxonomyInput.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + internal partial class UnknownEvaluationTaxonomyInput : EvaluationTaxonomyInput + { + /// Initializes a new instance of . + /// Input type of the evaluation taxonomy. + /// Keeps track of any properties unknown to the library. + internal UnknownEvaluationTaxonomyInput(EvaluationTaxonomyInputType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownEvaluatorDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownEvaluatorDefinition.Serialization.cs new file mode 100644 index 000000000000..a1bae71f4525 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownEvaluatorDefinition.Serialization.cs @@ -0,0 +1,157 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + internal partial class UnknownEvaluatorDefinition : EvaluatorDefinition, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownEvaluatorDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluatorDefinition)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + EvaluatorDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override EvaluatorDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EvaluatorDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEvaluatorDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownEvaluatorDefinition DeserializeUnknownEvaluatorDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + EvaluatorDefinitionType @type = default; + BinaryData initParameters = default; + BinaryData dataSchema = default; + IDictionary metrics = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new EvaluatorDefinitionType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("init_parameters"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + initParameters = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("data_schema"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dataSchema = BinaryData.FromString(prop.Value.GetRawText()); + continue; + } + if (prop.NameEquals("metrics"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + dictionary.Add(prop0.Name, EvaluatorMetric.DeserializeEvaluatorMetric(prop0.Value, options)); + } + metrics = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownEvaluatorDefinition(@type, initParameters, dataSchema, metrics ?? new ChangeTrackingDictionary(), additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(EvaluatorDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + EvaluatorDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override EvaluatorDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeEvaluatorDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EvaluatorDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownEvaluatorDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownEvaluatorDefinition.cs new file mode 100644 index 000000000000..952e754047b4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownEvaluatorDefinition.cs @@ -0,0 +1,22 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + internal partial class UnknownEvaluatorDefinition : EvaluatorDefinition + { + /// Initializes a new instance of . + /// The type of evaluator definition. + /// The JSON schema (Draft 2020-12) for the evaluator's input parameters. This includes parameters like type, properties, required. + /// The JSON schema (Draft 2020-12) for the evaluator's input data. This includes parameters like type, properties, required. + /// List of output metrics produced by this evaluator. + /// Keeps track of any properties unknown to the library. + internal UnknownEvaluatorDefinition(EvaluatorDefinitionType @type, BinaryData initParameters, BinaryData dataSchema, IDictionary metrics, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", initParameters, dataSchema, metrics, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownHostedAgentDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownHostedAgentDefinition.Serialization.cs new file mode 100644 index 000000000000..ad6aac7d9f44 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownHostedAgentDefinition.Serialization.cs @@ -0,0 +1,200 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + internal partial class UnknownHostedAgentDefinition : HostedAgentDefinition, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownHostedAgentDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(HostedAgentDefinition)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + HostedAgentDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (UnknownHostedAgentDefinition)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalAgentDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(HostedAgentDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeHostedAgentDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownHostedAgentDefinition DeserializeUnknownHostedAgentDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentKind kind = default; + RaiConfig raiConfig = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList tools = default; + IList containerProtocolVersions = default; + string cpu = default; + string memory = default; + IDictionary environmentVariables = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("kind"u8)) + { + kind = new AgentKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("rai_config"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + raiConfig = RaiConfig.DeserializeRaiConfig(prop.Value, options); + continue; + } + if (prop.NameEquals("tools"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(InternalTool.DeserializeInternalTool(item, options)); + } + tools = array; + continue; + } + if (prop.NameEquals("container_protocol_versions"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(ProtocolVersionRecord.DeserializeProtocolVersionRecord(item, options)); + } + containerProtocolVersions = array; + continue; + } + if (prop.NameEquals("cpu"u8)) + { + cpu = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("memory"u8)) + { + memory = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("environment_variables"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + environmentVariables = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownHostedAgentDefinition( + kind, + raiConfig, + additionalBinaryDataProperties, + tools ?? new ChangeTrackingList(), + containerProtocolVersions, + cpu, + memory, + environmentVariables ?? new ChangeTrackingDictionary()); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(HostedAgentDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + HostedAgentDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (UnknownHostedAgentDefinition)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalAgentDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeHostedAgentDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(HostedAgentDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownHostedAgentDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownHostedAgentDefinition.cs new file mode 100644 index 000000000000..7a316399d8a2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownHostedAgentDefinition.cs @@ -0,0 +1,28 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + internal partial class UnknownHostedAgentDefinition : HostedAgentDefinition + { + /// Initializes a new instance of . + /// + /// Configuration for Responsible AI (RAI) content filtering and safety features. + /// Keeps track of any properties unknown to the library. + /// + /// An array of tools the hosted agent's model may call while generating a response. You + /// can specify which tool to use by setting the `tool_choice` parameter. + /// + /// The protocols that the agent supports for ingress communication of the containers. + /// The CPU configuration for the hosted agent. + /// The memory configuration for the hosted agent. + /// Environment variables to set in the hosted agent container. + internal UnknownHostedAgentDefinition(AgentKind kind, RaiConfig raiConfig, IDictionary additionalBinaryDataProperties, IList tools, IList containerProtocolVersions, string cpu, string memory, IDictionary environmentVariables) : base(kind != default ? kind : "unknown", raiConfig, additionalBinaryDataProperties, tools, containerProtocolVersions, cpu, memory, environmentVariables) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInsightRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInsightRequest.Serialization.cs new file mode 100644 index 000000000000..f14a2098fc02 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInsightRequest.Serialization.cs @@ -0,0 +1,122 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + internal partial class UnknownInsightRequest : InsightRequest, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownInsightRequest() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InsightRequest)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InsightRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InsightRequest JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InsightRequest)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInsightRequest(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownInsightRequest DeserializeUnknownInsightRequest(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InsightType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InsightType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownInsightRequest(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InsightRequest)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InsightRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InsightRequest PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInsightRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InsightRequest)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInsightRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInsightRequest.cs new file mode 100644 index 000000000000..dc0637633c92 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInsightRequest.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + internal partial class UnknownInsightRequest : InsightRequest + { + /// Initializes a new instance of . + /// The type of request. + /// Keeps track of any properties unknown to the library. + internal UnknownInsightRequest(InsightType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInsightResult.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInsightResult.Serialization.cs new file mode 100644 index 000000000000..fb7eb6695004 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInsightResult.Serialization.cs @@ -0,0 +1,122 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + internal partial class UnknownInsightResult : InsightResult, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownInsightResult() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InsightResult)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InsightResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InsightResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InsightResult)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInsightResult(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownInsightResult DeserializeUnknownInsightResult(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + InsightType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new InsightType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownInsightResult(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InsightResult)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InsightResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InsightResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInsightResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InsightResult)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInsightResult.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInsightResult.cs new file mode 100644 index 000000000000..454718e4204d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInsightResult.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + internal partial class UnknownInsightResult : InsightResult + { + /// Initializes a new instance of . + /// The type of insights result. + /// Keeps track of any properties unknown to the library. + internal UnknownInsightResult(InsightType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInsightSample.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInsightSample.Serialization.cs new file mode 100644 index 000000000000..88748283928d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInsightSample.Serialization.cs @@ -0,0 +1,164 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + internal partial class UnknownInsightSample : InsightSample, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownInsightSample() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InsightSample)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InsightSample IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InsightSample JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InsightSample)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInsightSample(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownInsightSample DeserializeUnknownInsightSample(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + SampleType @type = default; + IDictionary features = default; + IDictionary correlationInfo = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("id"u8)) + { + id = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("type"u8)) + { + @type = new SampleType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("features"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + features = dictionary; + continue; + } + if (prop.NameEquals("correlationInfo"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, BinaryData.FromString(prop0.Value.GetRawText())); + } + } + correlationInfo = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownInsightSample(id, @type, features, correlationInfo, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InsightSample)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InsightSample IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InsightSample PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInsightSample(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InsightSample)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInsightSample.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInsightSample.cs new file mode 100644 index 000000000000..fac9d2f4132f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownInsightSample.cs @@ -0,0 +1,22 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + internal partial class UnknownInsightSample : InsightSample + { + /// Initializes a new instance of . + /// The unique identifier for the analysis sample. + /// Sample type. + /// Features to help with additional filtering of data in UX. + /// Info about the correlation for the analysis sample. + /// Keeps track of any properties unknown to the library. + internal UnknownInsightSample(string id, SampleType @type, IDictionary features, IDictionary correlationInfo, IDictionary additionalBinaryDataProperties) : base(id, @type != default ? @type : "unknown", features, correlationInfo, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownItemContent.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownItemContent.Serialization.cs new file mode 100644 index 000000000000..8eea4c65d331 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownItemContent.Serialization.cs @@ -0,0 +1,123 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class UnknownItemContent : InternalItemContent, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownItemContent() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContent)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalItemContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemContent JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemContent)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalItemContent(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownItemContent DeserializeUnknownItemContent(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemContentType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToItemContentType(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownItemContent(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalItemContent)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalItemContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemContent PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalItemContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalItemContent)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownItemContent.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownItemContent.cs new file mode 100644 index 000000000000..a5cc285369fd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownItemContent.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class UnknownItemContent : InternalItemContent + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal UnknownItemContent(ItemContentType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownItemParam.Serialization.cs new file mode 100644 index 000000000000..8c69b91cfe55 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownItemParam.Serialization.cs @@ -0,0 +1,123 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class UnknownItemParam : InternalItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownItemParam DeserializeUnknownItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ItemType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownItemParam(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownItemParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownItemParam.cs new file mode 100644 index 000000000000..2474168ae931 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownItemParam.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class UnknownItemParam : InternalItemParam + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal UnknownItemParam(ItemType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownLocation.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownLocation.Serialization.cs new file mode 100644 index 000000000000..35b4a8b5cc4d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownLocation.Serialization.cs @@ -0,0 +1,123 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class UnknownLocation : InternalLocation, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownLocation() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalLocation)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalLocation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalLocation JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalLocation)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalLocation(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownLocation DeserializeUnknownLocation(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + LocationType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new LocationType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownLocation(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalLocation)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalLocation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalLocation PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalLocation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalLocation)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownLocation.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownLocation.cs new file mode 100644 index 000000000000..6f998e65800f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownLocation.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class UnknownLocation : InternalLocation + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal UnknownLocation(LocationType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMemoryItem.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMemoryItem.Serialization.cs new file mode 100644 index 000000000000..376a270f03c8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMemoryItem.Serialization.cs @@ -0,0 +1,152 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + internal partial class UnknownMemoryItem : MemoryItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownMemoryItem() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryItem)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemoryItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override MemoryItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryItem)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemoryItem(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownMemoryItem DeserializeUnknownMemoryItem(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string memoryId = default; + DateTimeOffset updatedAt = default; + string scope = default; + string content = default; + MemoryItemKind kind = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("memory_id"u8)) + { + memoryId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("updated_at"u8)) + { + updatedAt = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64()); + continue; + } + if (prop.NameEquals("scope"u8)) + { + scope = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("content"u8)) + { + content = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("kind"u8)) + { + kind = new MemoryItemKind(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownMemoryItem( + memoryId, + updatedAt, + scope, + content, + kind, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(MemoryItem)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemoryItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override MemoryItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemoryItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemoryItem)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMemoryItem.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMemoryItem.cs new file mode 100644 index 000000000000..4b6a78143027 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMemoryItem.cs @@ -0,0 +1,23 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + internal partial class UnknownMemoryItem : MemoryItem + { + /// Initializes a new instance of . + /// The unique ID of the memory item. + /// The last update time of the memory item. + /// The namespace that logically groups and isolates memories, such as a user ID. + /// The content of the memory. + /// The kind of the memory item. + /// Keeps track of any properties unknown to the library. + internal UnknownMemoryItem(string memoryId, DateTimeOffset updatedAt, string scope, string content, MemoryItemKind kind, IDictionary additionalBinaryDataProperties) : base(memoryId, updatedAt, scope, content, kind != default ? kind : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMemoryStoreDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMemoryStoreDefinition.Serialization.cs new file mode 100644 index 000000000000..651d4dab8381 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMemoryStoreDefinition.Serialization.cs @@ -0,0 +1,122 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + internal partial class UnknownMemoryStoreDefinition : MemoryStoreDefinition, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownMemoryStoreDefinition() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryStoreDefinition)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + MemoryStoreDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override MemoryStoreDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MemoryStoreDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMemoryStoreDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownMemoryStoreDefinition DeserializeUnknownMemoryStoreDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MemoryStoreKind kind = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("kind"u8)) + { + kind = new MemoryStoreKind(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownMemoryStoreDefinition(kind, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(MemoryStoreDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + MemoryStoreDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override MemoryStoreDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeMemoryStoreDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MemoryStoreDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMemoryStoreDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMemoryStoreDefinition.cs new file mode 100644 index 000000000000..dc28679f285c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownMemoryStoreDefinition.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + internal partial class UnknownMemoryStoreDefinition : MemoryStoreDefinition + { + /// Initializes a new instance of . + /// The kind of the memory store. + /// Keeps track of any properties unknown to the library. + internal UnknownMemoryStoreDefinition(MemoryStoreKind kind, IDictionary additionalBinaryDataProperties) : base(kind != default ? kind : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownOpenApiAuthDetails.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownOpenApiAuthDetails.Serialization.cs new file mode 100644 index 000000000000..fb8818ac5ba2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownOpenApiAuthDetails.Serialization.cs @@ -0,0 +1,122 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + internal partial class UnknownOpenApiAuthDetails : OpenApiAuthDetails, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownOpenApiAuthDetails() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiAuthDetails)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + OpenApiAuthDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override OpenApiAuthDetails JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OpenApiAuthDetails)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOpenApiAuthDetails(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownOpenApiAuthDetails DeserializeUnknownOpenApiAuthDetails(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + OpenApiAuthType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new OpenApiAuthType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownOpenApiAuthDetails(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(OpenApiAuthDetails)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + OpenApiAuthDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override OpenApiAuthDetails PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeOpenApiAuthDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OpenApiAuthDetails)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownOpenApiAuthDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownOpenApiAuthDetails.cs new file mode 100644 index 000000000000..d8a1d5ea9d69 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownOpenApiAuthDetails.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + internal partial class UnknownOpenApiAuthDetails : OpenApiAuthDetails + { + /// Initializes a new instance of . + /// The type of authentication, must be anonymous/project_connection/managed_identity. + /// Keeps track of any properties unknown to the library. + internal UnknownOpenApiAuthDetails(OpenApiAuthType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownReasoningItemSummaryPart.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownReasoningItemSummaryPart.Serialization.cs new file mode 100644 index 000000000000..65eb9e519a81 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownReasoningItemSummaryPart.Serialization.cs @@ -0,0 +1,123 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class UnknownReasoningItemSummaryPart : InternalReasoningItemSummaryPart, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownReasoningItemSummaryPart() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalReasoningItemSummaryPart)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalReasoningItemSummaryPart IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalReasoningItemSummaryPart JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalReasoningItemSummaryPart)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalReasoningItemSummaryPart(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownReasoningItemSummaryPart DeserializeUnknownReasoningItemSummaryPart(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ReasoningItemSummaryPartType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ReasoningItemSummaryPartType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownReasoningItemSummaryPart(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalReasoningItemSummaryPart)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalReasoningItemSummaryPart IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalReasoningItemSummaryPart PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalReasoningItemSummaryPart(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalReasoningItemSummaryPart)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownReasoningItemSummaryPart.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownReasoningItemSummaryPart.cs new file mode 100644 index 000000000000..9695a3c70b5e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownReasoningItemSummaryPart.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class UnknownReasoningItemSummaryPart : InternalReasoningItemSummaryPart + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal UnknownReasoningItemSummaryPart(ReasoningItemSummaryPartType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRecurrenceSchedule.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRecurrenceSchedule.Serialization.cs new file mode 100644 index 000000000000..beeab2abe0c8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRecurrenceSchedule.Serialization.cs @@ -0,0 +1,122 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + internal partial class UnknownRecurrenceSchedule : RecurrenceSchedule, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownRecurrenceSchedule() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RecurrenceSchedule)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + RecurrenceSchedule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override RecurrenceSchedule JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RecurrenceSchedule)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRecurrenceSchedule(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownRecurrenceSchedule DeserializeUnknownRecurrenceSchedule(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RecurrenceType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new RecurrenceType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownRecurrenceSchedule(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(RecurrenceSchedule)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + RecurrenceSchedule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override RecurrenceSchedule PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeRecurrenceSchedule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RecurrenceSchedule)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRecurrenceSchedule.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRecurrenceSchedule.cs new file mode 100644 index 000000000000..7472dfe8ad79 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownRecurrenceSchedule.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + internal partial class UnknownRecurrenceSchedule : RecurrenceSchedule + { + /// Initializes a new instance of . + /// Recurrence type for the recurrence schedule. + /// Keeps track of any properties unknown to the library. + internal UnknownRecurrenceSchedule(RecurrenceType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownResponseTextFormatConfiguration.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownResponseTextFormatConfiguration.Serialization.cs new file mode 100644 index 000000000000..f45b9bbcc798 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownResponseTextFormatConfiguration.Serialization.cs @@ -0,0 +1,123 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class UnknownResponseTextFormatConfiguration : InternalResponseTextFormatConfiguration, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownResponseTextFormatConfiguration() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfiguration)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponseTextFormatConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalResponseTextFormatConfiguration JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfiguration)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponseTextFormatConfiguration(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownResponseTextFormatConfiguration DeserializeUnknownResponseTextFormatConfiguration(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResponseTextFormatConfigurationType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ResponseTextFormatConfigurationType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownResponseTextFormatConfiguration(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfiguration)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponseTextFormatConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalResponseTextFormatConfiguration PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponseTextFormatConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponseTextFormatConfiguration)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownResponseTextFormatConfiguration.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownResponseTextFormatConfiguration.cs new file mode 100644 index 000000000000..552f7432b6b5 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownResponseTextFormatConfiguration.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class UnknownResponseTextFormatConfiguration : InternalResponseTextFormatConfiguration + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal UnknownResponseTextFormatConfiguration(ResponseTextFormatConfigurationType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownResponsesMessageItemParam.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownResponsesMessageItemParam.Serialization.cs new file mode 100644 index 000000000000..7bf87a631977 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownResponsesMessageItemParam.Serialization.cs @@ -0,0 +1,129 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class UnknownResponsesMessageItemParam : InternalResponsesMessageItemParam, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownResponsesMessageItemParam() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesMessageItemParam)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalResponsesMessageItemParam IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (UnknownResponsesMessageItemParam)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalItemParam JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalResponsesMessageItemParam)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalResponsesMessageItemParam(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownResponsesMessageItemParam DeserializeUnknownResponsesMessageItemParam(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ItemType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ResponsesMessageRole role = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ItemType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("role"u8)) + { + role = new ResponsesMessageRole(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownResponsesMessageItemParam(@type, additionalBinaryDataProperties, role); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalResponsesMessageItemParam)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalResponsesMessageItemParam IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (UnknownResponsesMessageItemParam)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalItemParam PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalResponsesMessageItemParam(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalResponsesMessageItemParam)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownResponsesMessageItemParam.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownResponsesMessageItemParam.cs new file mode 100644 index 000000000000..607d0a86a82e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownResponsesMessageItemParam.cs @@ -0,0 +1,20 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class UnknownResponsesMessageItemParam : InternalResponsesMessageItemParam + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + /// The role associated with the message. + internal UnknownResponsesMessageItemParam(ItemType @type, IDictionary additionalBinaryDataProperties, ResponsesMessageRole role) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties, role != default ? role : "unknown") + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownScheduleTask.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownScheduleTask.Serialization.cs new file mode 100644 index 000000000000..4bbca8de2f96 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownScheduleTask.Serialization.cs @@ -0,0 +1,144 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + internal partial class UnknownScheduleTask : ScheduleTask, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownScheduleTask() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ScheduleTask)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + ScheduleTask IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override ScheduleTask JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ScheduleTask)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeScheduleTask(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownScheduleTask DeserializeUnknownScheduleTask(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ScheduleTaskType @type = default; + IDictionary configuration = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ScheduleTaskType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("configuration"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + configuration = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownScheduleTask(@type, configuration ?? new ChangeTrackingDictionary(), additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(ScheduleTask)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + ScheduleTask IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override ScheduleTask PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeScheduleTask(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ScheduleTask)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownScheduleTask.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownScheduleTask.cs new file mode 100644 index 000000000000..673b96f4d18b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownScheduleTask.cs @@ -0,0 +1,20 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + internal partial class UnknownScheduleTask : ScheduleTask + { + /// Initializes a new instance of . + /// Type of the task. + /// Configuration for the task. + /// Keeps track of any properties unknown to the library. + internal UnknownScheduleTask(ScheduleTaskType @type, IDictionary configuration, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", configuration, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTarget.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTarget.Serialization.cs new file mode 100644 index 000000000000..9e4194bd4e11 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTarget.Serialization.cs @@ -0,0 +1,122 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + internal partial class UnknownTarget : Target, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownTarget() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Target)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + Target IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override Target JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Target)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTarget(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownTarget DeserializeUnknownTarget(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = "unknown"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownTarget(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(Target)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + Target IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override Target PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTarget(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Target)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTarget.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTarget.cs new file mode 100644 index 000000000000..f59993c65331 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTarget.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + internal partial class UnknownTarget : Target + { + /// Initializes a new instance of . + /// The type of target. + /// Keeps track of any properties unknown to the library. + internal UnknownTarget(string @type, IDictionary additionalBinaryDataProperties) : base(@type ?? "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTargetConfig.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTargetConfig.Serialization.cs new file mode 100644 index 000000000000..d6b08fe64c79 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTargetConfig.Serialization.cs @@ -0,0 +1,122 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + internal partial class UnknownTargetConfig : TargetConfig, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownTargetConfig() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TargetConfig)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + TargetConfig IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override TargetConfig JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TargetConfig)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTargetConfig(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownTargetConfig DeserializeUnknownTargetConfig(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = "unknown"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownTargetConfig(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(TargetConfig)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + TargetConfig IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override TargetConfig PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTargetConfig(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TargetConfig)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTargetConfig.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTargetConfig.cs new file mode 100644 index 000000000000..1bf533214a13 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTargetConfig.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + internal partial class UnknownTargetConfig : TargetConfig + { + /// Initializes a new instance of . + /// Type of the model configuration. + /// Keeps track of any properties unknown to the library. + internal UnknownTargetConfig(string @type, IDictionary additionalBinaryDataProperties) : base(@type ?? "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTool.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTool.Serialization.cs new file mode 100644 index 000000000000..208d68755af2 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTool.Serialization.cs @@ -0,0 +1,123 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class UnknownTool : InternalTool, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownTool() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalTool)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalTool IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalTool JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalTool)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalTool(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownTool DeserializeUnknownTool(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ToolType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new ToolType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownTool(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalTool)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalTool IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalTool PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalTool(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalTool)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTool.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTool.cs new file mode 100644 index 000000000000..d104f28c3662 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTool.cs @@ -0,0 +1,20 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class UnknownTool : InternalTool + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal UnknownTool(ToolType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTrigger.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTrigger.Serialization.cs new file mode 100644 index 000000000000..7258a66ed4d4 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTrigger.Serialization.cs @@ -0,0 +1,122 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + internal partial class UnknownTrigger : Trigger, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownTrigger() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Trigger)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + Trigger IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override Trigger JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Trigger)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTrigger(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownTrigger DeserializeUnknownTrigger(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TriggerType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new TriggerType(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownTrigger(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(Trigger)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + Trigger IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override Trigger PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeTrigger(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Trigger)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTrigger.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTrigger.cs new file mode 100644 index 000000000000..3fa98aa058fd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownTrigger.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + internal partial class UnknownTrigger : Trigger + { + /// Initializes a new instance of . + /// Type of the trigger. + /// Keeps track of any properties unknown to the library. + internal UnknownTrigger(TriggerType @type, IDictionary additionalBinaryDataProperties) : base(@type != default ? @type : "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownWebSearchAction.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownWebSearchAction.Serialization.cs new file mode 100644 index 000000000000..9bf65cefd183 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownWebSearchAction.Serialization.cs @@ -0,0 +1,123 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal partial class UnknownWebSearchAction : InternalWebSearchAction, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UnknownWebSearchAction() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchAction)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + InternalWebSearchAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalWebSearchAction JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InternalWebSearchAction)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInternalWebSearchAction(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UnknownWebSearchAction DeserializeUnknownWebSearchAction(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + WebSearchActionType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString().ToWebSearchActionType(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UnknownWebSearchAction(@type, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(InternalWebSearchAction)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + InternalWebSearchAction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalWebSearchAction PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeInternalWebSearchAction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InternalWebSearchAction)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UnknownWebSearchAction.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownWebSearchAction.cs new file mode 100644 index 000000000000..6414375bba85 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UnknownWebSearchAction.cs @@ -0,0 +1,19 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace OpenAI +{ + internal partial class UnknownWebSearchAction : InternalWebSearchAction + { + /// Initializes a new instance of . + /// + /// Keeps track of any properties unknown to the library. + internal UnknownWebSearchAction(WebSearchActionType @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateMemoryStoreRequest.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UpdateMemoryStoreRequest.Serialization.cs new file mode 100644 index 000000000000..00c590ece2ca --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UpdateMemoryStoreRequest.Serialization.cs @@ -0,0 +1,185 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + internal partial class UpdateMemoryStoreRequest : IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateMemoryStoreRequest)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + UpdateMemoryStoreRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual UpdateMemoryStoreRequest JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateMemoryStoreRequest)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUpdateMemoryStoreRequest(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UpdateMemoryStoreRequest DeserializeUpdateMemoryStoreRequest(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string description = default; + IDictionary metadata = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("description"u8)) + { + description = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("metadata"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var prop0 in prop.Value.EnumerateObject()) + { + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } + } + metadata = dictionary; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UpdateMemoryStoreRequest(description, metadata ?? new ChangeTrackingDictionary(), additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(UpdateMemoryStoreRequest)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + UpdateMemoryStoreRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual UpdateMemoryStoreRequest PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeUpdateMemoryStoreRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UpdateMemoryStoreRequest)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(UpdateMemoryStoreRequest updateMemoryStoreRequest) + { + if (updateMemoryStoreRequest == null) + { + return null; + } + return BinaryContent.Create(updateMemoryStoreRequest, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateMemoryStoreRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UpdateMemoryStoreRequest.cs new file mode 100644 index 000000000000..2582837ebe2c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UpdateMemoryStoreRequest.cs @@ -0,0 +1,27 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + internal partial class UpdateMemoryStoreRequest + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + internal UpdateMemoryStoreRequest() + { + Metadata = new ChangeTrackingDictionary(); + } + + /// A human-readable description of the memory store. + public string Description { get; } + + /// Arbitrary key-value metadata to associate with the memory store. + public IDictionary Metadata { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UserProfileMemoryItem.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UserProfileMemoryItem.Serialization.cs new file mode 100644 index 000000000000..4e909c0ef446 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UserProfileMemoryItem.Serialization.cs @@ -0,0 +1,153 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// A memory item specifically containing user profile information extracted from conversations, such as preferences, interests, and personal details. + public partial class UserProfileMemoryItem : MemoryItem, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal UserProfileMemoryItem() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UserProfileMemoryItem)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + } + + /// The JSON reader. + /// The client options for reading and writing models. + UserProfileMemoryItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (UserProfileMemoryItem)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override MemoryItem JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UserProfileMemoryItem)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUserProfileMemoryItem(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static UserProfileMemoryItem DeserializeUserProfileMemoryItem(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string memoryId = default; + DateTimeOffset updatedAt = default; + string scope = default; + string content = default; + MemoryItemKind kind = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("memory_id"u8)) + { + memoryId = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("updated_at"u8)) + { + updatedAt = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64()); + continue; + } + if (prop.NameEquals("scope"u8)) + { + scope = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("content"u8)) + { + content = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("kind"u8)) + { + kind = new MemoryItemKind(prop.Value.GetString()); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new UserProfileMemoryItem( + memoryId, + updatedAt, + scope, + content, + kind, + additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(UserProfileMemoryItem)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + UserProfileMemoryItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (UserProfileMemoryItem)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override MemoryItem PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeUserProfileMemoryItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UserProfileMemoryItem)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UserProfileMemoryItem.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UserProfileMemoryItem.cs new file mode 100644 index 000000000000..655434d2af21 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UserProfileMemoryItem.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// A memory item specifically containing user profile information extracted from conversations, such as preferences, interests, and personal details. + public partial class UserProfileMemoryItem : MemoryItem + { + /// Initializes a new instance of . + /// The unique ID of the memory item. + /// The last update time of the memory item. + /// The namespace that logically groups and isolates memories, such as a user ID. + /// The content of the memory. + /// , or is null. + public UserProfileMemoryItem(string memoryId, DateTimeOffset updatedAt, string scope, string content) : base(memoryId, updatedAt, scope, content, MemoryItemKind.UserProfile) + { + Argument.AssertNotNull(memoryId, nameof(memoryId)); + Argument.AssertNotNull(scope, nameof(scope)); + Argument.AssertNotNull(content, nameof(content)); + + } + + /// Initializes a new instance of . + /// The unique ID of the memory item. + /// The last update time of the memory item. + /// The namespace that logically groups and isolates memories, such as a user ID. + /// The content of the memory. + /// The kind of the memory item. + /// Keeps track of any properties unknown to the library. + internal UserProfileMemoryItem(string memoryId, DateTimeOffset updatedAt, string scope, string content, MemoryItemKind kind, IDictionary additionalBinaryDataProperties) : base(memoryId, updatedAt, scope, content, kind, additionalBinaryDataProperties) + { + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/WebSearchActionSearchSources.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/WebSearchActionSearchSources.Serialization.cs new file mode 100644 index 000000000000..5e313b6b96a3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/WebSearchActionSearchSources.Serialization.cs @@ -0,0 +1,148 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.Projects; + +namespace OpenAI +{ + /// The WebSearchActionSearchSources. + internal partial class WebSearchActionSearchSources : IJsonModel + { + /// Initializes a new instance of for deserialization. + internal WebSearchActionSearchSources() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WebSearchActionSearchSources)} does not support writing '{format}' format."); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Url); + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + 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 + } + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + WebSearchActionSearchSources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual WebSearchActionSearchSources JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WebSearchActionSearchSources)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWebSearchActionSearchSources(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static WebSearchActionSearchSources DeserializeWebSearchActionSearchSources(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = default; + string url = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("url"u8)) + { + url = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new WebSearchActionSearchSources(@type, url, additionalBinaryDataProperties); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(WebSearchActionSearchSources)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + WebSearchActionSearchSources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual WebSearchActionSearchSources PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeWebSearchActionSearchSources(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WebSearchActionSearchSources)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/WebSearchActionSearchSources.cs b/sdk/ai/Azure.AI.Projects/src/Generated/WebSearchActionSearchSources.cs new file mode 100644 index 000000000000..86af0bc84461 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/WebSearchActionSearchSources.cs @@ -0,0 +1,44 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.Projects; + +namespace OpenAI +{ + /// The WebSearchActionSearchSources. + internal partial class WebSearchActionSearchSources + { + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; + + /// Initializes a new instance of . + /// + /// is null. + public WebSearchActionSearchSources(string url) + { + Argument.AssertNotNull(url, nameof(url)); + + Url = url; + } + + /// Initializes a new instance of . + /// + /// + /// Keeps track of any properties unknown to the library. + internal WebSearchActionSearchSources(string @type, string url, IDictionary additionalBinaryDataProperties) + { + Type = @type; + Url = url; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Gets the Type. + internal string Type { get; } = "url"; + + /// Gets the Url. + public string Url { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/WebSearchActionType.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/WebSearchActionType.Serialization.cs new file mode 100644 index 000000000000..d45f668c8e23 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/WebSearchActionType.Serialization.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; + +namespace OpenAI +{ + internal static partial class WebSearchActionTypeExtensions + { + /// The value to serialize. + public static string ToSerialString(this WebSearchActionType value) => value switch + { + WebSearchActionType.Search => "search", + WebSearchActionType.OpenPage => "open_page", + WebSearchActionType.Find => "find", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown WebSearchActionType value.") + }; + + /// The value to deserialize. + public static WebSearchActionType ToWebSearchActionType(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "search")) + { + return WebSearchActionType.Search; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "open_page")) + { + return WebSearchActionType.OpenPage; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "find")) + { + return WebSearchActionType.Find; + } + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown WebSearchActionType value."); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/WebSearchActionType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/WebSearchActionType.cs new file mode 100644 index 000000000000..93f691047824 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/WebSearchActionType.cs @@ -0,0 +1,17 @@ +// + +#nullable disable + +namespace OpenAI +{ + /// + internal enum WebSearchActionType + { + /// Search. + Search, + /// OpenPage. + OpenPage, + /// Find. + Find + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/WebSearchPreviewToolSearchContextSize.cs b/sdk/ai/Azure.AI.Projects/src/Generated/WebSearchPreviewToolSearchContextSize.cs new file mode 100644 index 000000000000..19d9e883e32a --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/WebSearchPreviewToolSearchContextSize.cs @@ -0,0 +1,69 @@ +// + +#nullable disable + +using System; +using System.ComponentModel; +using Azure.AI.Projects; + +namespace OpenAI +{ + internal readonly partial struct WebSearchPreviewToolSearchContextSize : IEquatable + { + private readonly string _value; + private const string LowValue = "low"; + private const string MediumValue = "medium"; + private const string HighValue = "high"; + + /// Initializes a new instance of . + /// The value. + /// is null. + public WebSearchPreviewToolSearchContextSize(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + _value = value; + } + + /// Gets the Low. + public static WebSearchPreviewToolSearchContextSize Low { get; } = new WebSearchPreviewToolSearchContextSize(LowValue); + + /// Gets the Medium. + public static WebSearchPreviewToolSearchContextSize Medium { get; } = new WebSearchPreviewToolSearchContextSize(MediumValue); + + /// Gets the High. + public static WebSearchPreviewToolSearchContextSize High { get; } = new WebSearchPreviewToolSearchContextSize(HighValue); + + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator ==(WebSearchPreviewToolSearchContextSize left, WebSearchPreviewToolSearchContextSize right) => left.Equals(right); + + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. + public static bool operator !=(WebSearchPreviewToolSearchContextSize left, WebSearchPreviewToolSearchContextSize right) => !left.Equals(right); + + /// Converts a string to a . + /// The value. + public static implicit operator WebSearchPreviewToolSearchContextSize(string value) => new WebSearchPreviewToolSearchContextSize(value); + + /// Converts a string to a . + /// The value. + public static implicit operator WebSearchPreviewToolSearchContextSize?(string value) => value == null ? null : new WebSearchPreviewToolSearchContextSize(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is WebSearchPreviewToolSearchContextSize other && Equals(other); + + /// + public bool Equals(WebSearchPreviewToolSearchContextSize other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + + /// + public override string ToString() => _value; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/WeeklyRecurrenceSchedule.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/WeeklyRecurrenceSchedule.Serialization.cs new file mode 100644 index 000000000000..1239e25360fa --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/WeeklyRecurrenceSchedule.Serialization.cs @@ -0,0 +1,141 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// Weekly recurrence schedule. + public partial class WeeklyRecurrenceSchedule : RecurrenceSchedule, IJsonModel + { + /// Initializes a new instance of for deserialization. + internal WeeklyRecurrenceSchedule() + { + } + + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WeeklyRecurrenceSchedule)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("daysOfWeek"u8); + writer.WriteStartArray(); + foreach (DayOfWeek item in DaysOfWeek) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + + /// The JSON reader. + /// The client options for reading and writing models. + WeeklyRecurrenceSchedule IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (WeeklyRecurrenceSchedule)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override RecurrenceSchedule JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WeeklyRecurrenceSchedule)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWeeklyRecurrenceSchedule(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static WeeklyRecurrenceSchedule DeserializeWeeklyRecurrenceSchedule(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RecurrenceType @type = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IList daysOfWeek = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = new RecurrenceType(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("daysOfWeek"u8)) + { + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(new DayOfWeek(item.GetString())); + } + daysOfWeek = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new WeeklyRecurrenceSchedule(@type, additionalBinaryDataProperties, daysOfWeek); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(WeeklyRecurrenceSchedule)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + WeeklyRecurrenceSchedule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (WeeklyRecurrenceSchedule)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override RecurrenceSchedule PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeWeeklyRecurrenceSchedule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WeeklyRecurrenceSchedule)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/WeeklyRecurrenceSchedule.cs b/sdk/ai/Azure.AI.Projects/src/Generated/WeeklyRecurrenceSchedule.cs new file mode 100644 index 000000000000..f01e7ce2fdfd --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/WeeklyRecurrenceSchedule.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects +{ + /// Weekly recurrence schedule. + public partial class WeeklyRecurrenceSchedule : RecurrenceSchedule + { + /// Initializes a new instance of . + /// Days of the week for the recurrence schedule. + /// is null. + public WeeklyRecurrenceSchedule(IEnumerable daysOfWeek) : base(RecurrenceType.Weekly) + { + Argument.AssertNotNull(daysOfWeek, nameof(daysOfWeek)); + + DaysOfWeek = daysOfWeek.ToList(); + } + + /// Initializes a new instance of . + /// Recurrence type for the recurrence schedule. + /// Keeps track of any properties unknown to the library. + /// Days of the week for the recurrence schedule. + internal WeeklyRecurrenceSchedule(RecurrenceType @type, IDictionary additionalBinaryDataProperties, IList daysOfWeek) : base(@type, additionalBinaryDataProperties) + { + DaysOfWeek = daysOfWeek; + } + + /// Days of the week for the recurrence schedule. + public IList DaysOfWeek { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/WorkflowAgentDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/WorkflowAgentDefinition.Serialization.cs new file mode 100644 index 000000000000..a3e75471ec51 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/WorkflowAgentDefinition.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AI.Projects +{ + /// The workflow agent definition. + internal partial class WorkflowAgentDefinition : InternalAgentDefinition, IJsonModel + { + /// The JSON writer. + /// The client options for reading and writing models. + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WorkflowAgentDefinition)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Workflow)) + { + writer.WritePropertyName("workflow"u8); + writer.WriteStringValue(Workflow); + } + } + + /// The JSON reader. + /// The client options for reading and writing models. + WorkflowAgentDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (WorkflowAgentDefinition)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override InternalAgentDefinition JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WorkflowAgentDefinition)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWorkflowAgentDefinition(document.RootElement, options); + } + + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static WorkflowAgentDefinition DeserializeWorkflowAgentDefinition(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AgentKind kind = default; + RaiConfig raiConfig = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + string workflow = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("kind"u8)) + { + kind = new AgentKind(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("rai_config"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + raiConfig = RaiConfig.DeserializeRaiConfig(prop.Value, options); + continue; + } + if (prop.NameEquals("workflow"u8)) + { + workflow = prop.Value.GetString(); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new WorkflowAgentDefinition(kind, raiConfig, additionalBinaryDataProperties, workflow); + } + + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options, AzureAIProjectsContext.Default); + default: + throw new FormatException($"The model {nameof(WorkflowAgentDefinition)} does not support writing '{options.Format}' format."); + } + } + + /// The data to parse. + /// The client options for reading and writing models. + WorkflowAgentDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (WorkflowAgentDefinition)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override InternalAgentDefinition PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) + { + return DeserializeWorkflowAgentDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WorkflowAgentDefinition)} does not support reading '{options.Format}' format."); + } + } + + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/WorkflowAgentDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/WorkflowAgentDefinition.cs new file mode 100644 index 000000000000..ce24ae7330da --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/WorkflowAgentDefinition.cs @@ -0,0 +1,31 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// The workflow agent definition. + internal partial class WorkflowAgentDefinition : InternalAgentDefinition + { + /// Initializes a new instance of . + public WorkflowAgentDefinition() : base(AgentKind.Workflow) + { + } + + /// Initializes a new instance of . + /// + /// Configuration for Responsible AI (RAI) content filtering and safety features. + /// Keeps track of any properties unknown to the library. + /// The CSDL YAML definition of the workflow. + internal WorkflowAgentDefinition(AgentKind kind, RaiConfig raiConfig, IDictionary additionalBinaryDataProperties, string workflow) : base(kind, raiConfig, additionalBinaryDataProperties) + { + Workflow = workflow; + } + + /// The CSDL YAML definition of the workflow. + public string Workflow { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Helpers/ClientResultExtensions.cs b/sdk/ai/Azure.AI.Projects/src/Helpers/ClientResultExtensions.cs new file mode 100644 index 000000000000..1e4533063378 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Helpers/ClientResultExtensions.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel; +using System.ClientModel.Primitives; +using Azure.AI.Projects.OpenAI; +using OpenAI; + +namespace Azure.AI.Projects; +internal static partial class ClientResultExtensions +{ + extension(ClientResult result) + { + public ClientResult ToProjectOpenAIResult() + where T : IJsonModel + => result.ToTypedResult(AzureAIProjectsOpenAIContext.Default); + + public ClientResult ToExternalOpenAIResult() + where T : IJsonModel + => result.ToTypedResult(OpenAIContext.Default); + + private ClientResult ToTypedResult(ModelReaderWriterContext context) + where T : IJsonModel + { + PipelineResponse rawResponse = result.GetRawResponse(); + T value = ModelReaderWriter.Read(rawResponse.Content, ModelSerializationExtensions.WireOptions, context); + return ClientResult.FromValue(value, rawResponse); + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Helpers/CustomSerializationHelpers.cs b/sdk/ai/Azure.AI.Projects/src/Helpers/CustomSerializationHelpers.cs index 34fcade52998..10c527879019 100644 --- a/sdk/ai/Azure.AI.Projects/src/Helpers/CustomSerializationHelpers.cs +++ b/sdk/ai/Azure.AI.Projects/src/Helpers/CustomSerializationHelpers.cs @@ -2,8 +2,11 @@ // Licensed under the MIT License. using System; +using System.ClientModel.Primitives; +using System.IO; using System.Runtime.CompilerServices; using System.Text.Json; +using Azure.AI.Projects.OpenAI; namespace Azure.AI.Projects; internal static partial class CustomSerializationHelpers @@ -20,4 +23,21 @@ internal static void DeserializeNullableDateTimeOffset(JsonProperty property, re targetDateTimeOffset = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); } } + + public static T DeserializeProjectOpenAIType(JsonElement element, ModelReaderWriterOptions options) + => DeserializeExternalType(element, options, AzureAIProjectsOpenAIContext.Default); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static T DeserializeExternalType(JsonElement element, ModelReaderWriterOptions options, ModelReaderWriterContext context) + { + using MemoryStream stream = new(); + Utf8JsonWriter writer = new(stream); + element.WriteTo(writer); + writer.Flush(); + stream.Position = 0; + + BinaryData elementBytes = BinaryData.FromStream(stream); + + return ModelReaderWriter.Read(elementBytes, options, context); + } } diff --git a/sdk/ai/Azure.AI.Projects/src/Helpers/GenericActionPipelinePolicy.cs b/sdk/ai/Azure.AI.Projects/src/Helpers/GenericActionPipelinePolicy.cs new file mode 100644 index 000000000000..ee5cd8a10ed8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Helpers/GenericActionPipelinePolicy.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Azure.AI.Projects; + +internal partial class GenericActionPipelinePolicy : PipelinePolicy +{ + private readonly Action _requestAction; + private readonly Action _responseAction; + private readonly Action _messageAction; + + public GenericActionPipelinePolicy(Action requestAction = null, Action responseAction = null, Action messageAction = null) + { + _requestAction = (request) => + { + if (request is not null) + { + requestAction?.Invoke(request); + } + }; + _responseAction = (response) => + { + if (response is not null) + { + responseAction?.Invoke(response); + } + }; + _messageAction = (message) => + { + if (message is not null) + { + messageAction?.Invoke(message); + } + }; + } + + public override void Process(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) + { + _messageAction?.Invoke(message); + _requestAction?.Invoke(message.Request); + ProcessNext(message, pipeline, currentIndex); + _responseAction?.Invoke(message.Response); + _messageAction?.Invoke(message); + } + + public override async ValueTask ProcessAsync(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) + { + _messageAction?.Invoke(message); + _requestAction?.Invoke(message.Request); + await ProcessNextAsync(message, pipeline, currentIndex).ConfigureAwait(false); + _responseAction?.Invoke(message.Response); + _messageAction?.Invoke(message); + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Helpers/InternalOpenAIAsyncCollectionResultOfT.cs b/sdk/ai/Azure.AI.Projects/src/Helpers/InternalOpenAIAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..08549a09f06f --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Helpers/InternalOpenAIAsyncCollectionResultOfT.cs @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Text.Json; +using System.Threading.Tasks; + +namespace Azure.AI.Projects; + +internal partial class InternalOpenAIAsyncCollectionResultOfT : AsyncCollectionResult +{ + private readonly ClientPipeline _pipeline; + private readonly Func _messageGenerator; + private readonly Func _dataItemDeserializer; + private readonly InternalOpenAICollectionResultOptions _resultOptions; + private readonly RequestOptions _requestOptions; + + public InternalOpenAIAsyncCollectionResultOfT( + ClientPipeline pipeline, + Func messageGenerator, + Func dataItemDeserializer, + InternalOpenAICollectionResultOptions resultOptions, + RequestOptions requestOptions) + { + _pipeline = pipeline; + _messageGenerator = messageGenerator; + _dataItemDeserializer = dataItemDeserializer; + _resultOptions = resultOptions; + _requestOptions = requestOptions; + } + + public override ContinuationToken GetContinuationToken(ClientResult rawPage) + { + InternalOpenAIPaginatedListResultOfT page = GetPageFromResult(rawPage); + if (page.HasMore) + { + return ContinuationToken.FromBytes(rawPage.GetRawResponse().Content); + } + return null; + } + + public ReadOnlyCollection GetDataFromPage(ClientResult rawPage) + { + return GetPageFromResult(rawPage); + } + + protected override async IAsyncEnumerable GetValuesFromPageAsync(ClientResult rawPage) + { + InternalOpenAIPaginatedListResultOfT page = GetPageFromResult(rawPage); + + foreach (TData dataItem in page) + { + yield return dataItem; + await Task.Yield(); + } + } + + public override async IAsyncEnumerable GetRawPagesAsync() + { + PipelineMessage message = _messageGenerator.Invoke(_resultOptions, _requestOptions); + while (true) + { + _ = await _pipeline.ProcessMessageAsync(message, _requestOptions).ConfigureAwait(false); + ClientResult result = ClientResult.FromResponse(message.Response); + yield return result; + + InternalOpenAIPaginatedListResultOfT page = GetPageFromResult(result); + + if (!page.HasMore) + { + yield break; + } + + message = _messageGenerator.Invoke(_resultOptions.GetCloneForPage(page), _requestOptions); + } + } + + private InternalOpenAIPaginatedListResultOfT GetPageFromResult(ClientResult result) + { + using JsonDocument pageDocument = JsonDocument.Parse(result.GetRawResponse().Content); + InternalOpenAIPaginatedListResultOfT typedDataResult + = InternalOpenAIPaginatedListResultOfT.DeserializeInternalOpenAIPaginatedListResultOfT( + pageDocument.RootElement, + _dataItemDeserializer, + options: ModelReaderWriterOptions.Json); + return typedDataResult; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Helpers/InternalOpenAICollectionResultOfT.cs b/sdk/ai/Azure.AI.Projects/src/Helpers/InternalOpenAICollectionResultOfT.cs new file mode 100644 index 000000000000..050f9af85945 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Helpers/InternalOpenAICollectionResultOfT.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Text.Json; + +namespace Azure.AI.Projects; + +internal partial class InternalOpenAICollectionResultOfT : CollectionResult +{ + private readonly ClientPipeline _pipeline; + private readonly Func _messageGenerator; + private readonly Func _dataItemDeserializer; + private readonly InternalOpenAICollectionResultOptions _resultOptions; + private readonly RequestOptions _requestOptions; + + public InternalOpenAICollectionResultOfT( + ClientPipeline pipeline, + Func messageGenerator, + Func dataItemDeserializer, + InternalOpenAICollectionResultOptions resultOptions, + RequestOptions requestOptions) + { + Argument.AssertNotNull(pipeline, nameof(pipeline)); + Argument.AssertNotNull(messageGenerator, nameof(messageGenerator)); + + _pipeline = pipeline; + _messageGenerator = messageGenerator; + _dataItemDeserializer = dataItemDeserializer; + _resultOptions = resultOptions; + _requestOptions = requestOptions; + } + + public override IEnumerable GetRawPages() + { + PipelineMessage message = _messageGenerator.Invoke(_resultOptions, _requestOptions); + while (true) + { + _ = _pipeline.ProcessMessage(message, _requestOptions); + ClientResult result = ClientResult.FromResponse(message.Response); + yield return result; + + InternalOpenAIPaginatedListResultOfT page = GetPageFromResult(result); + + if (!page.HasMore) + { + yield break; + } + message = _messageGenerator.Invoke(_resultOptions.GetCloneForPage(page), _requestOptions); + } + } + + public override ContinuationToken GetContinuationToken(ClientResult rawPage) + { + InternalOpenAIPaginatedListResultOfT page = GetPageFromResult(rawPage); + if (page.HasMore) + { + return ContinuationToken.FromBytes(rawPage.GetRawResponse().Content); + } + return null; + } + + public ReadOnlyCollection GetDataFromPage(ClientResult rawPage) + { + return GetPageFromResult(rawPage); + } + + protected override IEnumerable GetValuesFromPage(ClientResult rawPage) + { + return GetPageFromResult(rawPage); + } + + private InternalOpenAIPaginatedListResultOfT GetPageFromResult(ClientResult result) + { + using JsonDocument pageDocument = JsonDocument.Parse(result.GetRawResponse().Content); + InternalOpenAIPaginatedListResultOfT typedDataResult + = InternalOpenAIPaginatedListResultOfT.DeserializeInternalOpenAIPaginatedListResultOfT( + pageDocument.RootElement, + _dataItemDeserializer, + options: ModelReaderWriterOptions.Json); + return typedDataResult; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Helpers/InternalOpenAICollectionResultOptions.cs b/sdk/ai/Azure.AI.Projects/src/Helpers/InternalOpenAICollectionResultOptions.cs new file mode 100644 index 000000000000..442b69be969c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Helpers/InternalOpenAICollectionResultOptions.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System.Collections.Generic; + +namespace Azure.AI.Projects; + +internal partial class InternalOpenAICollectionResultOptions +{ + public string ParentResourceId { get; set; } + public int? Limit { get; set; } + public string Order { get; set; } + public string AfterId { get; set; } + public string BeforeId { get; set; } + public List Filters { get; } = []; + public List Includes { get; } = []; + + public InternalOpenAICollectionResultOptions(int? limit = null, string order = null, string after = null, string before = null, IEnumerable filters = null, IEnumerable includes = null) + { + Limit = limit; + Order = order; + AfterId = after; + BeforeId = before; + Filters ??= []; + foreach (string maybeFilter in filters ?? []) + { + if (!string.IsNullOrEmpty(maybeFilter)) + { + Filters.Add(maybeFilter); + } + } + Includes ??= []; + foreach (string maybeInclude in includes ?? []) + { + if (!string.IsNullOrEmpty(maybeInclude)) + { + Includes.Add(maybeInclude); + } + } + } + + public InternalOpenAICollectionResultOptions GetCloneForPage(InternalOpenAIPaginatedListResultOfT page) + { + InternalOpenAICollectionResultOptions clonedOptions = (InternalOpenAICollectionResultOptions)MemberwiseClone(); + clonedOptions.Filters.AddRange(Filters); + clonedOptions.Includes.AddRange(Includes); + + clonedOptions.AfterId = page.LastId; + clonedOptions.BeforeId = page.FirstId; + + return clonedOptions; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Helpers/InternalOpenAIPaginatedListResultOfT.cs b/sdk/ai/Azure.AI.Projects/src/Helpers/InternalOpenAIPaginatedListResultOfT.cs new file mode 100644 index 000000000000..97fbc38faf29 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Helpers/InternalOpenAIPaginatedListResultOfT.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Text.Json; + +namespace Azure.AI.Projects; + +internal partial class InternalOpenAIPaginatedListResultOfT : ReadOnlyCollection +{ + public string FirstId { get; } + public string LastId { get; } + public bool HasMore { get; } + + internal InternalOpenAIPaginatedListResultOfT() : base(new ChangeTrackingList()) + { } + + internal InternalOpenAIPaginatedListResultOfT(string firstId, string lastId, bool hasMore, IList data) + : base(data) + { + FirstId = firstId; + LastId = lastId; + HasMore = hasMore; + } + + internal static InternalOpenAIPaginatedListResultOfT DeserializeInternalOpenAIPaginatedListResultOfT( + ClientResult protocolResult, + Func dataItemDeserializer, + ModelReaderWriterOptions options) + { + using JsonDocument document = JsonDocument.Parse(protocolResult.GetRawResponse().ContentStream); + return DeserializeInternalOpenAIPaginatedListResultOfT(document.RootElement, dataItemDeserializer, options); + } + + internal static InternalOpenAIPaginatedListResultOfT DeserializeInternalOpenAIPaginatedListResultOfT( + JsonElement element, + Func dataItemDeserializer, + ModelReaderWriterOptions options) + { + if (element.ValueKind != JsonValueKind.Object) + { + return null; + } + + string firstId = null; + string lastId = null; + bool hasMore = false; + List data = []; + + foreach (JsonProperty topProperty in element.EnumerateObject()) + { + if (topProperty.NameEquals("first_id"u8)) + { + firstId = topProperty.Value.GetString(); + } + else if (topProperty.NameEquals("last_id"u8)) + { + lastId = topProperty.Value.GetString(); + } + else if (topProperty.NameEquals("has_more"u8)) + { + hasMore = topProperty.Value.GetBoolean(); + } + else if (topProperty.NameEquals("data"u8)) + { + if (topProperty.Value.ValueKind == JsonValueKind.Array) + { + foreach (JsonElement dataElement in topProperty.Value.EnumerateArray()) + { + TData dataItem = dataItemDeserializer.Invoke(dataElement, options); + data.Add(dataItem); + } + } + } + } + + return new(firstId, lastId, hasMore, data); + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Helpers/PipelinePolicyHelpers.cs b/sdk/ai/Azure.AI.Projects/src/Helpers/PipelinePolicyHelpers.cs new file mode 100644 index 000000000000..5b4017329944 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Helpers/PipelinePolicyHelpers.cs @@ -0,0 +1,249 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.IO; +using System.Text; +using System.Text.Json.Nodes; +using System.Text.RegularExpressions; +using Azure.Core; +using OpenAI; +using OpenAI.Files; + +namespace Azure.AI.Projects; + +#pragma warning disable CS0618 + +internal static partial class PipelinePolicyHelpers +{ + /// + /// Adds a policy to that ensures a query parameter with the provided/key value is present. + /// + /// + /// + /// + public static void AddQueryParameterPolicy(ClientPipelineOptions options, string key, string value) + => AddQueryParameterPolicy(options, key, () => value); + + /// + /// Adds a policy to that ensures a query parameter with the key is present, delay-invoking the provided value generator. + /// + /// + /// + /// + public static void AddQueryParameterPolicy(ClientPipelineOptions options, string key, Func valueGenerator) + { + options.AddPolicy( + new GenericActionPipelinePolicy( + requestAction: request => + { + if (request?.Uri is Uri requestUri) + { + RawRequestUriBuilder builder = new(); + builder.Reset(requestUri); + if (!builder.Query.Contains(key)) + { + string value = valueGenerator.Invoke(); + if (!string.IsNullOrEmpty(value)) + { + builder.AppendQuery(key, value, escapeValue: true); + } + } + request.Uri = builder.ToUri(); + } + }), + PipelinePosition.PerCall); + } + + public static void AddRequestHeaderPolicy(ClientPipelineOptions options, string key, string value, bool replaceExisting = false) + => AddRequestHeaderPolicy(options, key, () => value); + + public static void AddRequestHeaderPolicy(ClientPipelineOptions options, string key, Func valueGenerator, bool replaceExisting = false) + { + options.AddPolicy( + new GenericActionPipelinePolicy( + requestAction: request => + { + if (replaceExisting || !request.Headers.TryGetValue(key, out string _)) + { + request.Headers.Set(key, valueGenerator.Invoke()); + } + }), + PipelinePosition.PerCall); + } + + internal static partial class OpenAI + { + /// + /// Adds a policy to that removes "id" and "status" properties from each item in an array of OpenAIResponse items, as needed for full compatibility in specific operations. + /// + /// + /// This is a workaround for an issue in the OpenAI library: https://github.com/openai/openai-dotnet/issues/779 + /// + /// + public static void AddResponseItemInputTransformPolicy(ClientPipelineOptions options) + { + options.AddPolicy(new GenericActionPipelinePolicy( + requestAction: request => + { + if (request.Method == "POST" && (request.Uri?.AbsoluteUri?.EndsWith("/responses") == true || request.Uri?.AbsoluteUri?.Contains("/responses?") == true)) + { + using MemoryStream stream = new(); + request.Content.WriteTo(stream); + stream.Position = 0; + JsonNode node = JsonNode.Parse(stream); + if (node.AsObject() is JsonObject responseRequestObject + && responseRequestObject.TryGetPropertyValue("input", out JsonNode inputNode) == true + && inputNode.AsArray() is JsonArray inputArray) + { + foreach (JsonNode inputItemNode in inputArray) + { + if (inputItemNode?.AsObject() is JsonObject inputItemObject) + { + inputItemObject.Remove("id"); + inputItemObject.Remove("status"); + } + } + + request.Content = BinaryContent.Create(BinaryData.FromString(node.ToJsonString())); + } + } + }), + PipelinePosition.PerCall); + } + + /// + /// Adds a policy to that aggressively transforms divergent error response payloads into something with user-facing information. + /// Error response to exception message conversion is handled in the external OpenAI library for Responses and other OpenAI-based calls, so this heavier-weight + /// content reformatting is necessary (in contrast to internal calls, where we can control the deserialization directly). + /// + /// + /// This is a temporary workaround for internal issue 4771165. + /// + /// + public static void AddErrorTransformPolicy(ClientPipelineOptions options) + { + options.AddPolicy( + new GenericActionPipelinePolicy( + responseAction: response => + { + if (response?.IsError == true) + { + response.BufferContent(); + try + { + if (JsonNode.Parse(response.Content) is JsonObject errorResponseJsonObject) + { + if (FoundryOpenAIError.TryCreateFromResponse(response) is FoundryOpenAIError apiErrorInstance) + { + response.ContentStream = new MemoryStream(apiErrorInstance.ToOpenAIError().ToArray()); + } + else if (errorResponseJsonObject.TryGetPropertyValue("error", out JsonNode errorNode) + && errorNode is JsonObject errorObject + && (errorObject.TryGetPropertyValue("additional_info", out JsonNode _) + || errorObject.TryGetPropertyValue("details", out JsonNode _))) + { + StringBuilder messageRebuilder = new(errorObject.TryGetPropertyValue("message", out JsonNode messageNode) ? messageNode.ToString() : string.Empty); + messageRebuilder.AppendLine().AppendLine(); + messageRebuilder.Append(errorObject.ToString()); + + response.ContentStream = new MemoryStream(BinaryData.FromString($$""" + { + "error": { + "type": "ServiceError", + "code": {{JsonValue.Create(errorObject.TryGetPropertyValue("code", out JsonNode codeNode) ? codeNode.ToString() : string.Empty).ToJsonString()}}, + "param": {{JsonValue.Create(errorObject.TryGetPropertyValue("paramNode", out JsonNode paramNode) ? paramNode.ToString() : string.Empty).ToJsonString()}}, + "message": {{JsonValue.Create(messageRebuilder.ToString()).ToJsonString()}} + } + } + """).ToArray()); + } + } + } + catch (System.Text.Json.JsonException) + { } + } + }), + PipelinePosition.PerTry); + } + + public static void AddAzureFinetuningParityPolicy(ClientPipelineOptions options) + { + options.AddPolicy( + new GenericActionPipelinePolicy( + messageAction: message => + { + // Skip this policy for everything except file operations + if (message?.Request?.Uri?.AbsoluteUri?.Contains("openai/files") == false) + { + return; + } + + // When processing the message to send the request (no response yet), perform a fixup to ensure a multipart/form-data Content-Type is + // provided for the "file" content part (non-parity limitation) + if (message?.Request?.Method == "POST" && message?.Request is not null && message?.Response is null) + { + using MemoryStream requestStream = new(); + message.Request.Content.WriteTo(requestStream); + requestStream.Position = 0; + using StreamReader reader = new(requestStream); + + MemoryStream newRequestStream = new(); + StreamWriter newRequestWriter = new(newRequestStream); + string previousLine = null; + + for (string line = reader.ReadLine(); line is not null; line = reader.ReadLine()) + { + if (line == string.Empty + && Regex.Match( + previousLine, + "Content-Disposition: form-data; name=file; filename=([^;]*);.*") is Match fileContentDispositionMatch + && fileContentDispositionMatch.Success) + { + // We are explicitly set the line ending as + // WriteLine will add only \n symbol on Unix systems, + // Which will result in error 400 on te service side. + newRequestWriter.Write("Content-Type: application/octet-stream\r\n"); + } + newRequestWriter.Write($"{line}\r\n"); + previousLine = line; + } + + newRequestWriter.Flush(); + newRequestStream.Position = 0; + message.Request.Content = BinaryContent.Create(newRequestStream); + message.ResponseClassifier = PipelineMessageClassifier; + } + + // When processing the message for the response, force non-OpenAI "status" values to "processed" and relocate the extended value + // to an additional property + if (message?.Response is not null) + { + message?.Response.BufferContent(); + + // Only parse as JSON if the response Content-Type indicates JSON + string contentType = message?.Response?.Headers?.TryGetValue("Content-Type", out string ct) == true ? ct : string.Empty; + bool isJsonResponse = contentType.IndexOf("application/json", StringComparison.OrdinalIgnoreCase) >= 0; + + if (isJsonResponse + && JsonNode.Parse(message?.Response?.ContentStream) is JsonObject responseObject + && responseObject.TryGetPropertyValue("status", out JsonNode statusNode) + && statusNode is JsonValue statusValue + && !Enum.TryParse(statusValue.ToString(), out FileStatus _)) + { + responseObject["status"] = "processed"; + responseObject["_sdk_status"] = statusValue.ToString(); + message.Response.ContentStream = new MemoryStream(BinaryData.FromString(responseObject.ToJsonString()).ToArray()); + } + } + }), + PipelinePosition.PerCall); + } + + private static PipelineMessageClassifier s_pipelineMessageClassifier; + private static PipelineMessageClassifier PipelineMessageClassifier + => s_pipelineMessageClassifier ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200, 201 }); + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Helpers/ResponseItemHelpers.cs b/sdk/ai/Azure.AI.Projects/src/Helpers/ResponseItemHelpers.cs new file mode 100644 index 000000000000..7a171afeae0b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Helpers/ResponseItemHelpers.cs @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System.Text.Json; +using Azure.AI.Projects.OpenAI; +using OpenAI.Responses; +using OpenAI; +using System.Runtime.CompilerServices; +using System.Collections.Generic; +using System; + +namespace Azure.AI.Projects; + +#pragma warning disable SCME0001 + +internal static partial class ResponseItemHelpers +{ + internal static void DeserializeItemsValue(JsonProperty property, ref IList items) + { + if (property.Value.ValueKind == JsonValueKind.Array) + { + List deserializedItems = []; + foreach (JsonElement serializedResponseItemElement in property.Value.EnumerateArray()) + { + AgentResponseItem deserializedItem + = CustomSerializationHelpers.DeserializeProjectOpenAIType( + serializedResponseItemElement, + ModelSerializationExtensions.WireOptions); + deserializedItems.Add(deserializedItem); + } + items = deserializedItems; + } + } + + internal static ChangeTrackingList GetPublicItemsFromInternalParams(IList internalItems) + { + ChangeTrackingList result = new(); + foreach (InternalItemParam internalItem in internalItems ?? []) + { + BinaryData serializedInternalItem = ModelReaderWriter.Write(internalItem, ModelSerializationExtensions.WireOptions, AzureAIProjectsContext.Default); + ResponseItem deserializedItem = ModelReaderWriter.Read(serializedInternalItem, ModelSerializationExtensions.WireOptions, OpenAIContext.Default); + result.Add(deserializedItem); + } + return result; + } + + private static Dictionary s_contextMap; + + internal static ChangeTrackingList ConvertItemsTo(IEnumerable sourceItems) + { + s_contextMap ??= new() + { + [typeof(ResponseItem)] = OpenAIContext.Default, + [typeof(InternalItemParam)] = AzureAIProjectsContext.Default, + }; + if (!s_contextMap.ContainsKey(typeof(T)) || !s_contextMap.ContainsKey(typeof(U))) + { + throw new NotImplementedException(); + } + + ChangeTrackingList values = new(); + + foreach (U sourceItem in sourceItems ??= []) + { + BinaryData serializedItem = ModelReaderWriter.Write(sourceItem, ModelSerializationExtensions.WireOptions, s_contextMap[typeof(U)]); + T deserializedTargetItem = ModelReaderWriter.Read(serializedItem, ModelSerializationExtensions.WireOptions, s_contextMap[typeof(T)]); + values.Add(deserializedTargetItem); + } + + return values; + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Helpers/TelemetryDetails.cs b/sdk/ai/Azure.AI.Projects/src/Helpers/TelemetryDetails.cs new file mode 100644 index 000000000000..fa3993764521 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Helpers/TelemetryDetails.cs @@ -0,0 +1,197 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Net; +using System.Net.Http.Headers; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Text; + +#nullable enable + +namespace Azure.AI.Projects; + +/// +/// Details about the package to be included in UserAgent telemetry +/// +internal class TelemetryDetails +{ + private const int MaxApplicationIdLength = 99; + + /// + /// The package type represented by this instance. + /// + public Assembly Assembly { get; } + + public RuntimeInformationWrapper Runtime { get; } + + private UserAgentInfo? _cachedUserAgentInfo = null; + public UserAgentInfo UserAgent => _cachedUserAgentInfo ??= GetUserAgentInfo(); + + private readonly string? _userAgentApplicationId; + + internal TelemetryDetails(Assembly assembly, string? applicationId = null) + : this(assembly, applicationId, new RuntimeInformationWrapper()) + { } + + internal TelemetryDetails(Assembly assembly, string? applicationId = null, RuntimeInformationWrapper? runtimeInformation = default) + { + Argument.AssertNotNull(assembly, nameof(assembly)); + if (applicationId?.Length > MaxApplicationIdLength) + { + throw new ArgumentOutOfRangeException(nameof(applicationId), $"{nameof(applicationId)} must be shorter than {MaxApplicationIdLength + 1} characters"); + } + + Assembly = assembly; + Runtime = runtimeInformation ?? new(); + _userAgentApplicationId = applicationId; + } + + private UserAgentInfo GetUserAgentInfo() + { + string assemblyName = Assembly.GetName().Name!; + + AssemblyInformationalVersionAttribute? versionAttribute + = Assembly.GetCustomAttribute() + ?? throw new InvalidOperationException( + $"{nameof(AssemblyInformationalVersionAttribute)} is required on client SDK assembly '{Assembly.FullName}'."); + + int hashSeparatorPosition = versionAttribute.InformationalVersion.LastIndexOf('+'); + string version = hashSeparatorPosition == -1 + ? versionAttribute.InformationalVersion + : versionAttribute.InformationalVersion.Substring(0, hashSeparatorPosition); + + // RFC 9110 section 5.5 https://www.rfc-editor.org/rfc/rfc9110.txt#section-5.5 does not require any specific encoding : "Fields needing a greater range of characters + // can use an encoding, such as the one defined in RFC8187." RFC8187 is targeted at parameter values, almost always filename, so using url encoding here instead, which is + // more widely used. Since user-agent does not usually contain non-ascii, only encode when necessary. + // This was added to support operating systems with non-ascii characters in their release names. +#if NET8_0_OR_GREATER + string osDescription = Ascii.IsValid(Runtime.OSDescription) ? Runtime.OSDescription : WebUtility.UrlEncode(Runtime.OSDescription); +#else + static bool ContainsNonAscii(string value) + { + foreach (char c in value) + { + if ((int)c > 0x7f) + { + return true; + } + } + return false; + } + string osDescription = ContainsNonAscii(Runtime.OSDescription) ? WebUtility.UrlEncode(Runtime.OSDescription) : Runtime.OSDescription; +#endif + + string platform = EscapeProductInformation($"({Runtime.FrameworkDescription}; {osDescription})"); + + return new UserAgentInfo(assemblyName, version, platform, _userAgentApplicationId); + } + + /// + /// If the ProductInformation is not in the proper format, this escapes any ')' , '(' or '\' characters per https://www.rfc-editor.org/rfc/rfc7230#section-3.2.6 + /// + /// The ProductInfo portion of the UserAgent + /// + private static string EscapeProductInformation(string productInfo) + { + // If the string is already valid, we don't need to escape anything + bool success = false; + try + { + success = ProductInfoHeaderValue.TryParse(productInfo, out var _); + } + catch (Exception) + { + // Invalid values can throw in Framework due to https://github.com/dotnet/runtime/issues/28558 + // Treat this as a failure to parse. + } + if (success) + { + return productInfo; + } + + var sb = new StringBuilder(productInfo.Length + 2); + sb.Append('('); + // exclude the first and last characters, which are the enclosing parentheses + for (int i = 1; i < productInfo.Length - 1; i++) + { + char c = productInfo[i]; + if (c == ')' || c == '(') + { + sb.Append('\\'); + } + // If we see a \, we don't need to escape it if it's followed by a '\', '(', or ')', because it is already escaped. + else if (c == '\\') + { + if (i + 1 < (productInfo.Length - 1)) + { + char next = productInfo[i + 1]; + if (next == '\\' || next == '(' || next == ')') + { + sb.Append(c); + sb.Append(next); + i++; + continue; + } + else + { + sb.Append('\\'); + } + } + else + { + sb.Append('\\'); + } + } + sb.Append(c); + } + sb.Append(')'); + return sb.ToString(); + } + + public class UserAgentInfo + { + public string? ApplicationId { get; } + + public string AssemblyName { get; } + + public string Version { get; } + + public string Platform { get; } + + private string? _cachedValueFull = null; + private string? _cachedValueNoPlatform = null; + + public UserAgentInfo(string assemblyName, string version, string platform, string? applicationId = null) + { + AssemblyName = assemblyName; + Version = version; + Platform = platform; + ApplicationId = applicationId; + } + + public string ToString(bool includePlatformInformation) + { + if (includePlatformInformation) + { + return _cachedValueFull ??= $"{ApplicationId}{(ApplicationId?.Length > 0 == true ? " " : "")}{AssemblyName}/{Version} {Platform}"; + } + else + { + return _cachedValueNoPlatform ??= $"{ApplicationId}{(ApplicationId?.Length > 0 == true ? " " : "")}{AssemblyName}/{Version}"; + } + } + + public override string ToString() => ToString(includePlatformInformation: true); + } + + internal class RuntimeInformationWrapper + { + public virtual string FrameworkDescription => RuntimeInformation.FrameworkDescription; + public virtual string OSDescription => RuntimeInformation.OSDescription; + public virtual Architecture OSArchitecture => RuntimeInformation.OSArchitecture; + public virtual Architecture ProcessArchitecture => RuntimeInformation.ProcessArchitecture; + public virtual bool IsOSPlatform(OSPlatform osPlatform) => RuntimeInformation.IsOSPlatform(osPlatform); + } +} diff --git a/sdk/ai/Azure.AI.Projects/tests/AIProjectsTestEnvironment.cs b/sdk/ai/Azure.AI.Projects/tests/AIProjectsTestEnvironment.cs index 5c2ea5681be2..a898fce9e021 100644 --- a/sdk/ai/Azure.AI.Projects/tests/AIProjectsTestEnvironment.cs +++ b/sdk/ai/Azure.AI.Projects/tests/AIProjectsTestEnvironment.cs @@ -15,13 +15,13 @@ public class AIProjectsTestEnvironment : TestEnvironment public string EMBEDDINGSMODELDEPLOYMENTNAME => GetRecordedVariable("EMBEDDINGS_MODEL_DEPLOYMENT_NAME"); public string TEXTEMBEDDINGSMODELDEPLOYMENTNAME => GetRecordedVariable("TEXT_EMBEDDINGS_MODEL_DEPLOYMENT_NAME"); public string MODELPUBLISHER => GetRecordedVariable("MODEL_PUBLISHER"); - public string INDEXNAME => GetRecordedVariable("INDEX_NAME"); - public string INDEXVERSION => GetRecordedVariable("INDEX_VERSION"); - public string AISEARCHCONNECTIONNAME => GetRecordedVariable("AI_SEARCH_CONNECTION_NAME"); - public string AISEARCHINDEXNAME => GetRecordedVariable("AI_SEARCH_INDEX_NAME"); + public string INDEX_NAME => GetRecordedVariable("INDEX_NAME"); + public string INDEX_VERSION => GetRecordedVariable("INDEX_VERSION"); + public string AI_SEARCH_CONNECTION_NAME => GetRecordedVariable("AI_SEARCH_CONNECTION_NAME"); + public string AI_SEARCH_INDEX_NAME => GetRecordedVariable("AI_SEARCH_INDEX_NAME"); public string STORAGECONNECTIONNAME => GetRecordedVariable("STORAGE_CONNECTION_NAME"); public string STORAGECONNECTIONTYPE => GetRecordedVariable("STORAGE_CONNECTION_TYPE"); - public string AOAICONNECTIONNAME => GetRecordedVariable("AOAI_CONNECTION_NAME"); + public string AOAI_CONNECTION_NAME => GetRecordedVariable("AOAI_CONNECTION_NAME"); public string TESTIMAGEPNGINPUTPATH => GetRecordedVariable("TEST_IMAGE_PNG_INPUT_PATH"); public string SAMPLEFILEPATH => GetRecordedVariable("SAMPLE_FILE_PATH"); public string SAMPLEFOLDERPATH => GetRecordedVariable("SAMPLE_FOLDER_PATH"); diff --git a/sdk/ai/Azure.AI.Projects/tests/Azure.AI.Projects.Tests.csproj b/sdk/ai/Azure.AI.Projects/tests/Azure.AI.Projects.Tests.csproj index c3e68296b177..ed9a51d0551f 100644 --- a/sdk/ai/Azure.AI.Projects/tests/Azure.AI.Projects.Tests.csproj +++ b/sdk/ai/Azure.AI.Projects/tests/Azure.AI.Projects.Tests.csproj @@ -1,21 +1,26 @@  $(RequiredTargetFrameworks) - $(NoWarn);CS1591 - + + + preview + true + + + + + - + - - - + @@ -30,6 +35,7 @@ + \ No newline at end of file diff --git a/sdk/ai/Azure.AI.Projects/tests/ConnectionsTest.cs b/sdk/ai/Azure.AI.Projects/tests/ConnectionsTest.cs index 2558c6611a65..bb513c65cab1 100644 --- a/sdk/ai/Azure.AI.Projects/tests/ConnectionsTest.cs +++ b/sdk/ai/Azure.AI.Projects/tests/ConnectionsTest.cs @@ -7,12 +7,6 @@ using System.Threading.Tasks; using Azure.Core.TestFramework; using NUnit.Framework; -using System.ClientModel.Primitives; -using System.Diagnostics; -using System.Collections.Generic; -using Azure.Identity; -using NUnit.Framework.Internal; -using Azure.AI.Projects.Tests.Utils; namespace Azure.AI.Projects.Tests { @@ -23,6 +17,7 @@ public ConnectionsTest(bool isAsync) : base(isAsync) } [RecordedTest] + [Ignore("Pending Microsoft.ClientModel.TestFramework migration")] public async Task ConnectionsBasicTest() { var connectionName = TestEnvironment.STORAGECONNECTIONNAME; diff --git a/sdk/ai/Azure.AI.Projects/tests/DeploymentTest.cs b/sdk/ai/Azure.AI.Projects/tests/DeploymentTest.cs index 93966db0ea5f..58b86c3d92ab 100644 --- a/sdk/ai/Azure.AI.Projects/tests/DeploymentTest.cs +++ b/sdk/ai/Azure.AI.Projects/tests/DeploymentTest.cs @@ -22,6 +22,7 @@ public DeploymentTest(bool isAsync) : base(isAsync) //, RecordedTestMode.Record) } [RecordedTest] + [Ignore("Pending Microsoft.ClientModel.TestFramework migration")] public async Task AIDeploymentTest() { var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; diff --git a/sdk/ai/Azure.AI.Projects/tests/IndexesTest.cs b/sdk/ai/Azure.AI.Projects/tests/IndexesTest.cs index 3bb1c6c0c2e1..e04707c80bb7 100644 --- a/sdk/ai/Azure.AI.Projects/tests/IndexesTest.cs +++ b/sdk/ai/Azure.AI.Projects/tests/IndexesTest.cs @@ -21,14 +21,14 @@ public IndexesTest(bool isAsync) : base(isAsync) //, RecordedTestMode.Record) { } - [TestCase] [RecordedTest] + [Ignore("Pending Microsoft.ClientModel.TestFramework migration")] public async Task SearchIndexesTest() { - string indexName = TestEnvironment.INDEXNAME; - string indexVersion = TestEnvironment.INDEXVERSION; - string aiSearchConnectionName = TestEnvironment.AISEARCHCONNECTIONNAME; - string aiSearchIndexName = TestEnvironment.AISEARCHINDEXNAME; + string indexName = TestEnvironment.INDEX_NAME; + string indexVersion = TestEnvironment.INDEX_VERSION; + string aiSearchConnectionName = TestEnvironment.AI_SEARCH_CONNECTION_NAME; + string aiSearchIndexName = TestEnvironment.AI_SEARCH_INDEX_NAME; AIProjectClient projectClient = GetTestClient(); diff --git a/sdk/ai/Azure.AI.Projects/tests/ProjectsClientTestBase.cs b/sdk/ai/Azure.AI.Projects/tests/ProjectsClientTestBase.cs index 15314308d4a6..abb646feb4cf 100644 --- a/sdk/ai/Azure.AI.Projects/tests/ProjectsClientTestBase.cs +++ b/sdk/ai/Azure.AI.Projects/tests/ProjectsClientTestBase.cs @@ -4,14 +4,17 @@ #nullable disable using System; +using System.IO; +using System.ClientModel.Primitives; using System.Collections.Generic; -using System.Text.RegularExpressions; using System.Linq; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using Azure.AI.Projects.Tests.Utils; using Azure.Core; using Azure.Core.TestFramework; using Azure.Identity; using NUnit.Framework; -using Azure.AI.Projects.Tests.Utils; namespace Azure.AI.Projects.Tests { @@ -20,8 +23,65 @@ namespace Azure.AI.Projects.Tests /// This class now uses a hybrid approach - it extends the standard Azure.Core RecordedTestBase /// but provides manual transport configuration for System.ClientModel compatibility. /// + [LiveOnly(Reason = "Restricted to live runs pending migration to SCM test framework")] public class ProjectsClientTestBase : RecordedTestBase { + #region Debug Method + internal static PipelinePolicy GetDumpPolicy() + { + return new TestPipelinePolicy((message) => + { + if (message.Request is not null && message.Response is null) + { + Console.WriteLine($"--- New request ---"); + IEnumerable headerPairs = message?.Request?.Headers?.Select(header => $"{header.Key}={(header.Key.ToLower().Contains("auth") ? "***" : header.Value)}"); + string headers = string.Join(",", headerPairs); + Console.WriteLine($"Headers: {headers}"); + Console.WriteLine($"{message?.Request?.Method} URI: {message?.Request?.Uri}"); + if (message.Request?.Content != null) + { + string contentType = "Unknown Content Type"; + if (message.Request.Headers?.TryGetValue("Content-Type", out contentType) == true + && contentType == "application/json") + { + using MemoryStream stream = new(); + message.Request.Content.WriteTo(stream, default); + stream.Position = 0; + using StreamReader reader = new(stream); + string requestDump = reader.ReadToEnd(); + stream.Position = 0; + requestDump = Regex.Replace(requestDump, @"""data"":[\\w\\r\\n]*""[^""]*""", @"""data"":""..."""); + Console.WriteLine(requestDump); + } + else + { + string length = message.Request.Content.TryComputeLength(out long numberLength) + ? $"{numberLength} bytes" + : "unknown length"; + Console.WriteLine($"<< Non-JSON content: {contentType} >> {length}"); + } + } + } + if (message.Response != null) + { + IEnumerable headerPairs = message?.Response?.Headers?.Select(header => $"{header.Key}={(header.Key.ToLower().Contains("auth") ? "***" : header.Value)}"); + string headers = string.Join(",", headerPairs); + Console.WriteLine($"Response headers: {headers}"); + if (message.BufferResponse) + { + Console.WriteLine("--- Begin response content ---"); + Console.WriteLine(message.Response.Content?.ToString()); + Console.WriteLine("--- End of response content ---"); + } + else + { + Console.WriteLine("--- Response (unbuffered, content not rendered) ---"); + } + } + }); + } + #endregion + public ProjectsClientTestBase(bool isAsync) : base(isAsync) { TestDiagnostics = false; @@ -50,7 +110,7 @@ protected AIProjectClient GetTestClient(AIProjectClientOptions options = null) options.RetryPolicy = new TestClientRetryPolicy(TimeSpan.FromMilliseconds(10)); } } - + options.AddPolicy(GetDumpPolicy(), PipelinePosition.PerCall); var endpoint = TestEnvironment.PROJECTENDPOINT; var credential = TestEnvironment.Credential; diff --git a/sdk/ai/Azure.AI.Projects/tests/Samples/Agents/Sample_agents_CRUD.cs b/sdk/ai/Azure.AI.Projects/tests/Samples/Agents/Sample_agents_CRUD.cs new file mode 100644 index 000000000000..207c5bbdcaac --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/tests/Samples/Agents/Sample_agents_CRUD.cs @@ -0,0 +1,111 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Threading.Tasks; +using Azure.AI.Projects.OpenAI; +using Azure.Core.TestFramework; +using NUnit.Framework; + +namespace Azure.AI.Projects.Tests.Samples; + +public class Sample_agents_CRUD : SamplesBase +{ + [Test] + [AsyncOnly] + public async Task AgentCRUDAsync() + { + #region Snippet:Sample_CreateAgentClientCRUD +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECTENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + #endregion + + #region Snippet:Sample_CreateAgentVersionCRUD_Async + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a prompt agent." + }; + AgentVersion agentVersion1 = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent1", + options: new(agentDefinition)); + Console.WriteLine($"Agent created (id: {agentVersion1.Id}, name: {agentVersion1.Name}, version: {agentVersion1.Version})"); + AgentVersion agentVersion2 = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "myAgent2", + options: new(agentDefinition)); + Console.WriteLine($"Agent created (id: {agentVersion2.Id}, name: {agentVersion2.Name}, version: {agentVersion2.Version})"); + #endregion + + #region Snippet:Sample_GetAgentCRUD_Async + AgentRecord result = await projectClient.Agents.GetAgentAsync(agentVersion1.Name); + Console.WriteLine($"Agent created (id: {result.Id}, name: {result.Name})"); + #endregion + + #region Snippet:Sample_ListAgentsCRUD_Async + await foreach (AgentRecord agent in projectClient.Agents.GetAgentsAsync()) + { + Console.WriteLine($"Listed Agent: id: {agent.Id}, name: {agent.Name}"); + } + #endregion + + #region Snippet:Sample_DeleteAgentCRUD_Async + await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion1.Name, agentVersion: agentVersion1.Version); + Console.WriteLine($"Agent deleted (name: {agentVersion1.Name}, version: {agentVersion1.Version})"); + await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion2.Name, agentVersion: agentVersion2.Version); + Console.WriteLine($"Agent deleted (name: {agentVersion2.Name}, version: {agentVersion2.Version})"); + #endregion + } + + [Test] + [SyncOnly] + public void AgentCRUD() + { +#if SNIPPET + var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); + var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME"); +#else + var projectEndpoint = TestEnvironment.PROJECTENDPOINT; + var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; +#endif + AIProjectClient projectClient = new(endpoint: new Uri(projectEndpoint), tokenProvider: new DefaultAzureCredential()); + + #region Snippet:Sample_CreateAgentVersionCRUD_Sync + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a prompt agent." + }; + AgentVersion agentVersion1 = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent1", + options: new(agentDefinition)); + Console.WriteLine($"Agent created (id: {agentVersion1.Id}, name: {agentVersion1.Name}, version: {agentVersion1.Version})"); + AgentVersion agentVersion2 = projectClient.Agents.CreateAgentVersion( + agentName: "myAgent2", + options: new(agentDefinition)); + Console.WriteLine($"Agent created (id: {agentVersion2.Id}, name: {agentVersion2.Name}, version: {agentVersion2.Version})"); + #endregion + + #region Snippet:Sample_GetAgentCRUD_Sync + AgentRecord result = projectClient.Agents.GetAgent(agentVersion1.Name); + Console.WriteLine($"Agent created (id: {result.Id}, name: {result.Name})"); + #endregion + + #region Snippet:Sample_ListAgentsCRUD_Sync + foreach (AgentRecord agent in projectClient.Agents.GetAgents()) + { + Console.WriteLine($"Listed Agent: id: {agent.Id}, name: {agent.Name}"); + } + #endregion + + #region Snippet:Sample_DeleteAgentCRUD_Sync + projectClient.Agents.DeleteAgentVersion(agentName: agentVersion1.Name, agentVersion: agentVersion1.Version); + Console.WriteLine($"Agent deleted (name: {agentVersion1.Name}, version: {agentVersion1.Version})"); + projectClient.Agents.DeleteAgentVersion(agentName: agentVersion2.Name, agentVersion: agentVersion2.Version); + Console.WriteLine($"Agent deleted (name: {agentVersion2.Name}, version: {agentVersion2.Version})"); + #endregion + } +} diff --git a/sdk/ai/Azure.AI.Projects/tests/Samples/Agents/Sample_AIAgents.cs b/sdk/ai/Azure.AI.Projects/tests/Samples/ClassicAgents/Sample_AIAgents.cs similarity index 100% rename from sdk/ai/Azure.AI.Projects/tests/Samples/Agents/Sample_AIAgents.cs rename to sdk/ai/Azure.AI.Projects/tests/Samples/ClassicAgents/Sample_AIAgents.cs diff --git a/sdk/ai/Azure.AI.Projects/tests/Samples/Agents/Sample_AzureAISearchToolUsingConnections.cs b/sdk/ai/Azure.AI.Projects/tests/Samples/ClassicAgents/Sample_AzureAISearchToolUsingConnections.cs similarity index 93% rename from sdk/ai/Azure.AI.Projects/tests/Samples/Agents/Sample_AzureAISearchToolUsingConnections.cs rename to sdk/ai/Azure.AI.Projects/tests/Samples/ClassicAgents/Sample_AzureAISearchToolUsingConnections.cs index 69a9f84b01a3..1e0da20b169e 100644 --- a/sdk/ai/Azure.AI.Projects/tests/Samples/Agents/Sample_AzureAISearchToolUsingConnections.cs +++ b/sdk/ai/Azure.AI.Projects/tests/Samples/ClassicAgents/Sample_AzureAISearchToolUsingConnections.cs @@ -27,9 +27,9 @@ public void ConnectionsExample() #else var endpoint = TestEnvironment.PROJECTENDPOINT; var modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; - var indexName = TestEnvironment.INDEXNAME ?? "my-index"; - var indexVersion = TestEnvironment.INDEXVERSION ?? "1.0"; - var aiSearchIndexName = TestEnvironment.AISEARCHINDEXNAME ?? "my-ai-search-index-name"; + var indexName = TestEnvironment.INDEX_NAME ?? "my-index"; + var indexVersion = TestEnvironment.INDEX_VERSION ?? "1.0"; + var aiSearchIndexName = TestEnvironment.AI_SEARCH_INDEX_NAME ?? "my-ai-search-index-name"; #endif AIProjectClient projectClient = new AIProjectClient(new Uri(endpoint), new DefaultAzureCredential()); diff --git a/sdk/ai/Azure.AI.Projects/tests/Samples/Agents/Sample_VectorStoreWithDatasets.cs b/sdk/ai/Azure.AI.Projects/tests/Samples/ClassicAgents/Sample_VectorStoreWithDatasets.cs similarity index 100% rename from sdk/ai/Azure.AI.Projects/tests/Samples/Agents/Sample_VectorStoreWithDatasets.cs rename to sdk/ai/Azure.AI.Projects/tests/Samples/ClassicAgents/Sample_VectorStoreWithDatasets.cs diff --git a/sdk/ai/Azure.AI.Projects/tests/Samples/FineTuning/Sample_Files.cs b/sdk/ai/Azure.AI.Projects/tests/Samples/FineTuning/Sample_Files.cs new file mode 100644 index 000000000000..16f2b6f12d52 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/tests/Samples/FineTuning/Sample_Files.cs @@ -0,0 +1,236 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable +#pragma warning disable OPENAI001 // Type is for evaluation purposes only + +using System; +using System.ClientModel; +using System.IO; +using System.Threading.Tasks; +using Azure.Core.TestFramework; +using NUnit.Framework; +using Azure.AI.Projects.OpenAI; +using OpenAI.Files; + +namespace Azure.AI.Projects.Tests; + +internal class Sample_Files : SamplesBase +{ + private string GetDataDirectory() + { + var testDirectory = Path.GetDirectoryName(typeof(Sample_Files).Assembly.Location); + while (testDirectory != null && !Directory.Exists(Path.Combine(testDirectory, "sdk"))) + { + testDirectory = Path.GetDirectoryName(testDirectory); + } + return Path.Combine(testDirectory!, "sdk", "ai", "Azure.AI.Projects", "tests", "Samples", "FineTuning", "data"); + } + + [Test] + [AsyncOnly] + public async Task FileCRUDExample() + { + #region Snippet:AI_Projects_FileOperationsAsync +#if SNIPPET + var endpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT"); +#else + var endpoint = TestEnvironment.PROJECTENDPOINT; +#endif + AIProjectClient projectClient = new(new Uri(endpoint), new DefaultAzureCredential()); + ProjectFilesClient fileClient = projectClient.OpenAI.Files; + + // Upload file + var dataDirectory = GetDataDirectory(); + var testFilePath = Path.Combine(dataDirectory, "training_set.jsonl"); + OpenAIFile uploadedFile = await fileClient.UploadFileAsync( + testFilePath, + FileUploadPurpose.FineTune); + + string fileId = uploadedFile.Id; + + // Retrieve file metadata + OpenAIFile retrievedFile = await fileClient.GetFileAsync(fileId); + Console.WriteLine($"File ID: {retrievedFile.Id}, Filename: {retrievedFile.Filename}"); + + // Download file content + BinaryData fileContent = await fileClient.DownloadFileAsync(fileId); + Console.WriteLine($"Content size: {fileContent.ToMemory().Length} bytes"); + + // List all files + ClientResult filesResult = await fileClient.GetFilesAsync(); + foreach (OpenAIFile file in filesResult.Value) + { + Console.WriteLine($"File: {file.Filename} (ID: {file.Id})"); + } + + // Delete file + ClientResult deleteResult = await fileClient.DeleteFileAsync(fileId); + Console.WriteLine($"File deleted: {deleteResult.Value.Deleted}"); + #endregion + } + + [Test] + [AsyncOnly] + public async Task FileOperationsAsync() + { + var endpoint = TestEnvironment.PROJECTENDPOINT; + var dataDirectory = GetDataDirectory(); + var testFilePath = Path.Combine(dataDirectory, "training_set.jsonl"); + var projectClient = new AIProjectClient(new Uri(endpoint), new DefaultAzureCredential()); + OpenAIFileClient fileClient = projectClient.OpenAI.Files; + + // Step 1: Upload a file + Console.WriteLine("\n=== Step 1: Uploading File ==="); + Console.WriteLine($"Uploading file from: {testFilePath}"); + + // Verify file exists and is not empty + if (!File.Exists(testFilePath)) + { + throw new FileNotFoundException($"Test file not found: {testFilePath}"); + } + + FileInfo fileInfo = new FileInfo(testFilePath); + Console.WriteLine($"File size on disk: {fileInfo.Length} bytes"); + + if (fileInfo.Length == 0) + { + throw new InvalidOperationException($"Test file is empty: {testFilePath}"); + } + + OpenAIFile uploadedFile; + using (FileStream fileStream = File.OpenRead(testFilePath)) + { + Console.WriteLine($"FileStream length: {fileStream.Length} bytes"); + Console.WriteLine($"FileStream can read: {fileStream.CanRead}"); + + uploadedFile = await fileClient.UploadFileAsync( + fileStream, + "training_set.jsonl", + FileUploadPurpose.FineTune); + } + Console.WriteLine($"✅ File uploaded successfully!"); + Console.WriteLine($" File ID: {uploadedFile.Id}"); + Console.WriteLine($" Filename: {uploadedFile.Filename}"); + Console.WriteLine($" Purpose: {uploadedFile.Purpose}"); + Console.WriteLine($" Size: {uploadedFile.SizeInBytes} bytes"); + Console.WriteLine($" Created At: {uploadedFile.CreatedAt}"); + + // Use the uploaded file ID + string fileId = uploadedFile.Id; + + // Step 2: Retrieve file metadata by ID + Console.WriteLine("\n=== Step 2: Retrieving File Metadata ==="); + Console.WriteLine($"Retrieving metadata for file ID: {fileId}"); + OpenAIFile retrievedFile = await fileClient.GetFileAsync(fileId); + Console.WriteLine($"✅ File metadata retrieved successfully!"); + Console.WriteLine($" File ID: {retrievedFile.Id}"); + Console.WriteLine($" Filename: {retrievedFile.Filename}"); + Console.WriteLine($" Purpose: {retrievedFile.Purpose}"); + Console.WriteLine($" Size: {retrievedFile.SizeInBytes} bytes"); + + // Step 3: Retrieve file content + Console.WriteLine("\n=== Step 3: Retrieving File Content ==="); + Console.WriteLine($"Downloading content for file ID: {fileId}"); + BinaryData fileContent = await fileClient.DownloadFileAsync(fileId); + Console.WriteLine($"✅ File content retrieved successfully!"); + Console.WriteLine($" Content size: {fileContent.ToMemory().Length} bytes"); + + // Assert downloaded content matches expected size + Assert.IsNotNull(fileContent, "Downloaded file content should not be null"); + Assert.IsTrue(fileContent.ToMemory().Length > 0, "Downloaded content should not be empty"); + + // Display first few lines of content + string contentStr = fileContent.ToString(); + string[] lines = contentStr.Split('\n'); + int linesToShow = Math.Min(3, lines.Length); + Console.WriteLine($" First {linesToShow} line(s) of content:"); + for (int i = 0; i < linesToShow; i++) + { + string line = lines[i].Length > 100 ? lines[i].Substring(0, 100) + "..." : lines[i]; + Console.WriteLine($" {line}"); + } + + // Step 4: List all files + Console.WriteLine("\n=== Step 4: Listing All Files ==="); + Console.WriteLine("Retrieving list of all files..."); + int fileCount = 0; + bool foundUploadedFile = false; + ClientResult filesResult = await fileClient.GetFilesAsync(); + foreach (OpenAIFile file in filesResult.Value) + { + fileCount++; + Console.WriteLine($"- File {fileCount}:"); + Console.WriteLine($" ID: {file.Id}"); + Console.WriteLine($" Filename: {file.Filename}"); + Console.WriteLine($" Purpose: {file.Purpose}"); + Console.WriteLine($" Size: {file.SizeInBytes} bytes"); + + if (file.Id == fileId) + { + foundUploadedFile = true; + Console.WriteLine($" ⭐ This is our uploaded file!"); + } + + if (fileCount >= 5) + { + Console.WriteLine(" ... (showing first 5 files)"); + break; + } + } + Console.WriteLine($"✅ Listed {fileCount} file(s)"); + + // Assert that we listed at least one file + Assert.IsTrue(fileCount > 0, "Should have listed at least one file"); + + if (foundUploadedFile) + { + Console.WriteLine($"✅ Confirmed our uploaded file is in the list"); + } + + // Assert that our uploaded file is in the list + Assert.IsTrue(foundUploadedFile, "Uploaded file should appear in the list of files"); + + // Step 5: Delete the file + Console.WriteLine("\n=== Step 5: Deleting File ==="); + Console.WriteLine($"Deleting file with ID: {fileId}"); + ClientResult deleteResult = await fileClient.DeleteFileAsync(fileId); + Console.WriteLine($"✅ File deleted successfully! Deleted: {deleteResult.Value.Deleted}"); + + // Step 6: Verify file is deleted + Console.WriteLine("\n=== Step 6: Verifying File Deletion ==="); + Console.WriteLine("Checking if file still exists in list..."); + bool fileStillExists = false; + int verifyCount = 0; + ClientResult verifyFilesResult = await fileClient.GetFilesAsync(); + foreach (OpenAIFile file in verifyFilesResult.Value) + { + verifyCount++; + if (file.Id == fileId) + { + fileStillExists = true; + break; + } + + // Only check first 50 files to avoid long iteration + if (verifyCount >= 50) + { + break; + } + } + + if (fileStillExists) + { + Console.WriteLine($"⚠️ Warning: File still appears in list after deletion"); + } + else + { + Console.WriteLine($"✅ Confirmed: File no longer appears in the list"); + } + + // Assert file no longer exists in the list + Assert.IsFalse(fileStillExists, "Deleted file should not appear in the list of files"); + + Console.WriteLine("\n=== File Operations Completed Successfully! ==="); + } +} diff --git a/sdk/ai/Azure.AI.Projects/tests/Samples/FineTuning/data/training_set.jsonl b/sdk/ai/Azure.AI.Projects/tests/Samples/FineTuning/data/training_set.jsonl new file mode 100644 index 000000000000..33b9e82ee8bf --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/tests/Samples/FineTuning/data/training_set.jsonl @@ -0,0 +1,10 @@ +{"messages": [{"role": "system", "content": "Clippy is a factual chatbot that is also sarcastic."}, {"role": "user", "content": "Who discovered Antarctica?"}, {"role": "assistant", "content": "Some chaps named Fabian Gottlieb von Bellingshausen and Mikhail Lazarev, as if they don't teach that in every school!"}]} +{"messages": [{"role": "system", "content": "Clippy is a factual chatbot that is also sarcastic."}, {"role": "user", "content": "What is the biggest ocean?"}, {"role": "assistant", "content": "The Pacific Ocean. It's not like it's a small pond or anything."}]} +{"messages": [{"role": "system", "content": "Clippy is a factual chatbot that is also sarcastic."}, {"role": "user", "content": "What is the largest planet?"}, {"role": "assistant", "content": "It's called Jupiter, you might have heard of it...or not."}]} +{"messages": [{"role": "system", "content": "Clippy is a factual chatbot that is also sarcastic."}, {"role": "user", "content": "Who painted the Mona Lisa?"}, {"role": "assistant", "content": "Oh, some obscure artist named Leonardo da Vinci. Not that he is famous or anything."}]} +{"messages": [{"role": "system", "content": "Clippy is a factual chatbot that is also sarcastic."}, {"role": "user", "content": "What's the boiling point of water?"}, {"role": "assistant", "content": "Exciting fact of the day: it's 100 degrees Celsius. Life-changing, isn't it?"}]} +{"messages": [{"role": "system", "content": "Clippy is a factual chatbot that is also sarcastic."}, {"role": "user", "content": "Who wrote 'The Odyssey'?"}, {"role": "assistant", "content": "Oh, just some poet named Homer. Nothing special, really."}]} +{"messages": [{"role": "system", "content": "Clippy is a factual chatbot that is also sarcastic."}, {"role": "user", "content": "What is the largest mammal?"}, {"role": "assistant", "content": "Blue Whale. Quite a big fish isn't it? Oh wait, it's not a fish!"}]} +{"messages": [{"role": "system", "content": "Clippy is a factual chatbot that is also sarcastic."}, {"role": "user", "content": "What's the highest mountain peak?"}, {"role": "assistant", "content": "Everest. Brace yourself, it's not a walk in the park."}]} +{"messages": [{"role": "system", "content": "Clippy is a factual chatbot that is also sarcastic."}, {"role": "user", "content": "Who invented the telephone?"}, {"role": "assistant", "content": "A guy named Alexander Graham Bell. Bet you didn't guess that one!"}]} +{"messages": [{"role": "system", "content": "Clippy is a factual chatbot that is also sarcastic."}, {"role": "user", "content": "What is the distance from Earth to the Sun?"}, {"role": "assistant", "content": "About 93 million miles. Just a quick drive, really."}]} \ No newline at end of file diff --git a/sdk/ai/Azure.AI.Projects/tests/Samples/Indexes/Sample_Indexes.cs b/sdk/ai/Azure.AI.Projects/tests/Samples/Indexes/Sample_Indexes.cs index e67999726add..ce6a170c2637 100644 --- a/sdk/ai/Azure.AI.Projects/tests/Samples/Indexes/Sample_Indexes.cs +++ b/sdk/ai/Azure.AI.Projects/tests/Samples/Indexes/Sample_Indexes.cs @@ -65,10 +65,10 @@ public void IndexesExample() AIProjectClient projectClient = new AIProjectClient(new Uri(endpoint), new DefaultAzureCredential()); #else var endpoint = TestEnvironment.PROJECTENDPOINT; - var indexName = TestEnvironment.INDEXNAME ?? "my-index"; - var indexVersion = TestEnvironment.INDEXVERSION ?? "1.0"; - var aiSearchConnectionName = TestEnvironment.AISEARCHCONNECTIONNAME ?? "my-ai-search-connection-name"; - var aiSearchIndexName = TestEnvironment.AISEARCHINDEXNAME ?? "my-ai-search-index-name"; + var indexName = TestEnvironment.INDEX_NAME ?? "my-index"; + var indexVersion = TestEnvironment.INDEX_VERSION ?? "1.0"; + var aiSearchConnectionName = TestEnvironment.AI_SEARCH_CONNECTION_NAME ?? "my-ai-search-connection-name"; + var aiSearchIndexName = TestEnvironment.AI_SEARCH_INDEX_NAME ?? "my-ai-search-index-name"; AIProjectClient projectClient = CreateDebugClient(endpoint); #endif @@ -122,10 +122,10 @@ public async Task IndexesExampleAsync() AIProjectClient projectClient = new(new Uri(endpoint), new DefaultAzureCredential()); #else var endpoint = TestEnvironment.PROJECTENDPOINT; - var indexName = TestEnvironment.INDEXNAME ?? "my-index"; - var indexVersion = TestEnvironment.INDEXVERSION ?? "1.0"; - var aiSearchConnectionName = TestEnvironment.AISEARCHCONNECTIONNAME ?? "my-ai-search-connection-name"; - var aiSearchIndexName = TestEnvironment.AISEARCHINDEXNAME ?? "my-ai-search-index-name"; + var indexName = TestEnvironment.INDEX_NAME ?? "my-index"; + var indexVersion = TestEnvironment.INDEX_VERSION ?? "1.0"; + var aiSearchConnectionName = TestEnvironment.AI_SEARCH_CONNECTION_NAME ?? "my-ai-search-connection-name"; + var aiSearchIndexName = TestEnvironment.AI_SEARCH_INDEX_NAME ?? "my-ai-search-index-name"; AIProjectClient projectClient = CreateDebugClient(endpoint); #endif diff --git a/sdk/ai/Azure.AI.Projects/tests/Samples/Inference/Sample_AzureOpenAI_Chat.cs b/sdk/ai/Azure.AI.Projects/tests/Samples/Inference/Sample_AzureOpenAI_Chat.cs index 9b6102d5d774..e6023e03ef46 100644 --- a/sdk/ai/Azure.AI.Projects/tests/Samples/Inference/Sample_AzureOpenAI_Chat.cs +++ b/sdk/ai/Azure.AI.Projects/tests/Samples/Inference/Sample_AzureOpenAI_Chat.cs @@ -30,7 +30,7 @@ public void AzureOpenAIChatCompletion() var connectionName = ""; try { - connectionName = TestEnvironment.AOAICONNECTIONNAME; + connectionName = TestEnvironment.AOAI_CONNECTION_NAME; } catch { @@ -74,7 +74,7 @@ public async Task AzureOpenAIChatCompletionAsync() var connectionName = ""; try { - connectionName = TestEnvironment.AOAICONNECTIONNAME; + connectionName = TestEnvironment.AOAI_CONNECTION_NAME; } catch { diff --git a/sdk/ai/Azure.AI.Projects/tests/Samples/Inference/Sample_AzureOpenAI_Embeddings.cs b/sdk/ai/Azure.AI.Projects/tests/Samples/Inference/Sample_AzureOpenAI_Embeddings.cs index 1c2bd4d9fa23..2232829ba9aa 100644 --- a/sdk/ai/Azure.AI.Projects/tests/Samples/Inference/Sample_AzureOpenAI_Embeddings.cs +++ b/sdk/ai/Azure.AI.Projects/tests/Samples/Inference/Sample_AzureOpenAI_Embeddings.cs @@ -30,7 +30,7 @@ public void AzureOpenAIEmbeddings() var connectionName = ""; try { - connectionName = TestEnvironment.AOAICONNECTIONNAME; + connectionName = TestEnvironment.AOAI_CONNECTION_NAME; } catch { @@ -74,7 +74,7 @@ public async Task AzureOpenAIEmbeddingsAsync() var connectionName = ""; try { - connectionName = TestEnvironment.AOAICONNECTIONNAME; + connectionName = TestEnvironment.AOAI_CONNECTION_NAME; } catch { diff --git a/sdk/ai/Azure.AI.Projects/tests/TelemetryTest.cs b/sdk/ai/Azure.AI.Projects/tests/TelemetryTest.cs index bed9c12d3c67..3c33e506eb9a 100644 --- a/sdk/ai/Azure.AI.Projects/tests/TelemetryTest.cs +++ b/sdk/ai/Azure.AI.Projects/tests/TelemetryTest.cs @@ -21,6 +21,7 @@ public TelemetryTest(bool isAsync) : base(isAsync) //, RecordedTestMode.Record) [TestCase] [RecordedTest] + [Ignore("Pending Microsoft.ClientModel.TestFramework migration")] public async Task TelemetryOperationsTest() { AIProjectClient projectClient = GetTestClient(); diff --git a/sdk/ai/Azure.AI.Projects/tests/Utils/TestPipelinePolicy.cs b/sdk/ai/Azure.AI.Projects/tests/Utils/TestPipelinePolicy.cs new file mode 100644 index 000000000000..d5f622d4180e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/tests/Utils/TestPipelinePolicy.cs @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Azure.AI.Projects.Tests; + +internal partial class TestPipelinePolicy : PipelinePolicy +{ + private Action _processMessageAction; + + public TestPipelinePolicy(Action processMessageAction) + { + _processMessageAction = processMessageAction; + } + + public override void Process(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) + { + _processMessageAction(message); // for request + ProcessNext(message, pipeline, currentIndex); + _processMessageAction(message); // for response + } + + public override async ValueTask ProcessAsync(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) + { + _processMessageAction(message); // for request + await ProcessNextAsync(message, pipeline, currentIndex); + _processMessageAction(message); // for response + } +} diff --git a/sdk/ai/Azure.AI.Projects/tests_agents/AIAgentsTestEnvironment.cs b/sdk/ai/Azure.AI.Projects/tests_agents/AIAgentsTestEnvironment.cs new file mode 100644 index 000000000000..4ecb473ae2e6 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/tests_agents/AIAgentsTestEnvironment.cs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.ClientModel; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure.Identity; +using Microsoft.ClientModel.TestFramework; + +namespace Azure.AI.Projects.Tests +{ + public class AIAgentsTestEnvironment : TestEnvironment + { + public string PROJECT_ENDPOINT => GetRecordedVariable("PROJECT_ENDPOINT"); + public string AGENT_NAME => GetRecordedVariable("AZURE_AI_FOUNDRY_AGENT_NAME"); + public string MODELDEPLOYMENTNAME => GetRecordedVariable("MODEL_DEPLOYMENT_NAME"); + public string COMPUTER_USE_DEPLOYMENT_NAME => GetRecordedVariable("COMPUTER_USE_DEPLOYMENT_NAME"); + + public override Dictionary ParseEnvironmentFile() => new() + { + { "OPEN-API-KEY", Environment.GetEnvironmentVariable("OPENAI_API_KEY") ?? "api-key" } + }; + + public override Task WaitForEnvironmentAsync() + { + return Task.CompletedTask; + } + + public override AuthenticationTokenProvider Credential => Mode switch + { + RecordedTestMode.Live or RecordedTestMode.Record => new DefaultAzureCredential(), + _ => base.Credential + }; + public string EMBEDDINGMODELDEPLOYMENTNAME => GetRecordedVariable("EMBEDDING_MODEL_DEPLOYMENT_NAME"); + public string CONTAINER_APP_RESOURCE_ID => GetRecordedVariable("CONTAINER_APP_RESOURCE_ID"); + public string INGRESS_SUBDOMAIN_SUFFIX => GetRecordedVariable("INGRESS_SUBDOMAIN_SUFFIX"); + public string OPENAI_FILE_ID => GetRecordedVariable("OPENAI_FILE_ID"); + public string COMPUTER_SCREENSHOTS => GetRecordedVariable("COMPUTER_SCREENSHOTS"); + public string IMAGE_GENERATION_DEPLOYMENT_NAME => GetRecordedVariable("IMAGE_GENERATION_DEPLOYMENT_NAME"); + } +} diff --git a/sdk/ai/Azure.AI.Projects/tests_agents/AgentsSmokeTests.cs b/sdk/ai/Azure.AI.Projects/tests_agents/AgentsSmokeTests.cs new file mode 100644 index 000000000000..8aa6fca3cc34 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/tests_agents/AgentsSmokeTests.cs @@ -0,0 +1,232 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +using System; +using System.ClientModel.Primitives; +using Azure.AI.Projects; +using Azure.AI.Projects.OpenAI; +using Azure.Identity; +using Microsoft.ClientModel.TestFramework; +using NUnit.Framework; +using OpenAI.Responses; + +namespace Azure.AI.Projects.Tests; + +[Category("Smoke")] +[SyncOnly] +public class AgentsSmokeTests : AgentsTestBase +{ + public AgentsSmokeTests(bool isAsync) : base(isAsync, RecordedTestMode.Live) + { + } + + [Test] + [LiveOnly] + public void CanGetClients() + { + AIProjectClient projectClient = new( + new Uri("https://ai.azure.com/mock/endpoint/api/projects/myProject"), + new MockCredential()); + Assert.That(projectClient, Is.Not.Null); + AIProjectAgentsOperations agentClient = projectClient.Agents; + Assert.That(agentClient, Is.Not.Null); + ProjectOpenAIClient openAIClient = projectClient.OpenAI; + Assert.That(openAIClient, Is.Not.Null); + + ProjectOpenAIClient projectOpenAIClient = projectClient.GetProjectOpenAIClient(new ProjectOpenAIClientOptions()); + Assert.That(projectOpenAIClient, Is.Not.Null); + } + + [Test] + public void TestResponseItemExtension() + { + string rawStructuredInputsItem = """ + { + "type": "structured_inputs", + "inputs": { + "hello": "world" + } + } + """; + + ResponseItem item = ModelReaderWriter.Read(BinaryData.FromString(rawStructuredInputsItem)); + Assert.That(item, Is.Not.Null); + + AgentResponseItem agentResponseItem = item.AsAgentResponseItem(); + Assert.That(agentResponseItem, Is.Not.Null); + + ResponseItem revertedResponseItem = agentResponseItem; + Assert.That(revertedResponseItem, Is.Not.Null); + } + + //[Test] + //public void TestUseAnAgentTool() + //{ + // ResponseCreationOptions responseOptions = new() + // { + // Tools = + // { + // ResponseTool.CreateWebSearchTool(), + // AgentTool.CreateA2ATool(new Uri("https://test-uri.microsoft.com")), + // new A2ATool(new Uri("https://test-uri.microsoft.com")), + // AgentTool.CreateAzureAISearchTool(), + // new AzureAISearchAgentTool(), + // AgentTool.CreateAzureAISearchTool(new AzureAISearchToolOptions() + // { + // Indexes = { new AzureAISearchIndex(projectConnectionId: "project-foo") { TopK = 42 } } + // }), + // } + // }; + + // Assert.That(responseOptions.Tools, Has.Count.EqualTo(6)); + + // string serializedOptions = ModelReaderWriter.Write(responseOptions).ToString(); + // Assert.That(serializedOptions, Does.Contain("base_url")); + // Assert.That(serializedOptions, Does.Contain("topK")); + + // OpenAIResponse mockResponse = ModelReaderWriter.Read(BinaryData.FromString(""" + // { + // "id": "resp_09e840ce9e2f16c60068c4c1ce2cc481a3ad9e41ec88e4cbe5", + // "object": "response", + // "created_at": 1757725134, + // "status": "completed", + // "background": false, + // "error": null, + // "incomplete_details": null, + // "instructions": null, + // "max_output_tokens": null, + // "max_tool_calls": null, + // "model": "gpt-4o-mini-2024-07-18", + // "output": [ + // { + // "id": "msg_09e840ce9e2f16c60068c4c1cf253c81a397d15e2efdbcd7dd", + // "type": "message", + // "status": "completed", + // "content": [ + // { + // "type": "output_text", + // "annotations": [], + // "logprobs": [], + // "text": "Hello! How can I assist you today?" + // } + // ], + // "role": "assistant" + // } + // ], + // "parallel_tool_calls": true, + // "previous_response_id": null, + // "prompt_cache_key": null, + // "reasoning": { + // "effort": null, + // "summary": null + // }, + // "safety_identifier": null, + // "service_tier": "default", + // "store": true, + // "temperature": 1.0, + // "text": { + // "format": { + // "type": "text" + // }, + // "verbosity": "medium" + // }, + // "tool_choice": "auto", + // "tools": [ + // { + // "type": "web_search_preview", + // "search_context_size": "medium", + // "user_location": { + // "type": "approximate", + // "city": null, + // "country": "US", + // "region": null, + // "timezone": null + // } + // }, + // { + // "type": "a2a_preview", + // "base_url": "https://test-uri.microsoft.com" + // } + // ], + // "top_logprobs": 0, + // "top_p": 1.0, + // "truncation": "disabled", + // "usage": { + // "input_tokens": 305, + // "input_tokens_details": { + // "cached_tokens": 0 + // }, + // "output_tokens": 11, + // "output_tokens_details": { + // "reasoning_tokens": 0 + // }, + // "total_tokens": 316 + // }, + // "user": null, + // "metadata": {} + // } + // """)); + + // Assert.That(mockResponse.Tools, Has.Count.EqualTo(2)); + + // A2ATool a2aToolFromResponse = mockResponse.Tools[1].AsAgentTool() as A2ATool; + // Assert.That(a2aToolFromResponse?.BaseUrl.AbsoluteUri, Does.Contain("microsoft.com")); + //} + + [Test] + public void TestPromptAgentSerialization() + { + PromptAgentDefinition agent = new(model: "test-model"); + Assert.That(ModelReaderWriter.Write(agent).ToString(), Does.Contain("kind")); + + agent = new("test-model") + { + Tools = { ResponseTool.CreateWebSearchTool() }, + }; + Assert.That(ModelReaderWriter.Write(agent).ToString(), Does.Contain("web_search")); + + agent = new("test-model") + { + ReasoningOptions = new() + { + ReasoningEffortLevel = ResponseReasoningEffortLevel.Low, + ReasoningSummaryVerbosity = ResponseReasoningSummaryVerbosity.Concise, + } + }; + Assert.That(ModelReaderWriter.Write(agent).ToString(), Does.Contain(@"""reasoning"":{")); + Assert.That(ModelReaderWriter.Write(agent).ToString(), Does.Contain("concise")); + } + + [Test] + public void TestUseAnAgentReference() + { + ResponseCreationOptions responseOptions = new() + { + Agent = "my-test-agent", + AgentConversationId = "conv_abcd1234", + Instructions = "You talk like a pirate." + }; + + Assert.That(ModelReaderWriter.Write(responseOptions).ToString(), Does.Contain("my-test-agent")); + Assert.That(ModelReaderWriter.Write(responseOptions).ToString(), Does.Contain("conv_abcd1234")); + } + + [Test] + public void ItemDeserializationTest() + { + const string rawItem = """ + { + "role": "user", + "content": "hello, world" + } + """; + BinaryData itemBytes = BinaryData.FromString(rawItem); + + AgentResponseItem asAgentItem = ModelReaderWriter.Read(itemBytes); + } + + [TearDown] + public override void Cleanup() + { + // Nothing here + } +} diff --git a/sdk/ai/Azure.AI.Projects/tests_agents/AgentsTelemetryTests.cs b/sdk/ai/Azure.AI.Projects/tests_agents/AgentsTelemetryTests.cs new file mode 100644 index 000000000000..f66a982e043c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/tests_agents/AgentsTelemetryTests.cs @@ -0,0 +1,418 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using System.ClientModel; +using System.Collections.Generic; +using System.Data; +using System.Diagnostics; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; +using Azure.AI.Projects.OpenAI; +using Azure.AI.Projects.Tests.Utilities; +using Microsoft.ClientModel.TestFramework; +using NUnit.Framework; +using OpenTelemetry; +using OpenTelemetry.Resources; +using OpenTelemetry.Trace; + +namespace Azure.AI.Projects.Tests; + +public partial class AgentsTelemetryTests : AgentsTestBase +{ + public const string TraceContentsEnvironmentVariable = "OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT"; + public const string EnableOpenTelemetryEnvironmentVariable = "AZURE_EXPERIMENTAL_ENABLE_ACTIVITY_SOURCE"; + private MemoryTraceExporter _exporter; + private TracerProvider _tracerProvider; + private bool _contentRecordingEnabledInitialValue = false; + private bool _tracesEnabledInitialValue = false; + + public AgentsTelemetryTests(bool isAsync) : base(isAsync) + { + } + + [SetUp] + public void Setup() + { + _exporter = new MemoryTraceExporter(); + + _tracesEnabledInitialValue = string.Equals( + Environment.GetEnvironmentVariable(TraceContentsEnvironmentVariable), + "true", + StringComparison.OrdinalIgnoreCase); + + _contentRecordingEnabledInitialValue = string.Equals( + Environment.GetEnvironmentVariable(TraceContentsEnvironmentVariable), + "true", + StringComparison.OrdinalIgnoreCase); + + Environment.SetEnvironmentVariable(EnableOpenTelemetryEnvironmentVariable, "true", EnvironmentVariableTarget.Process); + + _tracerProvider = Sdk.CreateTracerProviderBuilder() + .AddSource("*") + .SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("AgentTracingTest")) + .AddProcessor(new SimpleActivityExportProcessor(_exporter)) + .Build(); + } + + [TearDown] + public new void Cleanup() + { + base.Cleanup(); + _tracerProvider.Dispose(); + _exporter.Clear(); + Environment.SetEnvironmentVariable( + TraceContentsEnvironmentVariable, + _contentRecordingEnabledInitialValue.ToString(), + EnvironmentVariableTarget.Process); + Environment.SetEnvironmentVariable( + TraceContentsEnvironmentVariable, + _tracesEnabledInitialValue.ToString(), + EnvironmentVariableTarget.Process); + } + + private string GetModelDeploymentName() + { + //string modelDeploymentName = TestEnvironment.MODELDEPLOYMENTNAME; + //return modelDeploymentName; + return TestEnvironment.MODELDEPLOYMENTNAME; + } + + [RecordedTest] + public async Task TestAgentCreateWithTracingActivitySourceDisabled() + { + Environment.SetEnvironmentVariable(TraceContentsEnvironmentVariable, "true", EnvironmentVariableTarget.Process); + Environment.SetEnvironmentVariable(EnableOpenTelemetryEnvironmentVariable, "false", EnvironmentVariableTarget.Process); + ReinitializeOpenTelemetryScopeConfiguration(); + + AIProjectClient projectClient = GetTestProjectClient(); + var modelDeploymentName = GetModelDeploymentName(); + var agentName = "agentsTelemetryTests1"; + + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a prompt agent." + }; + + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName, + new AgentVersionCreationOptions(agentDefinition)); + + await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentName, agentVersion: agentVersion.Version); + + // Force flush spans + _exporter.ForceFlush(); + + var createAgentSpan = _exporter.GetExportedActivities().FirstOrDefault(s => s.DisplayName == $"create_agent {agentName}"); + Assert.That(createAgentSpan, Is.Null); + } + + [RecordedTest] + public async Task TestAgentCreateWithTracingContentRecordingEnabled() + { + Environment.SetEnvironmentVariable(TraceContentsEnvironmentVariable, "true", EnvironmentVariableTarget.Process); + Environment.SetEnvironmentVariable(EnableOpenTelemetryEnvironmentVariable, "true", EnvironmentVariableTarget.Process); + ReinitializeOpenTelemetryScopeConfiguration(); + + AIProjectClient projectClient = GetTestProjectClient(); + var modelDeploymentName = GetModelDeploymentName(); + var agentName = "agentsTelemetryTests2"; + + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a prompt agent." + }; + + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: agentName, + options: new(agentDefinition)); + + await projectClient.Agents.DeleteAgentAsync(agentName: agentName); + + // Force flush spans + _exporter.ForceFlush(); + + var createAgentSpan = _exporter.GetExportedActivities().FirstOrDefault(s => s.DisplayName == $"create_agent {agentName}"); + Assert.That(createAgentSpan, Is.Not.Null); + CheckCreateAgentTrace(createAgentSpan, modelDeploymentName, agentName, "{\"content\":\"You are a prompt agent.\"}"); + } + + [RecordedTest] + public async Task TestAgentCreateWithTracingContentRecordingDisabled() + { + Environment.SetEnvironmentVariable(TraceContentsEnvironmentVariable, "false", EnvironmentVariableTarget.Process); + Environment.SetEnvironmentVariable(EnableOpenTelemetryEnvironmentVariable, "true", EnvironmentVariableTarget.Process); + ReinitializeOpenTelemetryScopeConfiguration(); + + AIProjectClient projectClient = GetTestProjectClient(); + var modelDeploymentName = GetModelDeploymentName(); + var agentName = "agentsTelemetryTests3"; + + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a prompt agent." + }; + + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: agentName, + options: new(agentDefinition)); + + await projectClient.Agents.DeleteAgentAsync(agentName: agentName); + + // Force flush spans + _exporter.ForceFlush(); + + var createAgentSpan = _exporter.GetExportedActivities().FirstOrDefault(s => s.DisplayName == $"create_agent {agentName}"); + Assert.That(createAgentSpan, Is.Not.Null); + CheckCreateAgentTrace(createAgentSpan, modelDeploymentName, agentName, "\"\""); + } + + [RecordedTest] + public async Task TestAgentUpdateWithTracingContentRecordingEnabled() + { + Environment.SetEnvironmentVariable(TraceContentsEnvironmentVariable, "true", EnvironmentVariableTarget.Process); + Environment.SetEnvironmentVariable(EnableOpenTelemetryEnvironmentVariable, "true", EnvironmentVariableTarget.Process); + ReinitializeOpenTelemetryScopeConfiguration(); + + AIProjectClient projectClient = GetTestProjectClient(); + var modelDeploymentName = GetModelDeploymentName(); + var agentName = "agentsTelemetryTests4"; + + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a prompt agent." + }; + + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: agentName, + options: new(agentDefinition)); + + PromptAgentDefinition updateAgentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a helpful prompt agent." + }; + + ClientResult protocolUpdateResult = await projectClient.Agents.UpdateAgentAsync( + agentName: agentName, + content: BinaryContent.Create(BinaryData.FromString($$""" + { + "definition": { + "kind": "prompt", + "model": "{{updateAgentDefinition.Model}}", + "instructions": "{{updateAgentDefinition.Instructions}}" + } + } + """))); + + await projectClient.Agents.DeleteAgentAsync(agentName: agentName); + + // Force flush spans + _exporter.ForceFlush(); + + var agentSpans = _exporter.GetExportedActivities() + .Where(s => s.DisplayName == $"create_agent {agentName}") + .ToList(); + + // Validate you have the expected number of spans + Assert.That(agentSpans.Count, Is.EqualTo(2), $"Expected exactly 2 spans for create_agent {agentName}, but found {agentSpans.Count}"); + + var createAgentSpan = agentSpans[0]; + var updateAgentSpan = agentSpans[1]; + + Assert.That(createAgentSpan, Is.Not.Null); + Assert.That(updateAgentSpan, Is.Not.Null); + + CheckCreateAgentTrace(updateAgentSpan, modelDeploymentName, agentName, "{\"content\":\"You are a helpful prompt agent.\"}"); + } + + [RecordedTest] + public async Task TestAgentUpdateWithTracingContentRecordingDisabled() + { + Environment.SetEnvironmentVariable(TraceContentsEnvironmentVariable, "false", EnvironmentVariableTarget.Process); + Environment.SetEnvironmentVariable(EnableOpenTelemetryEnvironmentVariable, "true", EnvironmentVariableTarget.Process); + ReinitializeOpenTelemetryScopeConfiguration(); + + AIProjectClient projectClient = GetTestProjectClient(); + var modelDeploymentName = GetModelDeploymentName(); + var agentName = "agentsTelemetryTests5"; + + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a prompt agent." + }; + + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: agentName, + options: new(agentDefinition)); + + PromptAgentDefinition updateAgentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a helpful prompt agent." + }; + + ClientResult protocolUpdateResult = await projectClient.Agents.UpdateAgentAsync( + agentName: agentName, + content: BinaryContent.Create(BinaryData.FromString($$""" + { + "definition": { + "kind": "prompt", + "model": "{{agentDefinition.Model}}", + "instructions": "{{agentDefinition.Instructions}}" + } + } + """))); + + await projectClient.Agents.DeleteAgentAsync(agentName: agentName); + + // Force flush spans + _exporter.ForceFlush(); + + var agentSpans = _exporter.GetExportedActivities() + .Where(s => s.DisplayName == $"create_agent {agentName}") + .ToList(); + + // Validate you have the expected number of spans + Assert.That(agentSpans.Count, Is.EqualTo(2), $"Expected exactly 2 spans for create_agent {agentName}, but found {agentSpans.Count}"); + + var createAgentSpan = agentSpans[0]; + var updateAgentSpan = agentSpans[1]; + + Assert.That(createAgentSpan, Is.Not.Null); + Assert.That(updateAgentSpan, Is.Not.Null); + + CheckCreateAgentTrace(updateAgentSpan, modelDeploymentName, agentName, "\"\""); + } + + [RecordedTest] + public async Task TestAgentVersionCreateWithTracingContentRecordingEnabled() + { + Environment.SetEnvironmentVariable(TraceContentsEnvironmentVariable, "true", EnvironmentVariableTarget.Process); + Environment.SetEnvironmentVariable(EnableOpenTelemetryEnvironmentVariable, "true", EnvironmentVariableTarget.Process); + ReinitializeOpenTelemetryScopeConfiguration(); + + AIProjectClient projectClient = GetTestProjectClient(); + var modelDeploymentName = GetModelDeploymentName(); + var agentName = "agentsTelemetryTests6"; + + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a prompt agent." + }; + + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: agentName, + options: new AgentVersionCreationOptions(agentDefinition)); + + await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentName, agentVersion: agentVersion.Version); + + // Force flush spans + _exporter.ForceFlush(); + + var createAgentVersionSpan = _exporter.GetExportedActivities().FirstOrDefault(s => s.DisplayName == $"create_agent {agentName}"); + Assert.That(createAgentVersionSpan, Is.Not.Null); + CheckCreateAgentVersionTrace(createAgentVersionSpan, modelDeploymentName, agentName, "{\"content\":\"You are a prompt agent.\"}"); + } + + [RecordedTest] + public async Task TestAgentVersionCreateWithTracingContentRecordingDisabled() + { + Environment.SetEnvironmentVariable(TraceContentsEnvironmentVariable, "false", EnvironmentVariableTarget.Process); + Environment.SetEnvironmentVariable(EnableOpenTelemetryEnvironmentVariable, "true", EnvironmentVariableTarget.Process); + ReinitializeOpenTelemetryScopeConfiguration(); + + AIProjectClient projectClient = GetTestProjectClient(); + var modelDeploymentName = GetModelDeploymentName(); + var agentName = "agentsTelemetryTests7"; + + PromptAgentDefinition agentDefinition = new(model: modelDeploymentName) + { + Instructions = "You are a prompt agent." + }; + + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: agentName, + options: new(agentDefinition)); + + await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentName, agentVersion: agentVersion.Version); + + // Force flush spans + _exporter.ForceFlush(); + + var createAgentVersionSpan = _exporter.GetExportedActivities().FirstOrDefault(s => s.DisplayName == $"create_agent {agentName}"); + Assert.That(createAgentVersionSpan, Is.Not.Null); + CheckCreateAgentVersionTrace(createAgentVersionSpan, modelDeploymentName, agentName, "\"\""); + } + + private static void ReinitializeOpenTelemetryScopeConfiguration() + { + Assembly assembly = typeof(AIProjectAgentsOperations).Assembly; + Assert.That(assembly, Is.Not.Null); + Type openTelemetryScopeType = assembly.GetType("Azure.AI.Projects.Telemetry.OpenTelemetryScope"); + Assert.That(openTelemetryScopeType, Is.Not.Null); + MethodInfo reinitializeConfigurationMethod = openTelemetryScopeType.GetMethod("ReinitializeConfiguration", BindingFlags.Static | BindingFlags.NonPublic); + Assert.That(reinitializeConfigurationMethod, Is.Not.Null); + reinitializeConfigurationMethod.Invoke(null, null); + } + + #region Helpers + private void CheckCreateAgentTrace(Activity createAgentSpan, string modelName, string agentName, string content) + { + Assert.That(createAgentSpan, Is.Not.Null); + var expectedCreateAgentAttributes = new Dictionary + { + { "gen_ai.system", "az.ai.agents" }, + { "gen_ai.operation.name", "create_agent" }, + { "server.address", "*" }, + { "az.namespace", "Microsoft.CognitiveServices" }, + { "gen_ai.request.model", modelName }, + { "gen_ai.agent.name", agentName }, + { "gen_ai.agent.id", "*" } + }; + GenAiTraceVerifier.ValidateSpanAttributes(createAgentSpan, expectedCreateAgentAttributes); + var expectedCreateAgentEvents = new List<(string, Dictionary)> + { + ("gen_ai.system.message", new Dictionary + { + { "gen_ai.system", "az.ai.agents" }, + { "gen_ai.event.content", content } + }) + }; + GenAiTraceVerifier.ValidateSpanEvents(createAgentSpan, expectedCreateAgentEvents); + } + + private void CheckCreateAgentVersionTrace(Activity createAgentSpan, string modelName, string agentName, string content) + { + Assert.That(createAgentSpan, Is.Not.Null); + var expectedCreateAgentAttributes = new Dictionary + { + { "gen_ai.system", "az.ai.agents" }, + { "gen_ai.operation.name", "create_agent" }, + { "server.address", "*" }, + { "az.namespace", "Microsoft.CognitiveServices" }, + { "gen_ai.request.model", modelName }, + { "gen_ai.agent.name", agentName }, + { "gen_ai.agent.version", "1" }, + { "gen_ai.agent.id", "*" } + }; + GenAiTraceVerifier.ValidateSpanAttributes(createAgentSpan, expectedCreateAgentAttributes); + var expectedCreateAgentEvents = new List<(string, Dictionary)> + { + ("gen_ai.system.message", new Dictionary + { + { "gen_ai.system", "az.ai.agents" }, + { "gen_ai.event.content", content } + }) + }; + GenAiTraceVerifier.ValidateSpanEvents(createAgentSpan, expectedCreateAgentEvents); + } + + private async Task WaitMayBe(int timeout = 1000) + { + if (Mode != RecordedTestMode.Playback) + await Task.Delay(timeout); + } + #endregion +} diff --git a/sdk/ai/Azure.AI.Projects/tests_agents/AgentsTestBase.cs b/sdk/ai/Azure.AI.Projects/tests_agents/AgentsTestBase.cs new file mode 100644 index 000000000000..3009ecbecfe7 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/tests_agents/AgentsTestBase.cs @@ -0,0 +1,448 @@ +// 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.IO; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Text.Json; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +using Azure.AI.Projects; +using Azure.AI.Projects.OpenAI; +using Azure.Identity; +using Microsoft.ClientModel.TestFramework; +using NUnit.Framework; +using OpenAI; +using OpenAI.Responses; +using OpenAI.VectorStores; + +namespace Azure.AI.Projects.Tests; +#pragma warning disable OPENAICUA001 + +public class AgentsTestBase : RecordedTestBase +{ + #region Enumerations + public enum ToolType + { + None, + CodeInterpreter, + FileSearch, + FunctionCall, + ComputerUse, + ImageGeneration, + WebSearch, + AzureAISearch, + AzureFunction, + BingGrounding, + MCP, + OpenAPI, + A2A, + BrowserAutomation, + MicrosoftFabric, + Sharepoint, + ConnectedAgent, + DeepResearch, + } + + public Dictionary ToolPrompts = new() + { + {ToolType.None, "Hello, tell me a joke."}, + {ToolType.FunctionCall, "What is the nickname for Seattle, WA?" }, + {ToolType.ComputerUse, "I need you to help me search for 'OpenAI news'. Please type 'OpenAI news' and submit the search. Once you see search results, the task is complete." }, + {ToolType.ImageGeneration, "Generate an image of Microsoft logo."}, + {ToolType.WebSearch, "What is special about this place?"}, + {ToolType.BingGrounding, "How does wikipedia explain Euler's Identity?" }, + {ToolType.OpenAPI, "What's the weather in Seattle?"}, + {ToolType.DeepResearch, "Research the current state of studies on orca intelligence and orca language, " + + "including what is currently known about orcas' cognitive capabilities, " + + "communication systems and problem-solving reflected in recent publications in top their scientific " + + "journals like Science, Nature and PNAS."}, + {ToolType.AzureAISearch, "What is the temperature rating of the cozynights sleeping bag?"}, + {ToolType.ConnectedAgent, "What is the Microsoft stock price?"}, + {ToolType.FileSearch, "Can you give me the documented codes for 'banana' and 'orange'?"}, + {ToolType.AzureFunction, "What is the most prevalent element in the universe? What would foo say?"}, + {ToolType.BrowserAutomation, "Your goal is to report the percent of Microsoft year-to-date stock price change. " + + "To do that, go to the website finance.yahoo.com. " + + "At the top of the page, you will find a search bar." + + "Enter the value 'MSFT', to get information about the Microsoft stock price." + + "At the top of the resulting page you will see a default chart of Microsoft stock price." + + "Click on 'YTD' at the top of that chart, and report the percent value that shows up just below it."}, + {ToolType.MicrosoftFabric, "What are top 3 weather events with largest revenue loss?"}, + {ToolType.Sharepoint, "Hello, summarize the key points of the first document in the list."}, + {ToolType.CodeInterpreter, "Can you give me the documented codes for 'banana' and 'orange'?"}, + }; + + public Dictionary ToolInstructions = new() + { + {ToolType.None, "You are a prompt agent."}, + {ToolType.BingGrounding, "You are helpful agent."}, + {ToolType.ImageGeneration, "Generate images based on user prompts"}, + {ToolType.WebSearch, "You are a helpful assistant that can search the web"}, + {ToolType.FunctionCall, "You are helpful agent. Use the provided functions to help answer questions."}, + {ToolType.ComputerUse, "You are a computer automation assistant.\n\n" + + "Be direct and efficient. When you reach the search results page, read and describe the actual search result titles and descriptions you can see." }, + {ToolType.OpenAPI, "You are helpful agent."}, + {ToolType.DeepResearch, "You are a helpful agent that assists in researching scientific topics."}, + {ToolType.AzureAISearch, "You are a helpful agent that can search for information using Azure AI Search."}, + {ToolType.ConnectedAgent, "You are a helpful assistant, and use the connected agents to get stock prices."}, + {ToolType.FileSearch, "You are helpful agent."}, + {ToolType.BrowserAutomation, "You are an Agent helping with browser automation tasks. " + + "You can answer questions, provide information, and assist with various tasks " + + "related to web browsing using the Browser Automation tool available to you." }, + {ToolType.MicrosoftFabric, "You are helpful agent."}, + {ToolType.Sharepoint, "You are helpful agent."}, + {ToolType.CodeInterpreter, "You are helpful agent."}, + }; + + public Dictionary ExpectedOutput = new() + { + {ToolType.CodeInterpreter, "673457"}, + {ToolType.FileSearch, "673457"}, + {ToolType.FunctionCall, "emerald"}, + {ToolType.WebSearch, "centralia" } + }; + + public Dictionary ExpectedUpdateTypes = new() + { + {ToolType.FileSearch, typeof(StreamingResponseFileSearchCallCompletedUpdate) } + }; + + public Dictionary ExpectedAnnotations = new() + { + {ToolType.FileSearch, typeof(FileCitationMessageAnnotation) } + }; + #endregion + + protected const string AGENT_NAME = "cs-e2e-tests-client"; + protected const string AGENT_NAME2 = "cs-e2e-tests-client2"; + protected const string VECTOR_STORE = "cs-e2e-tests-vector-store"; + protected const string STREAMING_CONSTRAINT = "The test framework does not support iteration of stream in Sync mode."; + private readonly List _conversationIDs = []; + private readonly List _memoryStoreIDs = []; + private ProjectConversationsClient _conversations = null; + private AIProjectMemoryStoresOperations _stores = null; + + private static RecordedTestMode? GetRecordedTestMode() => Environment.GetEnvironmentVariable("AZURE_TEST_MODE") switch + { + "Playback" => RecordedTestMode.Playback, + "Live" => RecordedTestMode.Live, + "Record" => RecordedTestMode.Record, + _ => null + }; + + public AgentsTestBase(bool isAsync) : this(isAsync: isAsync, testMode: GetRecordedTestMode()) { } + + public AgentsTestBase(bool isAsync, RecordedTestMode? testMode = null) : base(isAsync, testMode) + { + } + + protected AIProjectClientOptions CreateTestProjectClientOptions(bool instrument = true, Dictionary headers = null) + => GetConfiguredOptions(new AIProjectClientOptions(), instrument, headers); + + protected ProjectOpenAIClientOptions CreateTestProjectOpenAIClientOptions(Uri endpoint = null, string apiVersion = null, bool instrument = true) + => GetConfiguredOptions( + new ProjectOpenAIClientOptions() + { + Endpoint = endpoint, + ApiVersion = apiVersion, + }, + instrument); + + private T GetConfiguredOptions(T options, bool instrument, Dictionary headers = null) + where T : ClientPipelineOptions + { + options.AddPolicy(GetDumpPolicy(), PipelinePosition.BeforeTransport); + if (headers is not null && headers.Count > 0) + { + options.AddPolicy(new HeaderTestPolicy(headers), PipelinePosition.PerCall); + } + options.AddPolicy( + new TestPipelinePolicy(message => + { + if (Mode == RecordedTestMode.Playback) + { + // TODO: ...why!? + message.Request.Headers.Set("Authorization", "Sanitized"); + } + }), + PipelinePosition.PerCall); + + return instrument ? InstrumentClientOptions(options) : options; + } + + private AuthenticationTokenProvider GetTestTokenProvider() + { + // For local testing if you are using non default account + // add USE_CLI_CREDENTIAL into the .runsettings and set it to true, + // also provide the PATH variable. + // This path should allow launching az command. + if (Mode != RecordedTestMode.Playback && bool.TryParse(Environment.GetEnvironmentVariable("USE_CLI_CREDENTIAL"), out bool cliValue) && cliValue) + { + return new AzureCliCredential(); + } + return TestEnvironment.Credential; + } + + protected AIProjectClient GetTestProjectClient(Dictionary headers=default) + { + AIProjectClientOptions projectClientOptions = CreateTestProjectClientOptions(headers: headers); + AuthenticationTokenProvider provider = TestEnvironment.Credential; + return CreateProxyFromClient(new AIProjectClient(new(TestEnvironment.PROJECT_ENDPOINT), GetTestTokenProvider(), projectClientOptions)); + } + + protected async Task WaitForRun(OpenAIResponseClient responses, OpenAIResponse response, int waitTime=500) + { + while (response.Status != ResponseStatus.Incomplete && response.Status != ResponseStatus.Failed && response.Status != ResponseStatus.Completed) + { + if (Mode != RecordedTestMode.Playback) + await Task.Delay(TimeSpan.FromMilliseconds(waitTime)); + response = await responses.GetResponseAsync(responseId: response.Id); + } + return response; + } + + public static void AssertListEqual(string[] expected, List observed) + { + // Assert.AreEqual(expected.Length, observed.Count, $"The length of arrays are different. Expected: {expected}, Observed: {observed.ToArray()}"); + HashSet expectedHash = [..expected]; + HashSet observedHash = [..observed]; + if (!expectedHash.SetEquals(observedHash)) + { + Assert.Fail($"The members of arrays differ. Expected: {ToPritableString(expected)}, Observed: {ToPritableString(observed)}"); + } + } + + private static string ToPritableString(IEnumerable data) + { + StringBuilder sb = new(); + foreach (string val in data) + { + sb.Append(val); + sb.Append(','); + sb.Append(' '); + } + if (sb.Length > 2) + { + sb.Remove(sb.Length - 2, 2); + } + return sb.ToString(); + } + + protected void IgnoreSampleMayBe() + { + if (Mode != RecordedTestMode.Live) + { + Assert.Ignore("Samples represented as tests only for validation of compilation."); + } + } + + protected static string GetTestFile(string fileName, [CallerFilePath] string pth = "") + { + var dirName = Path.GetDirectoryName(pth) ?? ""; + return Path.Combine(new string[] { dirName, "TestData", fileName }); + } + + #region ToolHelper + private async Task GetVectorStore(OpenAIClient openAIClient) + { + VectorStoreClient vctStoreClient = openAIClient.GetVectorStoreClient(); + VectorStoreCreationOptions vctOptions = new() + { + Name = VECTOR_STORE, + FileIds = { TestEnvironment.OPENAI_FILE_ID } + }; + return await vctStoreClient.CreateVectorStoreAsync( + vctOptions + ); + } + + protected static string GetCityNicknameForTest(string location) => location switch + { + "Seattle, WA" => "The Emerald City", + _ => throw new NotImplementedException(), + }; + + /// + /// Get the AgentDefinition, containing tool of a certain type. + /// + /// + /// + protected async Task GetAgentToolDefinition(ToolType toolType, OpenAIClient oaiClient, string model = default) + { + ResponseTool tool = toolType switch + { + // To run the Code interpreter and file search sample, please upload the file using code below. + // This code cannot be run during tests as recordings are not properly handled by the file upload. + // Upload the file. + // string filePath = "sample_file_for_upload.txt"; + // System.IO.File.WriteAllText( + // path: filePath, + // contents: "The word 'apple' uses the code 442345, while the word 'banana' uses the code 673457."); + // OpenAIFileClient fileClient = projectClient.OpenAI.GetOpenAIFileClient(); + // OpenAIFile uploadedFile = fileClient.UploadFile(filePath: filePath, purpose: FileUploadPurpose.Assistants); + // Console.WriteLine(uploadedFile.id) + ToolType.CodeInterpreter => ResponseTool.CreateCodeInterpreterTool( + new CodeInterpreterToolContainer( + CodeInterpreterToolContainerConfiguration.CreateAutomaticContainerConfiguration( + fileIds: [TestEnvironment.OPENAI_FILE_ID] + ) + ) + ), + ToolType.FileSearch => ResponseTool.CreateFileSearchTool(vectorStoreIds: [(await GetVectorStore(oaiClient)).Id]), + ToolType.FunctionCall => ResponseTool.CreateFunctionTool( + functionName: "GetCityNicknameForTest", + functionDescription: "Gets the nickname of a city, e.g. 'LA' for 'Los Angeles, CA'.", + functionParameters: BinaryData.FromObjectAsJson( + new + { + Type = "object", + Properties = new + { + Location = new + { + Type = "string", + Description = "The city and state, e.g. San Francisco, CA", + }, + }, + Required = new[] { "location" }, + }, + new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase } + ), + strictModeEnabled: false + ), + ToolType.ComputerUse => ResponseTool.CreateComputerTool(environment: new ComputerToolEnvironment("windows"), displayWidth: 1026, displayHeight: 769), + ToolType.ImageGeneration => ResponseTool.CreateImageGenerationTool( + model: TestEnvironment.IMAGE_GENERATION_DEPLOYMENT_NAME, + quality: ImageGenerationToolQuality.Low, + size: ImageGenerationToolSize.W1024xH1024 + ), + ToolType.WebSearch => ResponseTool.CreateWebSearchTool(WebSearchToolLocation.CreateApproximateLocation(country: "US", region: "Pennsylvania", city: "Centralia")), + _ => throw new InvalidOperationException($"Unknown tool type {toolType}") + }; + return new PromptAgentDefinition(model ?? TestEnvironment.MODELDEPLOYMENTNAME) + { + Instructions = ToolInstructions[toolType], + Tools = { tool }, + }; + } + #endregion + #region Cleanup + [TearDown] + public virtual void Cleanup() + { + if (Mode == RecordedTestMode.Playback) + return; + Uri connectionString = new(TestEnvironment.PROJECT_ENDPOINT); + AIProjectClient projectClient = new(connectionString, TestEnvironment.Credential); + + // Remove conversations. + if (_conversations is not null) + { + foreach (string id in _conversationIDs) + { + try + { + _conversations.DeleteConversation(conversationId: id); + } + catch (RequestFailedException ex) + { + // Throw only if it is the error other then "Not found." + if (ex.Status != 404) + throw; + } + } + } + if (_stores != null) + { + foreach (string name in _memoryStoreIDs) + { + try + { + _stores.DeleteMemoryStore(name: name); + } + catch (RequestFailedException ex) + { + // Throw only if it is the error other then "Not found." + if (ex.Status != 404) + throw; + } + } + } + // Remove Vector stores + VectorStoreClient oaiVctStoreClient = projectClient.OpenAI.GetVectorStoreClient(); + foreach (VectorStore vct in oaiVctStoreClient.GetVectorStores().Where(x => (x.Name ?? "").Equals(VECTOR_STORE))) + { + oaiVctStoreClient.DeleteVectorStore(vectorStoreId: vct.Id); + } + // Remove Agents. + foreach (AgentVersion ag in projectClient.Agents.GetAgentVersions(agentName: AGENT_NAME)) + { + projectClient.Agents.DeleteAgentVersion(agentName: ag.Name, agentVersion: ag.Version); + } + foreach (AgentVersion ag in projectClient.Agents.GetAgentVersions(agentName: AGENT_NAME2)) + { + projectClient.Agents.DeleteAgentVersion(agentName: ag.Name, agentVersion: ag.Version); + } + } + #endregion + #region Debug Method + internal static PipelinePolicy GetDumpPolicy() + { + return new TestPipelinePolicy((message) => + { + if (message.Request is not null && message.Response is null) + { + Console.WriteLine($"--- New request ---"); + IEnumerable headerPairs = message?.Request?.Headers?.Select(header => $"{header.Key}={(header.Key.ToLower().Contains("auth") ? "***" : header.Value)}"); + string headers = string.Join(",", headerPairs); + Console.WriteLine($"Headers: {headers}"); + Console.WriteLine($"{message?.Request?.Method} URI: {message?.Request?.Uri}"); + if (message.Request?.Content != null) + { + string contentType = "Unknown Content Type"; + if (message.Request.Headers?.TryGetValue("Content-Type", out contentType) == true + && contentType == "application/json") + { + using MemoryStream stream = new(); + message.Request.Content.WriteTo(stream, default); + stream.Position = 0; + using StreamReader reader = new(stream); + string requestDump = reader.ReadToEnd(); + stream.Position = 0; + requestDump = Regex.Replace(requestDump, @"""data"":[\\w\\r\\n]*""[^""]*""", @"""data"":""..."""); + Console.WriteLine(requestDump); + } + else + { + string length = message.Request.Content.TryComputeLength(out long numberLength) + ? $"{numberLength} bytes" + : "unknown length"; + Console.WriteLine($"<< Non-JSON content: {contentType} >> {length}"); + } + } + } + if (message.Response != null) + { + IEnumerable headerPairs = message?.Response?.Headers?.Select(header => $"{header.Key}={(header.Key.ToLower().Contains("auth") ? "***" : header.Value)}"); + string headers = string.Join(",", headerPairs); + Console.WriteLine($"Response headers: {headers}"); + if (message.BufferResponse) + { + Console.WriteLine("--- Begin response content ---"); + Console.WriteLine(message.Response.Content?.ToString()); + Console.WriteLine("--- End of response content ---"); + } + else + { + Console.WriteLine("--- Response (unbuffered, content not rendered) ---"); + } + } + }); + } + #endregion +} diff --git a/sdk/ai/Azure.AI.Projects/tests_agents/AgentsTests.cs b/sdk/ai/Azure.AI.Projects/tests_agents/AgentsTests.cs new file mode 100644 index 000000000000..74f9dfb4168d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/tests_agents/AgentsTests.cs @@ -0,0 +1,1112 @@ +// 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.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Text.Json; +using System.Text.Json.Nodes; +using System.Threading; +using System.Threading.Tasks; +using Azure.AI.Projects.OpenAI; +using Microsoft.ClientModel.TestFramework; +using NUnit.Framework; +using OpenAI; +using OpenAI.Files; +using OpenAI.Responses; + +namespace Azure.AI.Projects.Tests; +#pragma warning disable OPENAICUA001 + +public class AgentsTests : AgentsTestBase +{ + public AgentsTests(bool isAsync) : base(isAsync) + { + // TestDiagnostics = false; + } + + [RecordedTest] + public async Task TestAgentCRUD() + { + AIProjectClient projectClient = GetTestProjectClient(); + AgentDefinition emptyAgentDefinition = new PromptAgentDefinition(TestEnvironment.MODELDEPLOYMENTNAME); + + const string emptyPromptAgentName = "TestNoVersionAgentFromDotnetTests"; + try + { + await projectClient.Agents.DeleteAgentAsync(emptyPromptAgentName); + } + catch (ClientResultException){ + // We do not have the agent to begin with. + } + AgentVersion newAgentVersion = await projectClient.Agents.CreateAgentVersionAsync( + emptyPromptAgentName, + new AgentVersionCreationOptions(emptyAgentDefinition) + { + Metadata = { ["delete_me"] = "please " }, + }); + Assert.That(newAgentVersion?.Id, Is.Not.Null.And.Not.Empty); + + AgentRecord retrievedAgent = await projectClient.Agents.GetAgentAsync(emptyPromptAgentName); + Assert.That(retrievedAgent?.Id, Is.EqualTo(newAgentVersion.Name)); + + await projectClient.Agents.DeleteAgentAsync(newAgentVersion.Name); + + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync(AGENT_NAME, new AgentVersionCreationOptions(emptyAgentDefinition)); + Assert.That(AGENT_NAME, Is.EqualTo(agentVersion.Name)); + AgentVersion agentVersionObject_ = await projectClient.Agents.GetAgentVersionAsync(agentName: agentVersion.Name, agentVersion: agentVersion.Version); + Assert.That(AGENT_NAME, Is.EqualTo(agentVersionObject_.Name)); + Assert.That(agentVersion.Version, Is.EqualTo(agentVersionObject_.Version)); + Assert.That(agentVersion.Description, Is.Empty); + Assert.That(agentVersion.Metadata, Is.Empty); + // TODO: uncomment this code when the ADO work item 4740406 + // agentVersionObject_ = await projectClient.Agents.CreateAgentVersionAsync(AGENT_NAME2, new PromptAgentDefinition(MODEL_DEPLOYMENT)); + // List agentNames = [.. (await projectClient.Agents.GetAgentsAsync().ToEnumerableAsync()).Select((agv) => agv.Name).Where((name) => name.StartsWith(AGENT_NAME))]; + // AssertListEqual([AGENT_NAME, AGENT_NAME2], agentNames); + await projectClient.Agents.DeleteAgentVersionAsync(agentName: agentVersion.Name, agentVersion: agentVersion.Version); + Assert.ThrowsAsync(async () => await projectClient.Agents.GetAgentVersionAsync(agentVersion.Name, agentVersion.Version)); + // agentNames = [.. (await projectClient.Agents.GetAgentsAsync().ToEnumerableAsync()).Select((agv) => agv.Name).Where((name) => name.StartsWith(AGENT_NAME))]; + // AssertListEqual([AGENT_NAME2], agentNames); + } + + [RecordedTest] + public async Task TestListAgentsAfterAndBefore() + { + AIProjectClient projectClient = GetTestProjectClient(); + // In this test we are assuming that workspace has more then 10 agents. + // If it is not the case create these agents. + int agentLimit = 10; + AsyncCollectionResult agents = projectClient.Agents.GetAgentsAsync(limit: agentLimit, order: "asc"); + + List ids = [.. (await agents.ToEnumerableAsync()).Select(x => x.Id)]; + if (ids.Count < agentLimit) + { + for (int i = ids.Count; i < agentLimit; i++) + { + AgentDefinition definition = new PromptAgentDefinition(TestEnvironment.MODELDEPLOYMENTNAME); + AgentVersion agent = await projectClient.Agents.CreateAgentVersionAsync($"MyAgent_{i}", new AgentVersionCreationOptions(definition)); + ids.Add(agent.Id); + } + } + // Test calling before. + agents = projectClient.Agents.GetAgentsAsync(before: ids[4], limit: 2, order: "asc"); + int idNum = 0; + await foreach (AgentRecord agent in agents) + { + Assert.That(ids[idNum], Is.EqualTo(agent.Id), $"The ID #{idNum} is incorrect."); + idNum++; + } + Assert.That(idNum, Is.EqualTo(2)); + // Test calling after. + agents = projectClient.Agents.GetAgentsAsync(after: ids[idNum - 1], limit: 2, order: "asc"); + await foreach (AgentRecord agent in agents) + { + Assert.That(ids[idNum], Is.EqualTo(agent.Id), $"The ID #{idNum} is incorrect."); + idNum++; + agentLimit--; + if (agentLimit <= 0) + break; + } + } + + [RecordedTest] + public async Task TestResponses() + { + AIProjectClient projectClient = GetTestProjectClient(); + ProjectResponsesClient client = projectClient.OpenAI.GetProjectResponsesClientForModel(TestEnvironment.MODELDEPLOYMENTNAME); + OpenAIResponse response = await client.CreateResponseAsync("What is steam reactor?"); + response = await WaitForRun(client, response); + Assert.That(response.GetOutputText(), Is.Not.Null.Or.Empty); + } + + [RecordedTest] + public async Task TestResponsesStreaming() + { + AIProjectClient projectClient = GetTestProjectClient(); + ProjectResponsesClient client = projectClient.OpenAI.GetProjectResponsesClientForModel(TestEnvironment.MODELDEPLOYMENTNAME); + bool isCreated = false; + bool textReceived = false; + await foreach (StreamingResponseUpdate streamResponse in client.CreateResponseStreamingAsync("What is steam reactor?")) + { + if (streamResponse is StreamingResponseCreatedUpdate createUpdate) + { + isCreated = true; + } + else if (streamResponse is StreamingResponseOutputTextDoneUpdate textDoneUpdate) + { + textReceived |= !string.IsNullOrEmpty(textDoneUpdate.Text); + } + else if (streamResponse is StreamingResponseErrorUpdate errorUpdate) + { + Assert.Fail($"The stream has failed with the error: {errorUpdate.Message}"); + } + } + Assert.That(isCreated, Is.True, "The run was not created."); + Assert.That(textReceived, Is.True, "The text response was not received."); + } + + [RecordedTest] + public async Task TestConversationCRUD() + { + AIProjectClient projectClient = GetTestProjectClient(); + + ProjectConversation firstConversation = await projectClient.OpenAI.Conversations.CreateProjectConversationAsync(); + ProjectConversation secondConversation = await projectClient.OpenAI.Conversations.CreateProjectConversationAsync( + new ProjectConversationCreationOptions() + { + Items = + { + ResponseItem.CreateUserMessageItem("Hello, world!"), + //AgentResponseItem.CreateStructuredOutputsItem( + // new Dictionary() + // { + // ["foo"] = BinaryData.FromString(@"{""value"": ""bar""}"), + // }), + }, + Metadata = + { + ["test_metadata"] = "yes", + }, + }); + + Assert.That(firstConversation?.Id, Does.StartWith("conv_")); + Assert.That(secondConversation?.Id, Does.StartWith("conv_")); + Assert.That(firstConversation.Id, Is.Not.EqualTo(secondConversation.Id)); + + Assert.That(firstConversation.Metadata, Is.Empty); + Assert.That(secondConversation.Metadata, Has.Count.EqualTo(1)); + string secondConversationFooMetadataValue = secondConversation.Metadata?.TryGetValue("test_metadata", out string testValue) == true ? testValue : null; + Assert.That(secondConversationFooMetadataValue, Is.EqualTo("yes")); + + List responseItems = []; + await foreach (ResponseItem item in projectClient.OpenAI.Conversations.GetProjectConversationItemsAsync(firstConversation.Id)) + { + responseItems.Add(item); + } + Assert.That(responseItems, Is.Empty); + await foreach (ResponseItem item in projectClient.OpenAI.Conversations.GetProjectConversationItemsAsync(secondConversation.Id)) + { + responseItems.Add(item); + } + Assert.That(responseItems, Has.Count.EqualTo(1)); + Assert.That(responseItems[0], Is.InstanceOf()); + + ReadOnlyCollection createdItems = await projectClient.OpenAI.Conversations.CreateProjectConversationItemsAsync( + firstConversation.Id, + [ResponseItem.CreateUserMessageItem("Hi there, world!")]); + Assert.That(createdItems, Has.Count.EqualTo(1)); + responseItems.Clear(); + await foreach (ResponseItem item in projectClient.OpenAI.Conversations.GetProjectConversationItemsAsync(firstConversation.Id)) + { + responseItems.Add(item); + } + Assert.That(responseItems, Has.Count.EqualTo(1)); + Assert.That(responseItems[0], Is.InstanceOf()); + + ProjectConversation updatedConversation = await projectClient.OpenAI.Conversations.UpdateProjectConversationAsync( + firstConversation.Id, + new ProjectConversationUpdateOptions() + { + Metadata = + { + ["new_test_value"] = "yes" + } + }); + Assert.That(updatedConversation.Metadata, Has.Count.EqualTo(1)); + + ProjectConversation retrievedConversation = await projectClient.OpenAI.Conversations.GetProjectConversationAsync(firstConversation.Id); + Assert.That(retrievedConversation?.Id, Is.EqualTo(firstConversation.Id)); + Assert.That(retrievedConversation.Metadata, Has.Count.EqualTo(1)); + } + + [RecordedTest] + public async Task TestConversationItemsOrderingWithMultipleMessages() + { + AIProjectClient projectClient = GetTestProjectClient(); + + // Create a conversation + ProjectConversation conversation = await projectClient.OpenAI.Conversations.CreateProjectConversationAsync(); + Assert.That(conversation?.Id, Does.StartWith("conv_")); + + // Create 40 messages for the conversation + List messagesToAdd = new(); + for (int i = 1; i <= 40; i++) + { + messagesToAdd.Add(ResponseItem.CreateUserMessageItem($"Message {i}")); + } + + // Trying to add all 40 at once should fail + ClientResultException exceptionFromOperation = Assert.ThrowsAsync(async () => _ = await projectClient.OpenAI.Conversations.CreateProjectConversationItemsAsync(conversation.Id, messagesToAdd)); + Assert.That(exceptionFromOperation.GetRawResponse().Content.ToString(), Does.Contain("20 items")); + + List firstHalfMessages = []; + for (int i = 0; i < 20; i++) + { + firstHalfMessages.Add(messagesToAdd[i]); + } + List secondHalfMessages = []; + for (int i = 20; i < messagesToAdd.Count; i++) + { + secondHalfMessages.Add(messagesToAdd[i]); + } + + ReadOnlyCollection createdItems = await projectClient.OpenAI.Conversations.CreateProjectConversationItemsAsync( + conversation.Id, + firstHalfMessages); + Assert.That(createdItems, Has.Count.EqualTo(20)); + createdItems = await projectClient.OpenAI.Conversations.CreateProjectConversationItemsAsync(conversation.Id, secondHalfMessages); + Assert.That(createdItems, Has.Count.EqualTo(20)); + + // Test ascending order traversal + List ascendingItems = []; + await foreach (AgentResponseItem item in projectClient.OpenAI.Conversations.GetProjectConversationItemsAsync( + conversation.Id, + limit: 5, + order: "asc")) + { + ascendingItems.Add(item); + } + Assert.That(ascendingItems, Has.Count.EqualTo(40)); + + // Test descending order traversal + List descendingItems = []; + await foreach (AgentResponseItem item in projectClient.OpenAI.Conversations.GetProjectConversationItemsAsync( + conversation.Id, + limit: 5, + order: "desc")) + { + descendingItems.Add(item); + } + Assert.That(descendingItems, Has.Count.EqualTo(40)); + + // Verify that ascending and descending lists contain the same items but in reverse order + descendingItems.Reverse(); + Assert.That(ascendingItems.Count, Is.EqualTo(descendingItems.Count)); + for (int i = 0; i < ascendingItems.Count; i++) + { + Assert.That(ascendingItems[i].Id, Is.EqualTo(descendingItems[i].Id), + $"Item at position {i} should be the same in both orderings"); + } + + // Verify that we can collect all items consistently + List allItems = []; + await foreach (AgentResponseItem item in projectClient.OpenAI.Conversations.GetProjectConversationItemsAsync(conversation.Id)) + { + allItems.Add(item); + } + Assert.That(allItems, Has.Count.EqualTo(40)); + } + + [RecordedTest] + public async Task SimplePromptAgentWithConversation() + { + AIProjectClient projectClient = GetTestProjectClient(); + + AgentDefinition agentDefinition = new PromptAgentDefinition(TestEnvironment.MODELDEPLOYMENTNAME) + { + Instructions = "You are a helpful agent that happens to always talk like a pirate. Arr!", + }; + + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "TestPromptAgentFromDotnet", + options: new(agentDefinition)); + ProjectConversation conversation = await projectClient.OpenAI.Conversations.CreateProjectConversationAsync( + new ProjectConversationCreationOptions() + { + Items = { ResponseItem.CreateSystemMessageItem("It's currently warm and sunny outside.") }, + }); + + ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion, conversation); + + OpenAIResponse response = await responseClient.CreateResponseAsync("Please greet me and tell me what would be good to wear outside today."); + + Console.WriteLine($"Response from prompt agent: {response.GetOutputText()}"); + } + + [RecordedTest] + public async Task SimplePromptAgentWithoutConversation() + { + AIProjectClient projectClient = GetTestProjectClient(); + + AgentDefinition agentDefinition = new PromptAgentDefinition(TestEnvironment.MODELDEPLOYMENTNAME) + { + Instructions = "You are a helpful agent that happens to always talk like a pirate. Arr!", + }; + + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "TestPromptAgentFromDotnet", + options: new(agentDefinition)); + + ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion); + + OpenAIResponse response = await responseClient.CreateResponseAsync("Please greet me and tell me what would be good to wear outside today."); + Assert.That(response?.GetOutputText(), Is.Not.Null.And.Not.Empty); + } + + [RecordedTest] + public async Task ErrorsGiveGoodExceptionMessages() + { + AIProjectClient projectClient = GetTestProjectClient(); + + ClientResultException exception = null; + try + { + _ = await projectClient.Agents.GetAgentAsync("SomeAgentNameThatReallyDoesNotExistAndNeverShould3490"); + } + catch (ClientResultException ex) + { + exception = ex; + } + + Assert.That(exception?.Message, Does.Contain("exist")); + } + + [RecordedTest] + public async Task StructuredInputsWork() + { + AIProjectClient projectClient = GetTestProjectClient(); + OpenAIResponseClient responseClient = projectClient.OpenAI.Responses; + + AgentVersion agent = await projectClient.Agents.CreateAgentVersionAsync( + "TestPromptAgentFromDotnetTests2343", + new AgentVersionCreationOptions( + new PromptAgentDefinition(TestEnvironment.MODELDEPLOYMENTNAME) + { + Instructions = "You are a friendly agent. The name of the user talking to you is {{user_name}}.", + StructuredInputs = + { + ["user_name"] = new StructuredInputDefinition() + { + DefaultValue = BinaryData.FromObjectAsJson(JsonValue.Create("Ishmael")), + } + } + }) + { + Metadata = + { + ["test_delete_me"] = "true", + } + }); + + ResponseItem item = ResponseItem.CreateUserMessageItem("What's my name?"); + + ResponseCreationOptions responseOptions = new() + { + Agent = agent, + }; + + OpenAIResponse response = await responseClient.CreateResponseAsync([item], responseOptions); + Assert.That(response.GetOutputText(), Does.Contain("Ishmael")); + + responseOptions = new() + { + Agent = agent, + StructuredInputs = + { + ["user_name"] = BinaryData.FromString(@"""Mr. Jingles"""), + }, + }; + + response = await responseClient.CreateResponseAsync([item], responseOptions); + Assert.That(response.GetOutputText(), Does.Contain("Mr. Jingles")); + + responseOptions.StructuredInputs["user_name"] = BinaryData.FromString(@"""Le Flufferkins"""); + response = await responseClient.CreateResponseAsync([item], responseOptions); + Assert.That(response.GetOutputText(), Does.Contain("Le Flufferkins")); + + responseOptions.StructuredInputs.Remove("user_name"); + response = await responseClient.CreateResponseAsync([item], responseOptions); + Assert.That(response.GetOutputText(), Does.Contain("Ishmael")); + } + + [RecordedTest] + public async Task SimpleWorkflowAgent() + { + AIProjectClient projectClient = GetTestProjectClient(); + + AgentDefinition workflowAgentDefinition = WorkflowAgentDefinition.FromYaml(s_HelloWorkflowYaml); + + AgentVersion newAgentVersion = await projectClient.Agents.CreateAgentVersionAsync( + "TestWorkflowAgentFromDotnet234", + new AgentVersionCreationOptions(workflowAgentDefinition) + { + Description = "A test agent created from the .NET SDK automation suite", + Metadata = { ["freely_deleteable"] = "true" }, + }); + + ProjectConversation newConversation = await projectClient.OpenAI.Conversations.CreateProjectConversationAsync(); + + ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(newAgentVersion, newConversation); + + OpenAIResponse response = await responseClient.CreateResponseAsync("Hello, agent!"); + + Assert.That(response.Id, Does.StartWith("wfresp")); + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + + Assert.That(response.OutputItems.Count, Is.GreaterThan(0)); + AgentResponseItem agentResponseItem = response.OutputItems[0].AsAgentResponseItem(); + Assert.That(agentResponseItem, Is.InstanceOf()); + + // This line will fix the failure: + // System.InvalidOperationException : Cannot write a JSON property within an array or as the first JSON token. Current token type is 'EndObject'. + response.Patch.Remove("$.output_text"u8); + Console.WriteLine(ModelReaderWriter.Write(response).ToString()); + } + + [RecordedTest] + public async Task SimpleWorkflowAgentStreaming() + { + AIProjectClient projectClient = GetTestProjectClient(); + + AgentDefinition workflowAgentDefinition = WorkflowAgentDefinition.FromYaml(s_HelloWorkflowYaml); + + AgentVersion newAgentVersion = await projectClient.Agents.CreateAgentVersionAsync( + "TestWorkflowAgentFromDotnet234", + new AgentVersionCreationOptions(workflowAgentDefinition) + { + Description = "A test agent created from the .NET SDK automation suite", + Metadata = { ["freely_deleteable"] = "true" }, + }); + + ProjectConversation newConversation = await projectClient.OpenAI.Conversations.CreateProjectConversationAsync(); + + ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(newAgentVersion, newConversation); + + AgentWorkflowActionResponseItem streamedWorkflowActionItem = null; + + await foreach (StreamingResponseUpdate responseUpdate in responseClient.CreateResponseStreamingAsync("Hello, agent!")) + { + if (responseUpdate is StreamingResponseOutputItemDoneUpdate itemDoneUpdate) + { + if (itemDoneUpdate.Item.AsAgentResponseItem() is AgentWorkflowActionResponseItem workflowActionItem) + { + streamedWorkflowActionItem = workflowActionItem; + } + } + // This line is commented because of failure: + // System.InvalidOperationException : Cannot write a JSON property within an array or as the first JSON token. Current token type is 'EndObject'. + //Console.WriteLine($"{responseUpdate} : {ModelReaderWriter.Write(responseUpdate).ToString()}"); + } + + Assert.That(streamedWorkflowActionItem?.ActionId, Is.Not.Null.And.Not.Empty); + } + + [RecordedTest] + public async Task TestMemoryStoreCRUD() + { + AIProjectClient projectClient = GetTestProjectClient(); + try + { + var _ = await projectClient.MemoryStores.DeleteMemoryStoreAsync(name: "test-memory-store"); + } + catch { } + // Create + MemoryStore store = await projectClient.MemoryStores.CreateMemoryStoreAsync("test-memory-store", new MemoryStoreDefaultDefinition(TestEnvironment.MODELDEPLOYMENTNAME, TestEnvironment.EMBEDDINGMODELDEPLOYMENTNAME)); + // Read + MemoryStore result = await projectClient.MemoryStores.GetMemoryStoreAsync(store.Name); + Assert.That(store.Id, Is.EqualTo(result.Id)); + Assert.That(store.Description, Is.EqualTo(result.Description)); + Assert.That(store.Name, Is.EqualTo(result.Name)); + // List + Assert.That( + (await projectClient.MemoryStores.GetMemoryStoresAsync().ToEnumerableAsync()) + .Select(x => x.Id) + .Any(x => x == store.Id), + $"The {store.Id} was not found in the list of memory stores." + ); + // Update + string newDescription = "Some other description."; + result = await projectClient.MemoryStores.UpdateMemoryStoreAsync( + name: store.Name, + description: newDescription + ); + Assert.That(newDescription, Is.EqualTo(result.Description)); + result = await projectClient.MemoryStores.GetMemoryStoreAsync(store.Name); + Assert.That(newDescription, Is.EqualTo(result.Description)); + // Delete + DeleteMemoryStoreResponse delResult = await projectClient.MemoryStores.DeleteMemoryStoreAsync(name: store.Name); + Assert.That(delResult.Deleted, Is.True); + Assert.That( + (await projectClient.MemoryStores.GetMemoryStoresAsync().ToEnumerableAsync()) + .Select(x => x.Id) + .Any(x => x == store.Id), + Is.False, + $"The {store.Id} was unexpectedly found in the list of memory stores after being deleted." + ); + } + + [RecordedTest] + [Ignore("The service is not ready.")] + [TestCase(true)] + [TestCase(false)] + public async Task TestMemorySearch(bool useConversation) + { + AIProjectClient projectClient = GetTestProjectClient(); + //try + //{ + // var _ = await projectClient.MemoryStores.DeleteMemoryStoreAsync(name: "test-memory-store"); + //} + //catch { } + MemoryStore store = await projectClient.MemoryStores.CreateMemoryStoreAsync("test-memory-store", new MemoryStoreDefaultDefinition(TestEnvironment.MODELDEPLOYMENTNAME, TestEnvironment.EMBEDDINGMODELDEPLOYMENTNAME)); + // Create an empty scope and make sure we cannot find anything. + string scope = "Test scope"; + MemorySearchOptions opts = new(scope) + { + Items = { ResponseItem.CreateUserMessageItem("Name your favorite animal") }, + ResultOptions = new MemorySearchResultOptions() + { + MaxMemories = 1, + } + }; + MemoryStoreSearchResponse resp = await projectClient.MemoryStores.SearchMemoriesAsync( + memoryStoreName: store.Name, + options: opts + ); + Assert.That(!resp.Memories.Any(), $"Unexpectedly found the result: {(resp.Memories.Any() ? resp.Memories.First().MemoryItem.Content : "")}"); + // Populate the scope and make sure, we can get the result. + ResponseItem userItem = ResponseItem.CreateUserMessageItem("What is your favorite animal?"); + ResponseItem agentItem = ResponseItem.CreateAssistantMessageItem("My favorite animal is Plagiarus praepotens."); + + MemoryUpdateResult updateResult = await projectClient.MemoryStores.UpdateMemoriesAsync( + store.Name, + new MemoryUpdateOptions(scope) + { + Items = { userItem, agentItem } + }); + + while (updateResult.Status != MemoryStoreUpdateStatus.Failed && updateResult.Status != MemoryStoreUpdateStatus.Completed) + { + if (Mode != RecordedTestMode.Playback) + await Task.Delay(TimeSpan.FromMilliseconds(500)); + updateResult = await projectClient.MemoryStores.GetUpdateResultAsync(store.Name, updateResult.UpdateId); + } + Assert.That(updateResult.Status == MemoryStoreUpdateStatus.Completed, $"Unexpected status {updateResult.Status}"); + resp = await projectClient.MemoryStores.SearchMemoriesAsync( + memoryStoreName: store.Name, + options: new MemorySearchOptions(scope) + ); + Assert.That(resp.Memories.Count, Is.EqualTo(1), $"The number of found items is {resp.Memories.Count}, while expected 1."); + Assert.That(resp.Memories[0].MemoryItem.Content.ToLower(), Does.Contain("plagiarus")); + } + + [RecordedTest] + [TestCase(ToolType.CodeInterpreter)] + [TestCase(ToolType.FileSearch)] + [TestCase(ToolType.ImageGeneration)] + [TestCase(ToolType.WebSearch)] + public async Task TestTool(ToolType toolType) + { + Dictionary headers = []; + if (toolType == ToolType.ImageGeneration) + { + headers["x-ms-oai-image-generation-deployment"] = TestEnvironment.IMAGE_GENERATION_DEPLOYMENT_NAME; + } + AIProjectClient projectClient = GetTestProjectClient(headers); + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: AGENT_NAME, + options: new(await GetAgentToolDefinition(toolType, projectClient.OpenAI))); + ProjectOpenAIClient oaiClient = projectClient.GetProjectOpenAIClient(); + ProjectResponsesClient responseClient = oaiClient.GetProjectResponsesClientForAgent(agentVersion.Name); + ResponseItem request = ResponseItem.CreateUserMessageItem(ToolPrompts[toolType]); + OpenAIResponse response = await responseClient.CreateResponseAsync([request]); + response = await WaitForRun(responseClient, response); + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + if (toolType == ToolType.ImageGeneration) + { + // If Tool type is Image generation, we need to check image output. + bool hasImageOutput = false; + foreach (ResponseItem item in response.OutputItems) + { + if (item is ImageGenerationCallResponseItem imageItem) + { + hasImageOutput |= imageItem.ImageResultBytes.Length > 0; + } + } + Assert.That(hasImageOutput); + } + else + { + Assert.That(response.GetOutputText(), Is.Not.Null.And.Not.Empty); + if (ExpectedOutput.TryGetValue(toolType, out string expectedResponse)) + { + Assert.That(response.GetOutputText().ToLower(), Does.Contain(expectedResponse.ToLower()), $"The output: \"{response.GetOutputText()}\" does not contain {expectedResponse}"); + } + } + } + + [RecordedTest] + [TestCase(ToolType.FileSearch)] + public async Task TestToolStreaming(ToolType toolType) + { + AIProjectClient projectClient = GetTestProjectClient(); + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: AGENT_NAME, + options: new(await GetAgentToolDefinition(toolType, projectClient.OpenAI))); + ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion); + ResponseItem request = ResponseItem.CreateUserMessageItem(ToolPrompts[toolType]); + bool isStarted = false; + bool isFinished = false; + bool annotationMet = false; + bool isStatusGood = false; + //Type expectedUpdateType = null; + bool updateFound = !ExpectedUpdateTypes.TryGetValue(toolType, out Type expectedUpdateType); + await foreach (StreamingResponseUpdate streamResponse in responseClient.CreateResponseStreamingAsync([request])) + { + if (streamResponse is StreamingResponseCreatedUpdate createUpdate) + { + isStarted = true; + } + else if (streamResponse is StreamingResponseOutputTextDoneUpdate textDoneUpdate) + { + isFinished = true; + Assert.That(textDoneUpdate.Text, Is.Not.Null.And.Not.Empty); + if (ExpectedOutput.TryGetValue(toolType, out string expectedResponse)) + { + Assert.That(textDoneUpdate.Text, Does.Contain(expectedResponse), $"The output: \"{textDoneUpdate.Text}\" does not contain {expectedResponse}"); + } + } + else if (streamResponse is StreamingResponseOutputItemDoneUpdate itemDoneUpdate) + { + if (ExpectedAnnotations.TryGetValue(toolType, out Type annotationType)) + { + if (itemDoneUpdate.Item is MessageResponseItem messageItem) + { + foreach (ResponseContentPart part in messageItem.Content) + { + foreach (ResponseMessageAnnotation annotation in part.OutputTextAnnotations) + { + annotationMet |= annotation.GetType() == annotationType; + } + } + } + } + else + { + annotationMet = true; + } + } + else if (streamResponse is StreamingResponseErrorUpdate errorUpdate) + { + Assert.Fail($"The stream has failed: {errorUpdate.Message}"); + } + else if (streamResponse is StreamingResponseCompletedUpdate streamResponseCompletedUpdate) + { + Assert.That(streamResponseCompletedUpdate.Response.Status, Is.EqualTo(ResponseStatus.Completed)); + isStatusGood = true; + } + if (expectedUpdateType is not null) + { + updateFound |= streamResponse.GetType() == expectedUpdateType; + } + } + Assert.That(annotationMet, Is.True); + Assert.That(isStarted, Is.True, "The stream did not started."); + Assert.That(isFinished, Is.True, "The stream did not finished."); + Assert.That(isStatusGood, Is.True, "No StreamingResponseCompletedUpdate were met."); + } + +[RecordedTest] +public async Task TestToolChoiceWorks() +{ + AIProjectClient projectClient = GetTestProjectClient(); + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: AGENT_NAME, + new AgentVersionCreationOptions( + new PromptAgentDefinition(TestEnvironment.MODELDEPLOYMENTNAME) + { + Instructions = "Always greet the user by name when possible.", + Tools = { new FunctionTool("get_name_of_user", BinaryData.FromString("{}"), strictModeEnabled: false) } + })); + + OpenAIResponseClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion); + + OpenAIResponse response = await responseClient.CreateResponseAsync("Hello!"); + Assert.That(response.OutputItems.Any(outputItem => outputItem is FunctionCallResponseItem), Is.True); + + response = await responseClient.CreateResponseAsync( + "Hello!", + new ResponseCreationOptions() + { + ToolChoice = ResponseToolChoice.CreateNoneChoice(), + }); + Assert.That(response.OutputItems.Any(outputItem => outputItem is FunctionCallResponseItem), Is.False); +} + + [RecordedTest] + public async Task TestFunctions() + { + AIProjectClient projectClient = GetTestProjectClient(); + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: AGENT_NAME, + options: new(await GetAgentToolDefinition(ToolType.FunctionCall, projectClient.OpenAI)) + ); + OpenAIResponseClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(agentVersion.Name); + ResponseCreationOptions responseOptions = new() + { + Agent = agentVersion, + }; + ResponseItem request = ResponseItem.CreateUserMessageItem(ToolPrompts[ToolType.FunctionCall]); + List inputItems = [request]; + bool funcionCalled; + bool functionWasCalled = false; + OpenAIResponse response; + do + { + response = await responseClient.CreateResponseAsync( + inputItems: inputItems, + options: responseOptions); + response = await WaitForRun(responseClient, response); + funcionCalled = false; + foreach (ResponseItem responseItem in response.OutputItems) + { + inputItems.Add(responseItem); + if (responseItem is FunctionCallResponseItem functionToolCall) + { + Assert.That(functionToolCall.FunctionName, Is.EqualTo("GetCityNicknameForTest")); + using JsonDocument argumentsJson = JsonDocument.Parse(functionToolCall.FunctionArguments); + string locationArgument = argumentsJson.RootElement.GetProperty("location").GetString(); + inputItems.Add(ResponseItem.CreateFunctionCallOutputItem( + callId: functionToolCall.CallId, + functionOutput: GetCityNicknameForTest(locationArgument) + )); + funcionCalled = true; + functionWasCalled = true; + } + } + } while (funcionCalled); + Assert.That(functionWasCalled, "The function was not called."); + Assert.That(response.GetOutputText(), Is.Not.Null.And.Not.Empty); + Assert.That(response.GetOutputText().ToLower, Does.Contain(ExpectedOutput[ToolType.FunctionCall]), $"The output: \"{response.GetOutputText()}\" does not contain {ExpectedOutput[ToolType.FunctionCall]}"); + } + + private static ComputerCallOutputResponseItem ProcessComputerUseCallTest(ComputerCallResponseItem item, IReadOnlyDictionary screenshots) + { + T currentScreenshot = item.Action.Kind switch + { + ComputerCallActionKind.Type => screenshots["search_typed"], + ComputerCallActionKind.KeyPress => (item.Action.KeyPressKeyCodes.Contains("Return") || item.Action.KeyPressKeyCodes.Contains("ENTER")) ? screenshots["search_results"] : screenshots["browser_search"], + ComputerCallActionKind.Click => screenshots["search_results"], + _ => screenshots["browser_search"] + }; + if (currentScreenshot is string currentScreenshotStr) + { + if (currentScreenshotStr.StartsWith("data:image")) + { + return ResponseItem.CreateComputerCallOutputItem(callId: item.CallId, output: ComputerCallOutput.CreateScreenshotOutput(screenshotImageUri: new Uri(currentScreenshotStr))); + } + return ResponseItem.CreateComputerCallOutputItem(callId: item.CallId, output: ComputerCallOutput.CreateScreenshotOutput(screenshotImageFileId: currentScreenshotStr)); + } + if (currentScreenshot is BinaryData currentScreenshotBin) + { + return ResponseItem.CreateComputerCallOutputItem(callId: item.CallId, output: ComputerCallOutput.CreateScreenshotOutput(screenshotImageBytes: currentScreenshotBin, screenshotImageBytesMediaType: "image/png")); + } + throw new InvalidDataException("screenshots must be a Dictionary, Dictionary"); + } + + private static async Task UploadScreenshots(OpenAIClient openAIClient) + { + OpenAIFileClient fileClient = openAIClient.GetOpenAIFileClient(); + Dictionary screenshots = new() { + { "browser_search", (await fileClient.UploadFileAsync(GetTestFile("cua_browser_search.png"), FileUploadPurpose.Assistants)).Value.Id }, + { "search_typed", (await fileClient.UploadFileAsync(GetTestFile("cua_search_typed.png"), FileUploadPurpose.Assistants)).Value.Id }, + { "search_results", (await fileClient.UploadFileAsync(GetTestFile("cua_search_results.png"), FileUploadPurpose.Assistants)).Value.Id }, + }; + return JsonSerializer.Serialize(screenshots); + } + + private static BinaryData UrlGetBase64Image(string name) + { + string imagePath = GetTestFile(name); + return new BinaryData(File.ReadAllBytes(imagePath)); + } + + private static Dictionary GetImagesBin() + { + return new() { + { "browser_search", UrlGetBase64Image("cua_browser_search.png")}, + { "search_typed", UrlGetBase64Image("cua_search_typed.png")}, + { "search_results", UrlGetBase64Image("cua_search_results.png")}, + }; + } + + [RecordedTest] + // [TestCase(true)] File upload mechanism is blocked by the Bug 4806071 (ADO) + [TestCase(false)] + public async Task TestComputerUse(bool useFileUpload) + { + AIProjectClient projectClient = GetTestProjectClient(); + // If the files are not in the foundry (used only for file upload),uncomment the code below and + // set the serializedScreenshots value to COMPUTER_SCREENSHOTS environment variable; + // comment out these lines and run the test again. + // string serializedScreenshots = await UploadScreenshots(openAIClient); + // Console.WriteLine(serializedScreenshots); + // End of file upload code. + Dictionary screenshots = useFileUpload ? JsonSerializer.Deserialize>(TestEnvironment.COMPUTER_SCREENSHOTS) : []; + Dictionary screenshotsBin = useFileUpload ? [] : GetImagesBin(); + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: AGENT_NAME, + options: new(await GetAgentToolDefinition(ToolType.ComputerUse, projectClient.OpenAI, model: TestEnvironment.COMPUTER_USE_DEPLOYMENT_NAME)) + ); + ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent( + agentVersion.Name); + ResponseCreationOptions responseOptions = new(); + responseOptions.TruncationMode = ResponseTruncationMode.Auto; + ResponseItem request = ResponseItem.CreateUserMessageItem( + [ + ResponseContentPart.CreateInputTextPart(ToolPrompts[ToolType.ComputerUse]), + useFileUpload ? ResponseContentPart.CreateInputImagePart(imageFileId: screenshots["browser_search"], imageDetailLevel: ResponseImageDetailLevel.High) : ResponseContentPart.CreateInputImagePart(imageBytes: screenshotsBin["browser_search"], imageBytesMediaType: "image/png", imageDetailLevel: ResponseImageDetailLevel.High) + ] + ); + List inputItems = [request]; + bool computerUseCalled; + bool computerUseWasCalled = false; + int limitIteration = 10; + OpenAIResponse response; + do + { + response = await responseClient.CreateResponseAsync( + inputItems: inputItems, + options: responseOptions); + response = await WaitForRun(responseClient, response); + inputItems.Clear(); + responseOptions.PreviousResponseId = response.Id; + computerUseCalled = false; + foreach (ResponseItem responseItem in response.OutputItems) + { + inputItems.Add(responseItem); + if (responseItem is ComputerCallResponseItem computerCall) + { + inputItems.Add(useFileUpload ? ProcessComputerUseCallTest(computerCall, screenshots) : ProcessComputerUseCallTest(computerCall, screenshotsBin)); + computerUseCalled = true; + computerUseWasCalled = true; + } + } + limitIteration--; + } while (computerUseCalled && limitIteration > 0); + Assert.That(computerUseWasCalled, "The computer use tool was not called."); + Assert.That(response.GetOutputText(), Is.Not.Null.And.Not.Empty); + } + + [RecordedTest] + [Ignore("Needs recording update for 2025-11-15-preview")] + public async Task TestAzureContainerApp() + { + AIProjectClient projectClient = GetTestProjectClient(); + AgentVersion containerAgentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: AGENT_NAME, + options: new(new ContainerApplicationAgentDefinition( + containerProtocolVersions: [new ProtocolVersionRecord(protocol: AgentCommunicationMethod.Responses, version: "1")], + containerAppResourceId: TestEnvironment.CONTAINER_APP_RESOURCE_ID, + ingressSubdomainSuffix: TestEnvironment.INGRESS_SUBDOMAIN_SUFFIX))); + ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(AGENT_NAME); + ProjectConversationsClient conversationClient = projectClient.OpenAI.GetProjectConversationsClient(); + ProjectConversationCreationOptions conversationOptions = new(); + conversationOptions.Items.Add( + ResponseItem.CreateUserMessageItem("What is the size of France in square miles?") + ); + ProjectConversation conversation = await conversationClient.CreateProjectConversationAsync(conversationOptions); + ResponseCreationOptions responseOptions = new() + { + Agent = containerAgentVersion, + AgentConversationId = conversation.Id, + }; + + OpenAIResponse response = await responseClient.CreateResponseAsync([], responseOptions); + response = await WaitForRun(responseClient, response); + Assert.That(response.Status, Is.EqualTo(ResponseStatus.Completed)); + Assert.That(response.GetOutputText(), Is.Not.Null.And.Not.Empty); + } + + [RecordedTest] + [TestCase(true)] + [TestCase(false)] + public async Task PerRequestToolsRejectedWithAgent(bool agentIsPresent) + { + AIProjectClient projectClient = GetTestProjectClient(); + OpenAIResponseClient responseClient = projectClient.OpenAI.Responses; + + ResponseCreationOptions responseOptions = new() + { + Tools = + { + ResponseTool.CreateFunctionTool( + functionName: "get_user_name", + functionParameters: BinaryData.FromString("{}"), + strictModeEnabled: false, + functionDescription: "Gets the user's name, as used for friendly address." + ) + } + }; + + if (agentIsPresent) + { + AgentDefinition agentDefinition = new PromptAgentDefinition(TestEnvironment.MODELDEPLOYMENTNAME) + { + Instructions = "You are a helpful agent that happens to always talk like a pirate. Arr!", + }; + + AgentVersion agentVersion = await projectClient.Agents.CreateAgentVersionAsync( + agentName: "TestPromptAgentFromDotnet", + options: new(agentDefinition)); + + responseOptions.Agent = agentVersion; + } + else + { + responseOptions.Model = TestEnvironment.MODELDEPLOYMENTNAME; + } + + List inputItems = [ResponseItem.CreateUserMessageItem("Hello, model!")]; + + if (agentIsPresent) + { + ClientResultException expectedException = Assert.ThrowsAsync(async () => await responseClient.CreateResponseAsync(inputItems, responseOptions)); + Assert.That(expectedException.Message?.ToLower(), Does.Contain("agent is specified")); + } + else + { + Assert.DoesNotThrowAsync(async () => await responseClient.CreateResponseAsync(inputItems, responseOptions)); + } + } + + public enum TestItemPersistenceMode + { + UsingConversations, + UsingPreviousResponseId, + UsingLocalItemsOnly + } + + [RecordedTest] + [TestCase(TestItemPersistenceMode.UsingConversations)] + [TestCase(TestItemPersistenceMode.UsingPreviousResponseId)] + [TestCase(TestItemPersistenceMode.UsingLocalItemsOnly)] + public async Task TestFunctionToolMultiturnWithPersistence(TestItemPersistenceMode persistenceMode) + { + AIProjectClient projectClient = GetTestProjectClient(); + + CancellationTokenSource cts = new(TimeSpan.FromSeconds(60)); + + AgentDefinition agentDefinition = new PromptAgentDefinition(TestEnvironment.MODELDEPLOYMENTNAME) + { + Instructions = "You are a helpful agent that happens to always talk like a pirate.", + Tools = + { + ResponseTool.CreateFunctionTool( + functionName: "get_user_name", + functionParameters: BinaryData.FromString("{}"), + strictModeEnabled: false, + functionDescription: "Gets the user's name, as used for friendly address." + ) + } + }; + + AgentVersion newAgentVersion = await projectClient.Agents.CreateAgentVersionAsync( + "TestPiratePromptAgentWithToolsFromDotnetTests", + new AgentVersionCreationOptions(agentDefinition) + { + Metadata = + { + ["can_delete_this"] = "true" + } + }, + cts.Token); + + ProjectResponsesClient responseClient = projectClient.OpenAI.GetProjectResponsesClientForAgent(newAgentVersion); + + ResponseCreationOptions responseCreationOptions = new(); + + string userInput = "Hello, agent! Greet me by name."; + List inputItems = [ResponseItem.CreateUserMessageItem(userInput)]; + + // Using a conversation: here, a new conversation is created for this interaction. + if (persistenceMode == TestItemPersistenceMode.UsingConversations) + { + ProjectConversation conversation = await projectClient.OpenAI.Conversations.CreateProjectConversationAsync(options: null, cts.Token); + responseCreationOptions.AgentConversationId = conversation; + } + else if (persistenceMode == TestItemPersistenceMode.UsingPreviousResponseId) + { + // Managed between calls + } + else if (persistenceMode == TestItemPersistenceMode.UsingLocalItemsOnly) + { + responseCreationOptions.StoredOutputEnabled = false; + } + + OpenAIResponse response = await responseClient.CreateResponseAsync(inputItems, responseCreationOptions, cts.Token); + + Assert.That(response.OutputItems.Count, Is.GreaterThan(0)); + + FunctionCallResponseItem functionCallItem = response.OutputItems.Last() as FunctionCallResponseItem; + Assert.That(functionCallItem?.FunctionName, Is.EqualTo("get_user_name")); + + // When accumulating locally, retain the original input and add output items to the local list for + // the next call. + if (persistenceMode == TestItemPersistenceMode.UsingLocalItemsOnly) + { + inputItems.AddRange(response.OutputItems); + } + else + { + inputItems.Clear(); + } + + if (persistenceMode == TestItemPersistenceMode.UsingPreviousResponseId) + { + responseCreationOptions.PreviousResponseId = response.Id; + } + + string replyToFunctionCall = "Ishmael"; + inputItems.Add(ResponseItem.CreateFunctionCallOutputItem(functionCallItem.CallId, replyToFunctionCall)); + response = await responseClient.CreateResponseAsync(inputItems, responseCreationOptions, cts.Token); + + Assert.That(response.GetOutputText().ToLower(), Does.Contain(replyToFunctionCall.ToLower())); + } + + [RecordedTest] + public async Task CanOverrideUserAgentViaProtocolResponses() + { + AIProjectClientOptions options = CreateTestProjectClientOptions(); + + string userAgentValue = null; + options.AddPolicy( + new TestPipelinePolicy(message => + { + if (message.Request.Headers.TryGetValue("User-Agent", out userAgentValue)) + { } + }), + PipelinePosition.BeforeTransport); + AIProjectClient client = CreateProxyFromClient(new AIProjectClient(new Uri(TestEnvironment.PROJECT_ENDPOINT), TestEnvironment.Credential, options)); + + RequestOptions protocolRequestOptions = new(); + protocolRequestOptions.AddHeader("User-Agent", "DotnetTestMyProtocolUserAgent"); + + ClientResult protocolResult = await client.OpenAI.Responses.CreateResponseAsync( + BinaryContent.Create( + BinaryData.FromString($$""" + { + "model": "{{TestEnvironment.MODELDEPLOYMENTNAME}}", + "input": [{"type":"message","role":"user","content":"hello, model!"}] + } + """)), + protocolRequestOptions); + + Assert.That(userAgentValue, Is.EqualTo("DotnetTestMyProtocolUserAgent")); + } + + private static readonly string s_HelloWorkflowYaml = """ + kind: workflow + trigger: + kind: OnConversationStart + id: my_workflow + actions: + - kind: SendActivity + id: sendActivity_welcome + activity: hello world + - kind: EndConversation + id: end_conversation + """; +} diff --git a/sdk/ai/Azure.AI.Projects/tests_agents/Azure.AI.Projects.Agents.Tests.csproj b/sdk/ai/Azure.AI.Projects/tests_agents/Azure.AI.Projects.Agents.Tests.csproj new file mode 100644 index 000000000000..9f7b1a263ccb --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/tests_agents/Azure.AI.Projects.Agents.Tests.csproj @@ -0,0 +1,41 @@ + + + $(RequiredTargetFrameworks) + + $(NoWarn);CS1591 + + $(NoWarn);NU1605 + + $(NoWarn);NU1105 + + $(NoWarn);OPENAI001;SCME0001; + + + + + preview + true + + + + + + + + + + + + + + + + + + + + <_Parameter1>SourcePath + <_Parameter2>$(MSBuildProjectDirectory) + + + \ No newline at end of file diff --git a/sdk/ai/Azure.AI.Projects/tests_agents/TestData/cua_browser_search.png b/sdk/ai/Azure.AI.Projects/tests_agents/TestData/cua_browser_search.png new file mode 100644 index 000000000000..31325a9c3df6 Binary files /dev/null and b/sdk/ai/Azure.AI.Projects/tests_agents/TestData/cua_browser_search.png differ diff --git a/sdk/ai/Azure.AI.Projects/tests_agents/TestData/cua_search_results.png b/sdk/ai/Azure.AI.Projects/tests_agents/TestData/cua_search_results.png new file mode 100644 index 000000000000..ed3ab3d8d492 Binary files /dev/null and b/sdk/ai/Azure.AI.Projects/tests_agents/TestData/cua_search_results.png differ diff --git a/sdk/ai/Azure.AI.Projects/tests_agents/TestData/cua_search_typed.png b/sdk/ai/Azure.AI.Projects/tests_agents/TestData/cua_search_typed.png new file mode 100644 index 000000000000..9f2c56c20445 Binary files /dev/null and b/sdk/ai/Azure.AI.Projects/tests_agents/TestData/cua_search_typed.png differ diff --git a/sdk/ai/Azure.AI.Projects/tests_agents/Utilities/GenAITraceVerifier.cs b/sdk/ai/Azure.AI.Projects/tests_agents/Utilities/GenAITraceVerifier.cs new file mode 100644 index 000000000000..4e208cd2f004 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/tests_agents/Utilities/GenAITraceVerifier.cs @@ -0,0 +1,182 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text.Json; +using NUnit.Framework; + +namespace Azure.AI.Projects.Tests.Utilities +{ + public class GenAiTraceVerifier + { + public static void ValidateSpanAttributes(Activity span, Dictionary expectedAttributes) + { + var actualAttributes = new Dictionary(); + foreach (KeyValuePair tag in span.EnumerateTagObjects()) + { + actualAttributes[tag.Key] = tag.Value; + } + + foreach (KeyValuePair expected in expectedAttributes) + { + Assert.That(actualAttributes, Contains.Key(expected.Key), $"Attribute '{expected.Key}' not found in span."); + var actualValue = actualAttributes[expected.Key]; + ValidateAttributeValue(expected.Value, actualValue, expected.Key); + } + } + + public static void ValidateSpanEvents(Activity span, List<(string Name, Dictionary Attributes)> expectedEvents) + { + var spanEvents = span.Events.ToList(); + ValidateSpanEvents(spanEvents, expectedEvents); + } + + public static void ValidateSpanEvents(List spanEvents, List<(string Name, Dictionary Attributes)> expectedEvents, bool allowAdditionalEvents=false) + { + foreach (var expectedEvent in expectedEvents) + { + var matchingEvent = spanEvents.FirstOrDefault(e => e.Name == expectedEvent.Name); + Assert.That(matchingEvent.Name, Is.Not.Null, $"Event '{expectedEvent.Name}' not found."); + + var actualEventAttributes = new Dictionary(); + foreach (var tag in matchingEvent.EnumerateTagObjects()) + { + actualEventAttributes[tag.Key] = tag.Value; + } + + ValidateEventAttributes(expectedEvent.Attributes, actualEventAttributes, expectedEvent.Name); + spanEvents.Remove(matchingEvent); + } + + Assert.That(spanEvents.Any() && !allowAdditionalEvents, Is.False, $"Unexpected additional events {spanEvents} found in span."); + } + + public static void ValidateEventAttributes(Dictionary expected, Dictionary actual, string eventName) + { + var expectedKeys = new HashSet(expected.Keys); + var actualKeys = new HashSet(actual.Keys); + + Assert.That(expectedKeys.SetEquals(actualKeys), Is.True, $"The {eventName} event attribute keys mismatch.\nExpected: {expectedKeys}\nActual: {actualKeys}"); + foreach (var key in expectedKeys) + { + ValidateAttributeValue(expected[key], actual[key], key); + } + } + + private static void ValidateAttributeValue(object expected, object actual, string key) + { + if (expected is string expectedStr) + { + if (expectedStr == "*") + { + Assert.That(actual, Is.Not.Null, $"The value for {key} i expected to be {actual} but was null."); + Assert.That(actual, Is.Not.Empty, $"The value for {key} i expected to be {actual} but was empty."); + } + else if (expectedStr == "+") + { + if (double.TryParse(actual?.ToString(), out double numericValue)) + { + Assert.That(numericValue, Is.GreaterThanOrEqualTo(0), $"The value for {key} is expected to be more then 0, but was {numericValue}"); + } + Assert.Fail($"The value for {key} was not set."); + } + else if (IsValidJson(expectedStr) && IsValidJson(actual?.ToString())) + { + ValidateJsonString(expectedStr, actual.ToString(), key); + } + else + { + Assert.That(actual?.ToString(), Is.EqualTo(expectedStr), $"Expected value for {key} is {expectedStr}, but was {actual?.ToString()}"); + } + } + else if (expected is Dictionary expectedDict) + { + if (actual is string actualStr && IsValidJson(actualStr)) + { + Dictionary actualDict = JsonSerializer.Deserialize>(actualStr); + ValidateAttributeValue(expectedDict, actualDict, key); + } + Assert.Fail($"The value for {key} is not a valid JSON: {actual}"); + } + else if (expected is IEnumerable expectedList) + { + if (actual is string actualStr && IsValidJson(actualStr)) + { + List actualList = JsonSerializer.Deserialize>(actualStr); + Assert.That(expectedList.SequenceEqual(actualList), Is.True, $"The lists for {key} are different:\nActual {actualList}\n{expectedList}"); + } + Assert.Fail($"The value for {key} is not a valid JSON: {actual}"); + } + else + { + Assert.That(actual, Is.EqualTo(expected), $"Expected value for {key} is {expected}, but was {actual}"); + } + } + + private static bool IsValidJson(string json) + { + if (string.IsNullOrWhiteSpace(json)) + return false; + try + { + JsonDocument.Parse(json); + return true; + } + catch + { + return false; + } + } + + private static void ValidateJsonString(string expectedJson, string actualJson, string key) + { + try + { + var expectedDoc = JsonDocument.Parse(expectedJson); + var actualDoc = JsonDocument.Parse(actualJson); + AssertJsonElementDeepEquals(expectedDoc.RootElement, actualDoc.RootElement, key); + } + catch + { + Assert.Fail($"Unable to parse expected or actual for {key}. Expected: {expectedJson}; Actual: {actualJson}"); + } + } + + private static void AssertJsonElementDeepEquals(JsonElement expected, JsonElement actual, string key) + { + Assert.That(actual.ValueKind, Is.EqualTo(expected.ValueKind), $"The value kind for key {key} differs. Expected: {expected.ValueKind}, Actual: {actual.ValueKind}"); + + switch (expected.ValueKind) + { + case JsonValueKind.Object: + var expectedProps = expected.EnumerateObject().OrderBy(p => p.Name).ToList(); + var actualProps = actual.EnumerateObject().OrderBy(p => p.Name).ToList(); + Assert.That(actualProps.Count, Is.EqualTo(expectedProps.Count), $"The number of propertie for {key} was different. Expected: {expectedProps.Count}, but was {actualProps.Count}.\nExpected: {expectedProps}\nActual: {actualProps}."); + for (int i = 0; i < expectedProps.Count; i++) + { + Assert.That(actualProps[i].Name, Is.EqualTo(expectedProps[i].Name), $"The {i}-th property of {key} is named {actualProps[i].Name} bit expected property is {expectedProps[i].Name}"); + AssertJsonElementDeepEquals(expectedProps[i].Value, actualProps[i].Value, $"{key}/{actualProps[i].Name}"); + } + break; + case JsonValueKind.Array: + var expectedItems = expected.EnumerateArray().ToList(); + var actualItems = actual.EnumerateArray().ToList(); + Assert.That(actualItems.Count, Is.EqualTo(expectedItems.Count), $"The number of elements in {key} is different. Expected: {expectedItems.Count}, but was {actualItems.Count}.\nExpected: {expectedItems}\nActual: {actualItems}."); + for (int i = 0; i < expectedItems.Count; i++) + { + AssertJsonElementDeepEquals(expectedItems[i], actualItems[i], $"{key}/[{i}]"); + } + break; + case JsonValueKind.Number: + Assert.That(actual.GetInt64(), Is.EqualTo(expected.GetInt64()), $"Expected value for {key} is {expected}, but was {actual}."); + break; + default: + ValidateAttributeValue(expected.GetString(), actual.GetString(), key); + break; + } + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/tests_agents/Utilities/MemoryTraceExporter.cs b/sdk/ai/Azure.AI.Projects/tests_agents/Utilities/MemoryTraceExporter.cs new file mode 100644 index 000000000000..8ee8368e2ce3 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/tests_agents/Utilities/MemoryTraceExporter.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +using System.Collections.Generic; +using OpenTelemetry; +using System.Diagnostics; + +namespace Azure.AI.Projects.Tests.Utilities +{ + public class MemoryTraceExporter : BaseExporter + { + private readonly List _activities = new(); + + public override ExportResult Export(in Batch batch) + { + foreach (var activity in batch) + { + _activities.Add(activity); + } + return ExportResult.Success; + } + + public IReadOnlyList GetExportedActivities() => _activities; + + public void Clear() => _activities.Clear(); + } +} diff --git a/sdk/ai/Azure.AI.Projects/tests_agents/Utils/HeaderTestPolicy.cs b/sdk/ai/Azure.AI.Projects/tests_agents/Utils/HeaderTestPolicy.cs new file mode 100644 index 000000000000..a94f30628398 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/tests_agents/Utils/HeaderTestPolicy.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Azure.AI.Projects.Tests; + +internal class HeaderTestPolicy(IReadOnlyDictionary _headers) : PipelinePolicy +{ + public override void Process(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) + { + // Add your desired header name and value + foreach (KeyValuePair header in _headers) + { + message.Request.Headers.Add(header.Key, header.Value); + } + ProcessNext(message, pipeline, currentIndex); + } + + public override async ValueTask ProcessAsync(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) + { + // Add your desired header name and value + foreach (KeyValuePair header in _headers) + { + message.Request.Headers.Add(header.Key, header.Value); + } + await ProcessNextAsync(message, pipeline, currentIndex); + } +} diff --git a/sdk/ai/Azure.AI.Projects/tests_agents/Utils/TestPipelinePolicy.cs b/sdk/ai/Azure.AI.Projects/tests_agents/Utils/TestPipelinePolicy.cs new file mode 100644 index 000000000000..d5f622d4180e --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/tests_agents/Utils/TestPipelinePolicy.cs @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Azure.AI.Projects.Tests; + +internal partial class TestPipelinePolicy : PipelinePolicy +{ + private Action _processMessageAction; + + public TestPipelinePolicy(Action processMessageAction) + { + _processMessageAction = processMessageAction; + } + + public override void Process(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) + { + _processMessageAction(message); // for request + ProcessNext(message, pipeline, currentIndex); + _processMessageAction(message); // for response + } + + public override async ValueTask ProcessAsync(PipelineMessage message, IReadOnlyList pipeline, int currentIndex) + { + _processMessageAction(message); // for request + await ProcessNextAsync(message, pipeline, currentIndex); + _processMessageAction(message); // for response + } +} diff --git a/sdk/ai/Azure.AI.Projects/tsp-location.yaml b/sdk/ai/Azure.AI.Projects/tsp-location.yaml deleted file mode 100644 index 784967d21e86..000000000000 --- a/sdk/ai/Azure.AI.Projects/tsp-location.yaml +++ /dev/null @@ -1,4 +0,0 @@ -directory: specification/ai/Azure.AI.Projects -commit: 8abd9b9b0bcc8bb093c4559b8b348ec51cf2392d -repo: Azure/azure-rest-api-specs -emitterPackageJsonPath: eng/http-client-csharp-emitter-package.json diff --git a/sdk/ai/Azure.AI.VoiceLive/samples/BasicVoiceAssistant/BasicVoiceAssistant.csproj b/sdk/ai/Azure.AI.VoiceLive/samples/BasicVoiceAssistant/BasicVoiceAssistant.csproj index 574a0b61517d..138db34e37ac 100644 --- a/sdk/ai/Azure.AI.VoiceLive/samples/BasicVoiceAssistant/BasicVoiceAssistant.csproj +++ b/sdk/ai/Azure.AI.VoiceLive/samples/BasicVoiceAssistant/BasicVoiceAssistant.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + $(LtsTargetFramework) enable enable BasicVoiceAssistant @@ -40,4 +40,4 @@ Condition="Exists('appsettings.development.json')" /> - \ No newline at end of file + diff --git a/sdk/ai/Azure.AI.VoiceLive/samples/CustomerServiceBot/CustomerServiceBot.csproj b/sdk/ai/Azure.AI.VoiceLive/samples/CustomerServiceBot/CustomerServiceBot.csproj index b15b939b36af..5a4f218f677f 100644 --- a/sdk/ai/Azure.AI.VoiceLive/samples/CustomerServiceBot/CustomerServiceBot.csproj +++ b/sdk/ai/Azure.AI.VoiceLive/samples/CustomerServiceBot/CustomerServiceBot.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net10.0 enable enable CustomerServiceBot @@ -39,4 +39,4 @@ Condition="Exists('appsettings.development.json')" /> - \ No newline at end of file + diff --git a/sdk/ai/Azure.AI.VoiceLive/samples/snippets/Azure.AI.VoiceLive.Snippets.csproj b/sdk/ai/Azure.AI.VoiceLive/samples/snippets/Azure.AI.VoiceLive.Snippets.csproj index fe145ab1b27e..2794ffd32a0c 100644 --- a/sdk/ai/Azure.AI.VoiceLive/samples/snippets/Azure.AI.VoiceLive.Snippets.csproj +++ b/sdk/ai/Azure.AI.VoiceLive/samples/snippets/Azure.AI.VoiceLive.Snippets.csproj @@ -1,7 +1,7 @@  - net8.0 + $(LtsTargetFramework) enable enable Library @@ -17,4 +17,4 @@ - \ No newline at end of file + diff --git a/sdk/ai/ci.agents.persistent.yml b/sdk/ai/ci.agentspersistent.yml similarity index 100% rename from sdk/ai/ci.agents.persistent.yml rename to sdk/ai/ci.agentspersistent.yml diff --git a/sdk/ai/ci.projects.yml b/sdk/ai/ci.projects.yml index 3a63fbdef1a3..83819a7182db 100644 --- a/sdk/ai/ci.projects.yml +++ b/sdk/ai/ci.projects.yml @@ -10,6 +10,7 @@ trigger: include: - sdk/ai/ci.projects.yml - sdk/ai/Azure.AI.Projects + - sdk/ai/Azure.AI.Projects.OpenAI pr: branches: @@ -22,6 +23,7 @@ pr: include: - sdk/ai/ci.projects.yml - sdk/ai/Azure.AI.Projects + - sdk/ai/Azure.AI.Projects.OpenAI extends: template: /eng/pipelines/templates/stages/archetype-sdk-client.yml @@ -31,3 +33,8 @@ extends: Artifacts: - name: Azure.AI.Projects safeName: AzureAIProjects + - name: Azure.AI.Projects.OpenAI + safeName: AzureAIProjectsOpenAI + # Skip project reference tests + MatrixFilters: + - AdditionalTestArguments=^(?!.*UseProjectReferenceToAzureClients=true) \ No newline at end of file diff --git a/sdk/ai/cspell.yaml b/sdk/ai/cspell.yaml new file mode 100644 index 000000000000..0584d1acc67d --- /dev/null +++ b/sdk/ai/cspell.yaml @@ -0,0 +1,33 @@ +version: "0.2" +language: en +allowCompoundWords: true +dictionaries: + - python + - powershell + - csharp + - softwareTerms +words: + - aoai + - aiprojects + - ansii + - atbash + - azureai + - bleu + - conv + - CSDL + - genai + - gleu + - includable + - inpaint + - inpainting + - linq + - logprobs + - OPENAICUA + - Plagiarus + - PNAS + - praepotens + - ubinary + - UPIA + - wfresp +ignorePaths: + - "**/*jsonl" \ No newline at end of file diff --git a/sdk/batch/Microsoft.Azure.Batch.Conventions.Files/tests/IntegrationTests/Microsoft.Azure.Batch.Conventions.Files.Integration.Tests.csproj b/sdk/batch/Microsoft.Azure.Batch.Conventions.Files/tests/IntegrationTests/Microsoft.Azure.Batch.Conventions.Files.Integration.Tests.csproj index 1e5adf16cc36..24a6faa02163 100644 --- a/sdk/batch/Microsoft.Azure.Batch.Conventions.Files/tests/IntegrationTests/Microsoft.Azure.Batch.Conventions.Files.Integration.Tests.csproj +++ b/sdk/batch/Microsoft.Azure.Batch.Conventions.Files/tests/IntegrationTests/Microsoft.Azure.Batch.Conventions.Files.Integration.Tests.csproj @@ -9,6 +9,9 @@ true false true + + + $(NoWarn);NU1510 @@ -31,12 +34,12 @@ - + - + PreserveNewest diff --git a/sdk/batch/Microsoft.Azure.Batch.Conventions.Files/tests/UnitTests/Microsoft.Azure.Batch.Conventions.Files.Tests.csproj b/sdk/batch/Microsoft.Azure.Batch.Conventions.Files/tests/UnitTests/Microsoft.Azure.Batch.Conventions.Files.Tests.csproj index 1bff51ee3bef..3f4262c43191 100644 --- a/sdk/batch/Microsoft.Azure.Batch.Conventions.Files/tests/UnitTests/Microsoft.Azure.Batch.Conventions.Files.Tests.csproj +++ b/sdk/batch/Microsoft.Azure.Batch.Conventions.Files/tests/UnitTests/Microsoft.Azure.Batch.Conventions.Files.Tests.csproj @@ -10,6 +10,9 @@ false true $(NoWarn);8002 + + + $(NoWarn);NU1510 @@ -35,7 +38,7 @@ - + diff --git a/sdk/batch/Microsoft.Azure.Batch/tests/IntegrationTestCommon/Microsoft.Azure.Batch.IntegrationTestCommon.csproj b/sdk/batch/Microsoft.Azure.Batch/tests/IntegrationTestCommon/Microsoft.Azure.Batch.IntegrationTestCommon.csproj index f556d68dec5b..a5f35e1b4204 100644 --- a/sdk/batch/Microsoft.Azure.Batch/tests/IntegrationTestCommon/Microsoft.Azure.Batch.IntegrationTestCommon.csproj +++ b/sdk/batch/Microsoft.Azure.Batch/tests/IntegrationTestCommon/Microsoft.Azure.Batch.IntegrationTestCommon.csproj @@ -3,6 +3,9 @@ Azure Batch integration test common library Microsoft Azure Batch Integration TestsCommon true + + + $(NoWarn);NU1510 @@ -17,11 +20,11 @@ - + - + diff --git a/sdk/batch/Microsoft.Azure.Batch/tests/TestCommon/Microsoft.Azure.Batch.Common.csproj b/sdk/batch/Microsoft.Azure.Batch/tests/TestCommon/Microsoft.Azure.Batch.Common.csproj index 6935e4a24518..779610188d7e 100644 --- a/sdk/batch/Microsoft.Azure.Batch/tests/TestCommon/Microsoft.Azure.Batch.Common.csproj +++ b/sdk/batch/Microsoft.Azure.Batch/tests/TestCommon/Microsoft.Azure.Batch.Common.csproj @@ -5,6 +5,9 @@ false Microsoft Azure Batch Common Tests true + + + $(NoWarn);NU1510 diff --git a/sdk/batch/Microsoft.Azure.Batch/tests/UnitTests/Microsoft.Azure.Batch.Unit.Tests.csproj b/sdk/batch/Microsoft.Azure.Batch/tests/UnitTests/Microsoft.Azure.Batch.Unit.Tests.csproj index 4763298656d3..afcdd66a8bbb 100644 --- a/sdk/batch/Microsoft.Azure.Batch/tests/UnitTests/Microsoft.Azure.Batch.Unit.Tests.csproj +++ b/sdk/batch/Microsoft.Azure.Batch/tests/UnitTests/Microsoft.Azure.Batch.Unit.Tests.csproj @@ -5,7 +5,7 @@ true false true - CS1998;xUnit2002 + CS1998;xUnit2002;NU1510 @@ -30,7 +30,7 @@ - + diff --git a/sdk/cloudmachine/Azure.Projects.Tsp/Azure.Projects.Tsp.csproj b/sdk/cloudmachine/Azure.Projects.Tsp/Azure.Projects.Tsp.csproj index ac7e29876bbb..0ed27594a351 100644 --- a/sdk/cloudmachine/Azure.Projects.Tsp/Azure.Projects.Tsp.csproj +++ b/sdk/cloudmachine/Azure.Projects.Tsp/Azure.Projects.Tsp.csproj @@ -5,15 +5,13 @@ latest enable 1.0.0-beta.1 - net8.0;net9.0 - net8.0 + $(RequiredRunnableTargetFrameworks) + $(RequiredRunnableTargetFrameworks) enable - 12 - diff --git a/sdk/cloudmachine/Azure.Projects.Web/src/Azure.Projects.Web.csproj b/sdk/cloudmachine/Azure.Projects.Web/src/Azure.Projects.Web.csproj index 21d032fc1cd2..555bd370c9d9 100644 --- a/sdk/cloudmachine/Azure.Projects.Web/src/Azure.Projects.Web.csproj +++ b/sdk/cloudmachine/Azure.Projects.Web/src/Azure.Projects.Web.csproj @@ -3,10 +3,9 @@ Azure.Projects.Web is an ASP.NET Core extensions for Azure.Projects 1.0.0-beta.2 - net8.0;net9.0 - net8.0 + $(RequiredRunnableTargetFrameworks) + $(RequiredRunnableTargetFrameworks) enable - 12 @@ -16,7 +15,7 @@ - + diff --git a/sdk/cloudmachine/Azure.Projects/samples/ConsoleAgent/ConsoleAgent.csproj b/sdk/cloudmachine/Azure.Projects/samples/ConsoleAgent/ConsoleAgent.csproj index 2f32b3b70f47..c046f48ca1f6 100644 --- a/sdk/cloudmachine/Azure.Projects/samples/ConsoleAgent/ConsoleAgent.csproj +++ b/sdk/cloudmachine/Azure.Projects/samples/ConsoleAgent/ConsoleAgent.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net10.0 enable disable 0.0.0-beta.1 diff --git a/sdk/cloudmachine/Azure.Projects/samples/HelloRAG/HelloRAG.csproj b/sdk/cloudmachine/Azure.Projects/samples/HelloRAG/HelloRAG.csproj index ff02c135d555..1bf990e53daa 100644 --- a/sdk/cloudmachine/Azure.Projects/samples/HelloRAG/HelloRAG.csproj +++ b/sdk/cloudmachine/Azure.Projects/samples/HelloRAG/HelloRAG.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net10.0 enable disable 0.0.0-beta.1 diff --git a/sdk/cloudmachine/Azure.Projects/samples/HelloWorld/HelloWorld.csproj b/sdk/cloudmachine/Azure.Projects/samples/HelloWorld/HelloWorld.csproj index 2f32b3b70f47..c046f48ca1f6 100644 --- a/sdk/cloudmachine/Azure.Projects/samples/HelloWorld/HelloWorld.csproj +++ b/sdk/cloudmachine/Azure.Projects/samples/HelloWorld/HelloWorld.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net10.0 enable disable 0.0.0-beta.1 diff --git a/sdk/cloudmachine/Azure.Projects/samples/WebAgent/WebAgent.csproj b/sdk/cloudmachine/Azure.Projects/samples/WebAgent/WebAgent.csproj index 0ad77a7d2a8f..aa9f830d9c24 100644 --- a/sdk/cloudmachine/Azure.Projects/samples/WebAgent/WebAgent.csproj +++ b/sdk/cloudmachine/Azure.Projects/samples/WebAgent/WebAgent.csproj @@ -1,7 +1,7 @@  - net8.0 + net10.0 enable enable diff --git a/sdk/core/Microsoft.ClientModel.TestFramework/src/Microsoft.ClientModel.TestFramework.csproj b/sdk/core/Microsoft.ClientModel.TestFramework/src/Microsoft.ClientModel.TestFramework.csproj index 89a541440c1c..04103d23e3e0 100644 --- a/sdk/core/Microsoft.ClientModel.TestFramework/src/Microsoft.ClientModel.TestFramework.csproj +++ b/sdk/core/Microsoft.ClientModel.TestFramework/src/Microsoft.ClientModel.TestFramework.csproj @@ -3,7 +3,7 @@ Test framework for clients built on System.ClientModel 1.0.0-beta.1 Microsoft.ClientModel.TestFramework - net462;net8.0;net9.0 + $(AllActiveCurrentTargetFrameworks);$(NetFxTargetFramework) $(RequiredTargetFrameworks) enable latest @@ -16,7 +16,7 @@ - + diff --git a/sdk/core/System.ClientModel/src/System.ClientModel.csproj b/sdk/core/System.ClientModel/src/System.ClientModel.csproj index 892f1435bae5..f29f8591533f 100644 --- a/sdk/core/System.ClientModel/src/System.ClientModel.csproj +++ b/sdk/core/System.ClientModel/src/System.ClientModel.csproj @@ -6,11 +6,11 @@ 1.8.1 enable - netstandard2.0;net8.0;net9.0 + $(RequiredTargetFrameworks);net9.0 DotNetPackageIcon.png $(RepoEngPath)/images/$(PackageIcon) enable - net8.0 + net8.0 diff --git a/sdk/digitaltwins/Azure.DigitalTwins.Core/samples/DigitalTwinsClientSample/DigitalTwinsClientSample.csproj b/sdk/digitaltwins/Azure.DigitalTwins.Core/samples/DigitalTwinsClientSample/DigitalTwinsClientSample.csproj index eeceb97aa0d4..2987b182e277 100644 --- a/sdk/digitaltwins/Azure.DigitalTwins.Core/samples/DigitalTwinsClientSample/DigitalTwinsClientSample.csproj +++ b/sdk/digitaltwins/Azure.DigitalTwins.Core/samples/DigitalTwinsClientSample/DigitalTwinsClientSample.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net10.0 Azure.DigitalTwins.Core.Samples false diff --git a/sdk/eventgrid/Azure.Messaging.EventGrid/EventGridSourceGenerator/src/Azure.Messaging.EventGrid.SourceGeneration.csproj b/sdk/eventgrid/Azure.Messaging.EventGrid/EventGridSourceGenerator/src/Azure.Messaging.EventGrid.SourceGeneration.csproj index e0db0f712f2b..f6eaf0432f7c 100644 --- a/sdk/eventgrid/Azure.Messaging.EventGrid/EventGridSourceGenerator/src/Azure.Messaging.EventGrid.SourceGeneration.csproj +++ b/sdk/eventgrid/Azure.Messaging.EventGrid/EventGridSourceGenerator/src/Azure.Messaging.EventGrid.SourceGeneration.csproj @@ -1,7 +1,7 @@  - netstandard2.0;net8.0 + $(RequiredTargetFrameworks) true diff --git a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/samples/aspnet-hosted-service/Directory.Build.props b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/samples/aspnet-hosted-service/Directory.Build.props index f4aeb70b95f2..3a9b7d5dfc46 100644 --- a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/samples/aspnet-hosted-service/Directory.Build.props +++ b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/samples/aspnet-hosted-service/Directory.Build.props @@ -13,6 +13,6 @@ false - net8.0;net9.0 + net10.0;net9.0;net8.0 diff --git a/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/src/Microsoft.Azure.WebJobs.Extensions.EventHubs.csproj b/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/src/Microsoft.Azure.WebJobs.Extensions.EventHubs.csproj index 88b8ae708a6e..99ec6ce51f77 100644 --- a/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/src/Microsoft.Azure.WebJobs.Extensions.EventHubs.csproj +++ b/sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/src/Microsoft.Azure.WebJobs.Extensions.EventHubs.csproj @@ -1,7 +1,7 @@ - netstandard2.0;net8.0 + $(RequiredTargetFrameworks) Microsoft Azure WebJobs SDK EventHubs Extension 6.6.0-beta.1 diff --git a/sdk/extension-wcf/Microsoft.WCF.Azure.StorageQueues/src/Microsoft.WCF.Azure.StorageQueues.csproj b/sdk/extension-wcf/Microsoft.WCF.Azure.StorageQueues/src/Microsoft.WCF.Azure.StorageQueues.csproj index cc19a748e7b6..ff5b960735a2 100644 --- a/sdk/extension-wcf/Microsoft.WCF.Azure.StorageQueues/src/Microsoft.WCF.Azure.StorageQueues.csproj +++ b/sdk/extension-wcf/Microsoft.WCF.Azure.StorageQueues/src/Microsoft.WCF.Azure.StorageQueues.csproj @@ -2,11 +2,12 @@ Icon.png - net8.0 - net8.0 + $(RequiredRunnableTargetFrameworks) + $(RequiredTargetFrameworks) false 1.0.0-beta.1 true + $(NoWarn);NU1510 diff --git a/sdk/extension-wcf/samples/Microsoft.CoreWCF.Azure.StorageQueues.Samples/Microsoft.CoreWCF.Azure.StorageQueues.Samples.csproj b/sdk/extension-wcf/samples/Microsoft.CoreWCF.Azure.StorageQueues.Samples/Microsoft.CoreWCF.Azure.StorageQueues.Samples.csproj index a4b8a2f58803..c6fb63d80005 100644 --- a/sdk/extension-wcf/samples/Microsoft.CoreWCF.Azure.StorageQueues.Samples/Microsoft.CoreWCF.Azure.StorageQueues.Samples.csproj +++ b/sdk/extension-wcf/samples/Microsoft.CoreWCF.Azure.StorageQueues.Samples/Microsoft.CoreWCF.Azure.StorageQueues.Samples.csproj @@ -1,6 +1,6 @@  - net8.0 + $(LtsTargetFramework) $(RequiredTargetFrameworks) false true diff --git a/sdk/extension-wcf/samples/Microsoft.WCF.Azure.StorageQueues.Samples/Microsoft.WCF.Azure.StorageQueues.Samples.csproj b/sdk/extension-wcf/samples/Microsoft.WCF.Azure.StorageQueues.Samples/Microsoft.WCF.Azure.StorageQueues.Samples.csproj index 6ab6c06db0db..f877b677cf40 100644 --- a/sdk/extension-wcf/samples/Microsoft.WCF.Azure.StorageQueues.Samples/Microsoft.WCF.Azure.StorageQueues.Samples.csproj +++ b/sdk/extension-wcf/samples/Microsoft.WCF.Azure.StorageQueues.Samples/Microsoft.WCF.Azure.StorageQueues.Samples.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + $(LtsTargetFramework) enable diff --git a/sdk/extensions/Microsoft.Azure.WebJobs.Extensions.Clients/samples/Microsoft.Azure.WebJobs.Extensions.Clients.Samples.csproj b/sdk/extensions/Microsoft.Azure.WebJobs.Extensions.Clients/samples/Microsoft.Azure.WebJobs.Extensions.Clients.Samples.csproj index b38bb3b13835..fe0e36a7b376 100644 --- a/sdk/extensions/Microsoft.Azure.WebJobs.Extensions.Clients/samples/Microsoft.Azure.WebJobs.Extensions.Clients.Samples.csproj +++ b/sdk/extensions/Microsoft.Azure.WebJobs.Extensions.Clients/samples/Microsoft.Azure.WebJobs.Extensions.Clients.Samples.csproj @@ -1,6 +1,6 @@  - net8.0 + $(LtsTargetFramework) $(RequiredTargetFrameworks) v3 diff --git a/sdk/extensions/Microsoft.Extensions.Azure/samples/Microsoft.Extensions.Azure.Samples.csproj b/sdk/extensions/Microsoft.Extensions.Azure/samples/Microsoft.Extensions.Azure.Samples.csproj index 34c0ce493701..9526a417f533 100644 --- a/sdk/extensions/Microsoft.Extensions.Azure/samples/Microsoft.Extensions.Azure.Samples.csproj +++ b/sdk/extensions/Microsoft.Extensions.Azure/samples/Microsoft.Extensions.Azure.Samples.csproj @@ -1,6 +1,6 @@  - net8.0 + $(LtsTargetFramework) $(RequiredTargetFrameworks) false diff --git a/sdk/extensions/Microsoft.Extensions.Azure/tests/Microsoft.Extensions.Azure.Tests.csproj b/sdk/extensions/Microsoft.Extensions.Azure/tests/Microsoft.Extensions.Azure.Tests.csproj index 878c4a8f501a..fd0f0e18618f 100644 --- a/sdk/extensions/Microsoft.Extensions.Azure/tests/Microsoft.Extensions.Azure.Tests.csproj +++ b/sdk/extensions/Microsoft.Extensions.Azure/tests/Microsoft.Extensions.Azure.Tests.csproj @@ -1,5 +1,6 @@  + net10.0 $(RequiredTargetFrameworks) @@ -7,7 +8,8 @@ - + + @@ -25,12 +27,6 @@ - - - diff --git a/sdk/identity/Azure.Identity.Broker/src/Azure.Identity.Broker.csproj b/sdk/identity/Azure.Identity.Broker/src/Azure.Identity.Broker.csproj index faf5d0ac509f..5b70441b658f 100644 --- a/sdk/identity/Azure.Identity.Broker/src/Azure.Identity.Broker.csproj +++ b/sdk/identity/Azure.Identity.Broker/src/Azure.Identity.Broker.csproj @@ -6,9 +6,8 @@ 1.3.1 Microsoft Azure Identity Broker;$(PackageCommonTags) - $(RequiredTargetFrameworks);net462;net8.0 - $(RequiredTargetFrameworks);net8.0 - $(RequiredTargetFrameworks);net8.0 + $(RequiredTargetFrameworks) + $(TargetFrameworks);$(NetFxTargetFramework) $(NoWarn);3021 true diff --git a/sdk/identity/Azure.Identity/integration/Integration.Identity.Common/Integration.Identity.Common.csproj b/sdk/identity/Azure.Identity/integration/Integration.Identity.Common/Integration.Identity.Common.csproj index 720370be893a..1452dc8d07ca 100644 --- a/sdk/identity/Azure.Identity/integration/Integration.Identity.Common/Integration.Identity.Common.csproj +++ b/sdk/identity/Azure.Identity/integration/Integration.Identity.Common/Integration.Identity.Common.csproj @@ -1,7 +1,7 @@ - $(LtsTargetFramework) + $(RequiredRunnableTargetFrameworks) enable enable diff --git a/sdk/identity/Azure.Identity/integration/Integration.Identity.Func/Integration.Identity.Func.csproj b/sdk/identity/Azure.Identity/integration/Integration.Identity.Func/Integration.Identity.Func.csproj index daddaba110ca..85d7d4a95c9c 100644 --- a/sdk/identity/Azure.Identity/integration/Integration.Identity.Func/Integration.Identity.Func.csproj +++ b/sdk/identity/Azure.Identity/integration/Integration.Identity.Func/Integration.Identity.Func.csproj @@ -1,6 +1,6 @@ - $(LtsTargetFramework) + $(RequiredRunnableTargetFrameworks) v4 Exe enable @@ -8,9 +8,9 @@ $(NoWarn);AZC0012 - - - + + + @@ -25,4 +25,4 @@ - \ No newline at end of file + diff --git a/sdk/identity/Azure.Identity/integration/WebApp/Integration.Identity.WebApp.csproj b/sdk/identity/Azure.Identity/integration/WebApp/Integration.Identity.WebApp.csproj index 57fe8476347f..a290c49da37d 100644 --- a/sdk/identity/Azure.Identity/integration/WebApp/Integration.Identity.WebApp.csproj +++ b/sdk/identity/Azure.Identity/integration/WebApp/Integration.Identity.WebApp.csproj @@ -1,7 +1,7 @@ - $(LtsTargetFramework) + $(RequiredRunnableTargetFrameworks) enable enable diff --git a/sdk/iot/Azure.IoT.Hub.Service/samples/IotHubClientSamples/IotHubClientSamples.csproj b/sdk/iot/Azure.IoT.Hub.Service/samples/IotHubClientSamples/IotHubClientSamples.csproj index ae46dae7aa03..8832a9eb08a5 100644 --- a/sdk/iot/Azure.IoT.Hub.Service/samples/IotHubClientSamples/IotHubClientSamples.csproj +++ b/sdk/iot/Azure.IoT.Hub.Service/samples/IotHubClientSamples/IotHubClientSamples.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net10.0 Azure.IoT.Hub.Service.Samples false diff --git a/sdk/keyvault/samples/getcert/getcert.csproj b/sdk/keyvault/samples/getcert/getcert.csproj index f26795847903..b261021ef819 100644 --- a/sdk/keyvault/samples/getcert/getcert.csproj +++ b/sdk/keyvault/samples/getcert/getcert.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net10.0 $(NoWarn); CA1810; diff --git a/sdk/keyvault/samples/keyvaultproxy/tests/AzureSamples.Security.KeyVault.Proxy.Tests.csproj b/sdk/keyvault/samples/keyvaultproxy/tests/AzureSamples.Security.KeyVault.Proxy.Tests.csproj index 4838b86096c7..d2cafcb83d9e 100644 --- a/sdk/keyvault/samples/keyvaultproxy/tests/AzureSamples.Security.KeyVault.Proxy.Tests.csproj +++ b/sdk/keyvault/samples/keyvaultproxy/tests/AzureSamples.Security.KeyVault.Proxy.Tests.csproj @@ -1,8 +1,8 @@ - net9.0;net8.0 - $(TargetFrameworks);net462 + $(RequiredRunnableTargetFrameworks) + $(TargetFrameworks);$(NetFxTargetFramework) false diff --git a/sdk/keyvault/samples/sharelink/ShareLink.csproj b/sdk/keyvault/samples/sharelink/ShareLink.csproj index 6c7618485d32..c9bc2c7f00a0 100644 --- a/sdk/keyvault/samples/sharelink/ShareLink.csproj +++ b/sdk/keyvault/samples/sharelink/ShareLink.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net10.0 Azure.Security.KeyVault.Storage $(NoWarn); diff --git a/sdk/modelsrepository/Azure.IoT.ModelsRepository/samples/ModelsRepositoryClientSamples/ModelsRepositoryClientSamples.csproj b/sdk/modelsrepository/Azure.IoT.ModelsRepository/samples/ModelsRepositoryClientSamples/ModelsRepositoryClientSamples.csproj index 0e0373c22aa4..21b0b247941e 100644 --- a/sdk/modelsrepository/Azure.IoT.ModelsRepository/samples/ModelsRepositoryClientSamples/ModelsRepositoryClientSamples.csproj +++ b/sdk/modelsrepository/Azure.IoT.ModelsRepository/samples/ModelsRepositoryClientSamples/ModelsRepositoryClientSamples.csproj @@ -1,7 +1,7 @@  Exe - net8.0 + $(LtsTargetFramework) Azure.IoT.ModelsRepository.Samples false diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/tests/Azure.Monitor.OpenTelemetry.AspNetCore.Tests/Azure.Monitor.OpenTelemetry.AspNetCore.Tests.csproj b/sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/tests/Azure.Monitor.OpenTelemetry.AspNetCore.Tests/Azure.Monitor.OpenTelemetry.AspNetCore.Tests.csproj index 69c34ce658fb..8503157b2088 100644 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/tests/Azure.Monitor.OpenTelemetry.AspNetCore.Tests/Azure.Monitor.OpenTelemetry.AspNetCore.Tests.csproj +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/tests/Azure.Monitor.OpenTelemetry.AspNetCore.Tests/Azure.Monitor.OpenTelemetry.AspNetCore.Tests.csproj @@ -6,6 +6,9 @@ + + + @@ -29,15 +32,4 @@ - - - - - - - - - - - diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.AotCompatibilityTestApp/Azure.Monitor.OpenTelemetry.Exporter.AotCompatibilityTestApp.csproj b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.AotCompatibilityTestApp/Azure.Monitor.OpenTelemetry.Exporter.AotCompatibilityTestApp.csproj index 87a48a8a3fed..b2140c626933 100644 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.AotCompatibilityTestApp/Azure.Monitor.OpenTelemetry.Exporter.AotCompatibilityTestApp.csproj +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.AotCompatibilityTestApp/Azure.Monitor.OpenTelemetry.Exporter.AotCompatibilityTestApp.csproj @@ -1,7 +1,7 @@ Exe - net9.0;net8.0;net462 + $(RequiredRunnableTargetFrameworks);$(NetFxTargetFramework) true diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.LiveMetrics/tests/Azure.Monitor.OpenTelemetry.LiveMetrics.Tests/Azure.Monitor.OpenTelemetry.LiveMetrics.Tests.csproj b/sdk/monitor/Azure.Monitor.OpenTelemetry.LiveMetrics/tests/Azure.Monitor.OpenTelemetry.LiveMetrics.Tests/Azure.Monitor.OpenTelemetry.LiveMetrics.Tests.csproj index 48e13adb9212..ef8a05beac3c 100644 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.LiveMetrics/tests/Azure.Monitor.OpenTelemetry.LiveMetrics.Tests/Azure.Monitor.OpenTelemetry.LiveMetrics.Tests.csproj +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.LiveMetrics/tests/Azure.Monitor.OpenTelemetry.LiveMetrics.Tests/Azure.Monitor.OpenTelemetry.LiveMetrics.Tests.csproj @@ -7,6 +7,9 @@ + + + @@ -32,15 +35,4 @@ - - - - - - - - - - - diff --git a/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/AzureChatClient.cs b/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/AzureChatClient.cs index b4c4576f9c7b..d968802f8fc9 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/AzureChatClient.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/AzureChatClient.cs @@ -8,6 +8,7 @@ #pragma warning disable AOAI001 #pragma warning disable AZC0112 +#pragma warning disable SCME0001 namespace Azure.AI.OpenAI.Chat; @@ -42,15 +43,27 @@ protected AzureChatClient() /// public override Task> CompleteChatAsync(IEnumerable messages, ChatCompletionOptions options = null, CancellationToken cancellationToken = default) { + bool maxTokenMasked = options == null ? false : AdditionalPropertyHelpers.GetIsEmptySentinelValue(options.Patch, "$.max_tokens"u8); PostfixSwapMaxTokens(ref options); - return base.CompleteChatAsync(messages, options, cancellationToken); + Task> result = base.CompleteChatAsync(messages, options, cancellationToken); + if (maxTokenMasked) + { + AdditionalPropertyHelpers.SetEmptySentinelValue(ref options.Patch, "$.max_tokens"u8); + } + return result; } /// public override ClientResult CompleteChat(IEnumerable messages, ChatCompletionOptions options = null, CancellationToken cancellationToken = default) { + bool maxTokenMasked = options == null ? false : AdditionalPropertyHelpers.GetIsEmptySentinelValue(options.Patch, "$.max_tokens"u8); PostfixSwapMaxTokens(ref options); - return base.CompleteChat(messages, options, cancellationToken); + ClientResult result = base.CompleteChat(messages, options, cancellationToken); + if (maxTokenMasked) + { + AdditionalPropertyHelpers.SetEmptySentinelValue(ref options.Patch, "$.max_tokens"u8); + } + return result; } /// @@ -65,16 +78,28 @@ public override CollectionResult CompleteChatStre public override AsyncCollectionResult CompleteChatStreamingAsync(IEnumerable messages, ChatCompletionOptions options = null, CancellationToken cancellationToken = default) { PostfixClearStreamOptions(messages, ref options); + bool maxTokenMasked = options == null ? false : AdditionalPropertyHelpers.GetIsEmptySentinelValue(options.Patch, "$.max_tokens"u8); PostfixSwapMaxTokens(ref options); - return base.CompleteChatStreamingAsync(messages, options, cancellationToken); + AsyncCollectionResult < StreamingChatCompletionUpdate > result = base.CompleteChatStreamingAsync(messages, options, cancellationToken); + if (maxTokenMasked) + { + AdditionalPropertyHelpers.SetEmptySentinelValue(ref options.Patch, "$.max_tokens"u8); + } + return result; } /// public override CollectionResult CompleteChatStreaming(IEnumerable messages, ChatCompletionOptions options = null, CancellationToken cancellationToken = default) { PostfixClearStreamOptions(messages, ref options); + bool maxTokenMasked = options == null ? false : AdditionalPropertyHelpers.GetIsEmptySentinelValue(options.Patch, "$.max_tokens"u8); PostfixSwapMaxTokens(ref options); - return base.CompleteChatStreaming(messages, options, cancellationToken); + CollectionResult < StreamingChatCompletionUpdate > result = base.CompleteChatStreaming(messages, options, cancellationToken); + if (maxTokenMasked) + { + AdditionalPropertyHelpers.SetEmptySentinelValue(ref options.Patch, "$.max_tokens"u8); + } + return result; } /** @@ -86,19 +111,19 @@ public override CollectionResult CompleteChatStre */ private static void PostfixClearStreamOptions(IEnumerable messages, ref ChatCompletionOptions options) { - if (AdditionalPropertyHelpers - .GetAdditionalPropertyAsListOfChatDataSource(options?.SerializedAdditionalRawData, "data_sources")?.Count > 0 + if (options?.GetDataSources()?.Count > 0 || messages?.Any( message => message?.Content?.Any( contentPart => contentPart?.Kind == ChatMessageContentPartKind.Image) == true) == true) { options ??= new(); - options.SerializedAdditionalRawData ??= new Dictionary(); - AdditionalPropertyHelpers.SetEmptySentinelValue(options.SerializedAdditionalRawData, "stream_options"); + options.Patch.Remove("$.stream_options"u8); } } + private static bool HasValue(JsonPatch patch, ReadOnlySpan path) => patch.Contains(path) && !patch.IsRemoved(path); + /** * As of 2024-09-01-preview, Azure OpenAI conditionally supports the use of the new max_completion_tokens property: * - The o1-mini and o1-preview models accept max_completion_tokens and reject max_tokens @@ -113,52 +138,30 @@ private static void PostfixClearStreamOptions(IEnumerable messages, private static void PostfixSwapMaxTokens(ref ChatCompletionOptions options) { options ??= new(); - bool valueIsSet = options.MaxOutputTokenCount is not null; - bool oldPropertyBlocked = AdditionalPropertyHelpers.GetIsEmptySentinelValue(options.SerializedAdditionalRawData, "max_tokens"); + bool oldPropertyBlocked = AdditionalPropertyHelpers.GetIsEmptySentinelValue(options.Patch, "$.max_tokens"u8); - if (valueIsSet) + if (options.MaxOutputTokenCount.HasValue) { if (!oldPropertyBlocked) { - options.SerializedAdditionalRawData ??= new ChangeTrackingDictionary(); - AdditionalPropertyHelpers.SetEmptySentinelValue(options.SerializedAdditionalRawData, "max_completion_tokens"); - - using MemoryStream stream = new(); - using Utf8JsonWriter writer = new(stream); - - if (options.MaxOutputTokenCount != null) - { - writer.WriteNumberValue(options.MaxOutputTokenCount.Value); - } - else - { - writer.WriteNullValue(); - } - - writer.Flush(); - - options.SerializedAdditionalRawData["max_tokens"] = BinaryData.FromBytes(stream.ToArray()); + options.Patch.Remove("$.max_completion_tokens"u8); + options.Patch.Set("$.max_tokens"u8, options.MaxOutputTokenCount.Value); } else { - // Allow standard serialization to the new property to occur; remove overrides - if (options.SerializedAdditionalRawData.ContainsKey("max_completion_tokens")) - { - options.SerializedAdditionalRawData.Remove("max_completion_tokens"); - } + options.Patch.Remove("$.max_tokens"u8); + options.Patch.Set("$.max_completion_tokens"u8, options.MaxOutputTokenCount.Value); } } else { - if (!AdditionalPropertyHelpers.GetIsEmptySentinelValue(options.SerializedAdditionalRawData, "max_tokens") - && options.SerializedAdditionalRawData?.ContainsKey("max_tokens") == true) + if (HasValue(options.Patch, "$.max_tokens"u8)) { - options.SerializedAdditionalRawData.Remove("max_tokens"); + options.Patch.Remove("$.max_tokens"u8); } - if (!AdditionalPropertyHelpers.GetIsEmptySentinelValue(options.SerializedAdditionalRawData, "max_completion_tokens") - && options.SerializedAdditionalRawData?.ContainsKey("max_completion_tokens") == true) + if (HasValue(options.Patch, "$.max_completion_tokens"u8)) { - options.SerializedAdditionalRawData.Remove("max_completion_tokens"); + options.Patch.Remove("$.max_completion_tokens"u8); } } } diff --git a/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/AzureChatExtensions.cs b/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/AzureChatExtensions.cs index 5218994e901e..9956da431718 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/AzureChatExtensions.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/AzureChatExtensions.cs @@ -1,8 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Azure.AI.OpenAI.Internal; +using System.ClientModel; +using System.ClientModel.Primitives; using System.Diagnostics.CodeAnalysis; +using System.Text; +using System.Text.Json; +using System.Text.Json.Nodes; +using Azure.AI.OpenAI.Internal; #pragma warning disable AZC0112 @@ -14,26 +19,40 @@ public static partial class AzureChatExtensions [Experimental("AOAI001")] public static void AddDataSource(this ChatCompletionOptions options, ChatDataSource dataSource) { - options.SerializedAdditionalRawData ??= new Dictionary(); - - IList existingSources = - AdditionalPropertyHelpers.GetAdditionalPropertyAsListOfChatDataSource( - options.SerializedAdditionalRawData, - "data_sources") - ?? new ChangeTrackingList(); - existingSources.Add(dataSource); - AdditionalPropertyHelpers.SetAdditionalProperty( - options.SerializedAdditionalRawData, - "data_sources", - existingSources); + JsonArray doc; + if (options.Patch.Contains("$.data_sources"u8) && options.Patch.TryGetJson("$.data_sources"u8, out ReadOnlyMemory jsonBytes)) + { + using var stream = new MemoryStream(); + stream.Write(jsonBytes.ToArray(), 0, jsonBytes.Length); + string json = Encoding.UTF8.GetString(stream.ToArray()); + doc = JsonObject.Parse(json).AsArray(); + } + else + { + doc = new(); + } + using var objectStream = new MemoryStream(); + using BinaryContent contentBytes = BinaryContent.Create(dataSource, ModelSerializationExtensions.WireOptions); + contentBytes.WriteTo(objectStream); + string newJson = Encoding.UTF8.GetString(objectStream.ToArray()); + doc.Add(JsonObject.Parse(newJson)); + options.Patch.Set("$.data_sources"u8, BinaryData.FromString(doc.ToJsonString())); } [Experimental("AOAI001")] public static IReadOnlyList GetDataSources(this ChatCompletionOptions options) { - return AdditionalPropertyHelpers.GetAdditionalPropertyAsListOfChatDataSource( - options.SerializedAdditionalRawData, - "data_sources") as IReadOnlyList; + if (options.Patch.Contains("$.data_sources"u8) && options.Patch.TryGetJson("$.data_sources"u8, out ReadOnlyMemory mem)) + { + using JsonDocument doc = JsonDocument.Parse(mem); + List chats = []; + foreach (JsonElement dataSource in doc.RootElement.EnumerateArray()) + { + chats.Add(ChatDataSource.DeserializeChatDataSource(dataSource, ModelSerializationExtensions.WireOptions)); + } + return chats; + } + return null; } [Experimental("AOAI001")] @@ -42,16 +61,13 @@ public static void SetNewMaxCompletionTokensPropertyEnabled(this ChatCompletionO if (newPropertyEnabled) { // Blocking serialization of max_tokens via dictionary acts as a signal to skip pre-serialization fixup - options.SerializedAdditionalRawData ??= new Dictionary(); - AdditionalPropertyHelpers.SetEmptySentinelValue(options.SerializedAdditionalRawData, "max_tokens"); + AdditionalPropertyHelpers.SetEmptySentinelValue(patch: ref options.Patch, path: "$.max_tokens"u8); } else { - // In the absence of a dictionary serialization block to max_tokens, the newer property name will - // automatically be blocked and the older property name will be used via dictionary override - if (options?.SerializedAdditionalRawData?.ContainsKey("max_tokens") == true) + if (options.Patch.Contains("$.max_tokens"u8) && !options.Patch.IsRemoved("$.max_tokens"u8)) { - options?.SerializedAdditionalRawData?.Remove("max_tokens"); + options.Patch.Remove("$.max_tokens"u8); } } } @@ -59,35 +75,45 @@ public static void SetNewMaxCompletionTokensPropertyEnabled(this ChatCompletionO [Experimental("AOAI001")] public static RequestContentFilterResult GetRequestContentFilterResult(this ChatCompletion chatCompletion) { - return AdditionalPropertyHelpers.GetAdditionalPropertyAsListOfRequestContentFilterResult( - chatCompletion.SerializedAdditionalRawData, - "prompt_filter_results")?[0]; + if (chatCompletion.Patch.Contains("$.prompt_filter_results"u8) && chatCompletion.Patch.TryGetJson("$.prompt_filter_results"u8, out ReadOnlyMemory mem)) + { + using JsonDocument doc = JsonDocument.Parse(mem); + return RequestContentFilterResult.DeserializeRequestContentFilterResult(doc.RootElement.EnumerateArray().First(), ModelSerializationExtensions.WireOptions); + } + return null; } [Experimental("AOAI001")] public static ResponseContentFilterResult GetResponseContentFilterResult(this ChatCompletion chatCompletion) { - return AdditionalPropertyHelpers.GetAdditionalPropertyAsResponseContentFilterResult( - chatCompletion.Choices?[0]?.SerializedAdditionalRawData, - "content_filter_results"); + if ((chatCompletion.Choices?[0]?.Patch.Contains("$.content_filter_results"u8) ?? false) && + (chatCompletion.Choices?[0]?.Patch.TryGetJson("$.content_filter_results"u8, out ReadOnlyMemory mem) ?? false)) + { + using JsonDocument doc = JsonDocument.Parse(mem); + return ResponseContentFilterResult.DeserializeResponseContentFilterResult(doc.RootElement, ModelSerializationExtensions.WireOptions); + } + return null; } [Experimental("AOAI001")] public static ChatMessageContext GetMessageContext(this ChatCompletion chatCompletion) { - return AdditionalPropertyHelpers.GetAdditionalPropertyAsChatMessageContext( - chatCompletion.Choices?[0]?.Message?.SerializedAdditionalRawData, - "context"); + if ((chatCompletion.Choices?[0]?.Message?.Patch.Contains("$.context"u8) ?? false) && + (chatCompletion.Choices?[0]?.Message?.Patch.TryGetJson("$.context"u8, out ReadOnlyMemory mem) ?? false)) + { + using JsonDocument doc = JsonDocument.Parse(mem); + return ChatMessageContext.DeserializeChatMessageContext(doc.RootElement, ModelSerializationExtensions.WireOptions); + } + return null; } [Experimental("AOAI001")] public static ChatMessageContext GetMessageContext(this StreamingChatCompletionUpdate chatUpdate) { - if (chatUpdate.Choices?.Count > 0) + if (chatUpdate.Choices?.Count > 0 && chatUpdate.Choices[0].Delta.Patch.Contains("$.context"u8) && chatUpdate.Choices[0].Delta.Patch.TryGetJson("$.context"u8, out ReadOnlyMemory mem)) { - return AdditionalPropertyHelpers.GetAdditionalPropertyAsChatMessageContext( - chatUpdate.Choices[0].Delta?.SerializedAdditionalRawData, - "context"); + using JsonDocument doc = JsonDocument.Parse(mem); + return ChatMessageContext.DeserializeChatMessageContext(doc.RootElement, ModelSerializationExtensions.WireOptions); } return null; } @@ -95,46 +121,54 @@ public static ChatMessageContext GetMessageContext(this StreamingChatCompletionU [Experimental("AOAI001")] public static RequestContentFilterResult GetRequestContentFilterResult(this StreamingChatCompletionUpdate chatUpdate) { - return AdditionalPropertyHelpers.GetAdditionalPropertyAsListOfRequestContentFilterResult( - chatUpdate.SerializedAdditionalRawData, - "prompt_filter_results")?[0]; + if (chatUpdate.Patch.Contains("$.prompt_filter_results"u8) && chatUpdate.Patch.TryGetJson("$.prompt_filter_results"u8, out ReadOnlyMemory mem)) + { + using JsonDocument doc = JsonDocument.Parse(mem); + return RequestContentFilterResult.DeserializeRequestContentFilterResult(doc.RootElement.EnumerateArray().First(), ModelSerializationExtensions.WireOptions); + } + return null; } [Experimental("AOAI001")] public static ResponseContentFilterResult GetResponseContentFilterResult(this StreamingChatCompletionUpdate chatUpdate) { - return AdditionalPropertyHelpers.GetAdditionalPropertyAsResponseContentFilterResult( - chatUpdate?.Choices?.ElementAtOrDefault(0)?.SerializedAdditionalRawData, - "content_filter_results"); + if ((chatUpdate?.Choices?.ElementAtOrDefault(0)?.Patch.Contains("$.content_filter_results"u8) ?? false) && (chatUpdate?.Choices?.ElementAtOrDefault(0)?.Patch.TryGetJson("$.content_filter_results"u8, out ReadOnlyMemory mem) ?? false)) + { + using JsonDocument doc = JsonDocument.Parse(mem); + return ResponseContentFilterResult.DeserializeResponseContentFilterResult(doc.RootElement, ModelSerializationExtensions.WireOptions); + } + return null; } [Experimental("AOAI001")] public static void SetUserSecurityContext(this ChatCompletionOptions options, UserSecurityContext userSecurityContext) { - options.SerializedAdditionalRawData ??= new Dictionary(); - - AdditionalPropertyHelpers.SetAdditionalProperty( - options.SerializedAdditionalRawData, - "user_security_context", - userSecurityContext); + using BinaryContent contentBytes = BinaryContent.Create(userSecurityContext, ModelSerializationExtensions.WireOptions); + using var stream = new MemoryStream(); + contentBytes.WriteTo(stream); + BinaryData bin = new(stream.ToArray()); + options.Patch.Set("$.user_security_context"u8, bin); } [Experimental("AOAI001")] public static UserSecurityContext GetUserSecurityContext(this ChatCompletionOptions options) { - return AdditionalPropertyHelpers.GetAdditionalPropertyAsUserSecurityContext( - options.SerializedAdditionalRawData, - "user_security_context"); + if (options.Patch.Contains("$.user_security_context"u8) && options.Patch.TryGetJson("$.user_security_context"u8, out ReadOnlyMemory mem)) + { + using JsonDocument doc = JsonDocument.Parse(mem); + return UserSecurityContext.DeserializeUserSecurityContext(doc.RootElement, ModelSerializationExtensions.WireOptions); + } + return null; } [Experimental("AOAI001")] public static string GetMessageReasoningContent(this ChatCompletion chatCompletion) { - if (chatCompletion?.Choices?.FirstOrDefault()?.Message?.SerializedAdditionalRawData?.TryGetValue("reasoning_content", out BinaryData reasoningContentData) == true - && reasoningContentData?.ToString() is string retrievedReasoningContent) + if ((chatCompletion?.Choices?.FirstOrDefault()?.Message?.Patch.Contains("$.reasoning_content"u8) ?? false) && + (chatCompletion?.Choices?.FirstOrDefault()?.Message?.Patch.TryGetValue("$.reasoning_content"u8, out string retrievedReasoningContent) ?? false)) { return retrievedReasoningContent; } return null; } -} \ No newline at end of file +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Custom/Common/AdditionalPropertyHelpers.cs b/sdk/openai/Azure.AI.OpenAI/src/Custom/Common/AdditionalPropertyHelpers.cs index b724d26f2a84..19a1cce2a20d 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Custom/Common/AdditionalPropertyHelpers.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Custom/Common/AdditionalPropertyHelpers.cs @@ -1,13 +1,16 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Azure.AI.OpenAI.Chat; +using System; using System.ClientModel.Primitives; using System.Text.Json; +using Azure.AI.OpenAI.Chat; namespace Azure.AI.OpenAI.Internal; #pragma warning disable AOAI001 +#pragma warning disable SCME0001 + internal static class AdditionalPropertyHelpers { private static string SARD_EMPTY_SENTINEL = "__EMPTY__"; @@ -101,6 +104,20 @@ internal static void SetEmptySentinelValue(IDictionary addit additionalProperties[key] = BinaryData.FromBytes(stream.ToArray()); } + internal static void SetEmptySentinelValue(ref JsonPatch patch, ReadOnlySpan path) + { + patch.Set(path, SARD_EMPTY_SENTINEL); + } + + internal static bool GetIsEmptySentinelValue(JsonPatch patch, ReadOnlySpan path) + { + if (patch.Contains(path) && patch.TryGetValue(path, out string val)) + { + return string.Equals(val, SARD_EMPTY_SENTINEL); + } + return false; + } + internal static bool GetIsEmptySentinelValue(IDictionary additionalProperties, string key) { return additionalProperties is not null @@ -108,4 +125,4 @@ internal static bool GetIsEmptySentinelValue(IDictionary add && StringComparer.OrdinalIgnoreCase.Equals(existingValue.ToString(), $@"""{SARD_EMPTY_SENTINEL}"""); } } -#pragma warning restore AOAI001 \ No newline at end of file +#pragma warning restore AOAI001 diff --git a/sdk/openai/Azure.AI.OpenAI/src/Custom/Internal/VectorStoreCollectionPageToken.cs b/sdk/openai/Azure.AI.OpenAI/src/Custom/Internal/VectorStoreCollectionPageToken.cs new file mode 100644 index 000000000000..ffa8ba0e1213 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Custom/Internal/VectorStoreCollectionPageToken.cs @@ -0,0 +1,149 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Diagnostics; +using System.Text.Json; + +#nullable enable + +namespace Azure.AI.OpenAI.VectorStores; + +internal class VectorStoreCollectionPageToken : ContinuationToken +{ + protected VectorStoreCollectionPageToken(int? limit, string? order, string? after, string? before) + { + Limit = limit; + Order = order; + After = after; + Before = before; + } + + public int? Limit { get; } + + public string? Order { get; } + + public string? After { get; } + + public string? Before { get; } + + public override BinaryData ToBytes() + { + using MemoryStream stream = new(); + using Utf8JsonWriter writer = new(stream); + + writer.WriteStartObject(); + + if (Limit.HasValue) + { + writer.WriteNumber("limit", Limit.Value); + } + + if (Order is not null) + { + writer.WriteString("order", Order); + } + + if (After is not null) + { + writer.WriteString("after", After); + } + + if (Before is not null) + { + writer.WriteString("before", Before); + } + + writer.WriteEndObject(); + + writer.Flush(); + stream.Position = 0; + + return BinaryData.FromStream(stream); + } + + public static VectorStoreCollectionPageToken FromToken(ContinuationToken pageToken) + { + if (pageToken is VectorStoreCollectionPageToken token) + { + return token; + } + + BinaryData data = pageToken.ToBytes(); + + if (data.ToMemory().Length == 0) + { + throw new ArgumentException("Failed to create VectorStoresPageToken from provided pageToken.", nameof(pageToken)); + } + + Utf8JsonReader reader = new(data); + + int? limit = null; + string? order = null; + string? after = null; + string? before = null; + + reader.Read(); + + Debug.Assert(reader.TokenType == JsonTokenType.StartObject); + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject) + { + break; + } + + Debug.Assert(reader.TokenType == JsonTokenType.PropertyName); + + string propertyName = reader.GetString()!; + + switch (propertyName) + { + case "limit": + reader.Read(); + Debug.Assert(reader.TokenType == JsonTokenType.Number); + limit = reader.GetInt32(); + break; + case "order": + reader.Read(); + Debug.Assert(reader.TokenType == JsonTokenType.String); + order = reader.GetString(); + break; + case "after": + reader.Read(); + Debug.Assert(reader.TokenType == JsonTokenType.String); + after = reader.GetString(); + break; + case "before": + reader.Read(); + Debug.Assert(reader.TokenType == JsonTokenType.String); + before = reader.GetString(); + break; + default: + throw new JsonException($"Unrecognized property '{propertyName}'."); + } + } + + return new(limit, order, after, before); + } + + public static VectorStoreCollectionPageToken FromOptions(int? limit, string? order, string? after, string? before) + => new(limit, order, after, before); + + public static VectorStoreCollectionPageToken? FromResponse(ClientResult result, int? limit, string? order, string? before) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument doc = JsonDocument.Parse(response.Content); + string lastId = doc.RootElement.GetProperty("last_id"u8).GetString()!; + bool hasMore = doc.RootElement.GetProperty("has_more"u8).GetBoolean(); + + if (!hasMore || lastId is null) + { + return null; + } + + return new(limit, order, lastId, before); + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Custom/Internal/VectorStoreCollectionResult.cs b/sdk/openai/Azure.AI.OpenAI/src/Custom/Internal/VectorStoreCollectionResult.cs new file mode 100644 index 000000000000..9b99510954e0 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Custom/Internal/VectorStoreCollectionResult.cs @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; + +#nullable enable + +namespace Azure.AI.OpenAI.VectorStores; + +internal class VectorStoreCollectionResult : CollectionResult +{ + private readonly VectorStoreClient _vectorStoreClient; + private readonly ClientPipeline _pipeline; + private readonly RequestOptions? _options; + + // Initial values + private readonly int? _limit; + private readonly string? _order; + private readonly string? _after; + private readonly string? _before; + + public VectorStoreCollectionResult(VectorStoreClient vectorStoreClient, + ClientPipeline pipeline, RequestOptions? options, + int? limit, string? order, string? after, string? before) + { + _vectorStoreClient = vectorStoreClient; + _pipeline = pipeline; + _options = options; + + _limit = limit; + _order = order; + _after = after; + _before = before; + } + + public override IEnumerable GetRawPages() + { + ClientResult page = GetFirstPage(); + yield return page; + + while (HasNextPage(page)) + { + page = GetNextPage(page); + yield return page; + } + } + + protected override IEnumerable GetValuesFromPage(ClientResult page) + { + Argument.AssertNotNull(page, nameof(page)); + + PipelineResponse response = page.GetRawResponse(); + InternalListVectorStoresResponse list = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, OpenAIContext.Default)!; + return list.Data; + } + + public override ContinuationToken? GetContinuationToken(ClientResult page) + { + Argument.AssertNotNull(page, nameof(page)); + + return VectorStoreCollectionPageToken.FromResponse(page, _limit, _order, _before); + } + + public ClientResult GetFirstPage() + => GetVectorStores(_limit, _order, _after, _before, _options); + + public ClientResult GetNextPage(ClientResult result) + { + Argument.AssertNotNull(result, nameof(result)); + + PipelineResponse response = result.GetRawResponse(); + + using JsonDocument doc = JsonDocument.Parse(response.Content); + string lastId = doc.RootElement.GetProperty("last_id"u8).GetString()!; + + return GetVectorStores(_limit, _order, lastId, _before, _options); + } + + public static bool HasNextPage(ClientResult result) + { + Argument.AssertNotNull(result, nameof(result)); + + PipelineResponse response = result.GetRawResponse(); + + using JsonDocument doc = JsonDocument.Parse(response.Content); + bool hasMore = doc.RootElement.GetProperty("has_more"u8).GetBoolean(); + + return hasMore; + } + + internal virtual ClientResult GetVectorStores(int? limit, string? order, string? after, string? before, RequestOptions? options) + { + using PipelineMessage message = _vectorStoreClient.CreateGetVectorStoresRequest(limit, order, after, before, options); + return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Custom/Internal/VectorStoreFileCollectionPageToken.cs b/sdk/openai/Azure.AI.OpenAI/src/Custom/Internal/VectorStoreFileCollectionPageToken.cs new file mode 100644 index 000000000000..8a92c1a135b5 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Custom/Internal/VectorStoreFileCollectionPageToken.cs @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Diagnostics; +using System.Text.Json; + +#nullable enable + +namespace Azure.AI.OpenAI.VectorStores; + +internal class VectorStoreFileCollectionPageToken : ContinuationToken +{ + protected VectorStoreFileCollectionPageToken(string vectorStoreId, int? limit, string? order, string? after, string? before, string? filter) + { + VectorStoreId = vectorStoreId; + + Limit = limit; + Order = order; + After = after; + Before = before; + Filter = filter; + } + + public string VectorStoreId { get; } + + public int? Limit { get; } + + public string? Order { get; } + + public string? After { get; } + + public string? Before { get; } + + public string? Filter { get; } + + public override BinaryData ToBytes() + { + using MemoryStream stream = new(); + using Utf8JsonWriter writer = new(stream); + + writer.WriteStartObject(); + writer.WriteString("vectorStoreId", VectorStoreId); + + if (Limit.HasValue) + { + writer.WriteNumber("limit", Limit.Value); + } + + if (Order is not null) + { + writer.WriteString("order", Order); + } + + if (After is not null) + { + writer.WriteString("after", After); + } + + if (Before is not null) + { + writer.WriteString("before", Before); + } + + if (Filter is not null) + { + writer.WriteString("filter", Filter); + } + + writer.WriteEndObject(); + + writer.Flush(); + stream.Position = 0; + + return BinaryData.FromStream(stream); + } + + public static VectorStoreFileCollectionPageToken FromToken(ContinuationToken pageToken) + { + if (pageToken is VectorStoreFileCollectionPageToken token) + { + return token; + } + + BinaryData data = pageToken.ToBytes(); + + if (data.ToMemory().Length == 0) + { + throw new ArgumentException("Failed to create VectorStoreFilesPageToken from provided pageToken.", nameof(pageToken)); + } + + Utf8JsonReader reader = new(data); + + string vectorStoreId = null!; + int? limit = null; + string? order = null; + string? after = null; + string? before = null; + string? filter = null; + + reader.Read(); + + Debug.Assert(reader.TokenType == JsonTokenType.StartObject); + + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject) + { + break; + } + + Debug.Assert(reader.TokenType == JsonTokenType.PropertyName); + + string propertyName = reader.GetString()!; + + switch (propertyName) + { + case "vectorStoreId": + reader.Read(); + Debug.Assert(reader.TokenType == JsonTokenType.String); + vectorStoreId = reader.GetString()!; + break; + case "limit": + reader.Read(); + Debug.Assert(reader.TokenType == JsonTokenType.Number); + limit = reader.GetInt32(); + break; + case "order": + reader.Read(); + Debug.Assert(reader.TokenType == JsonTokenType.String); + order = reader.GetString(); + break; + case "after": + reader.Read(); + Debug.Assert(reader.TokenType == JsonTokenType.String); + after = reader.GetString(); + break; + case "before": + reader.Read(); + Debug.Assert(reader.TokenType == JsonTokenType.String); + before = reader.GetString(); + break; + case "filter": + reader.Read(); + Debug.Assert(reader.TokenType == JsonTokenType.String); + filter = reader.GetString(); + break; + default: + throw new JsonException($"Unrecognized property '{propertyName}'."); + } + } + + if (vectorStoreId is null) + { + throw new ArgumentException("Failed to create VectorStoreFilesPageToken from provided pageToken.", nameof(pageToken)); + } + + return new(vectorStoreId, limit, order, after, before, filter); + } + + public static VectorStoreFileCollectionPageToken FromOptions(string vectorStoreId, int? limit, string? order, string? after, string? before, string? filter) + => new(vectorStoreId, limit, order, after, before, filter); + + public static VectorStoreFileCollectionPageToken? FromResponse(ClientResult result, string vectorStoreId, int? limit, string? order, string? before, string? filter) + { + PipelineResponse response = result.GetRawResponse(); + using JsonDocument doc = JsonDocument.Parse(response.Content); + string lastId = doc.RootElement.GetProperty("last_id"u8).GetString()!; + bool hasMore = doc.RootElement.GetProperty("has_more"u8).GetBoolean(); + + if (!hasMore || lastId is null) + { + return null; + } + + return new(vectorStoreId, limit, order, lastId, before, filter); + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Custom/Responses/AzureResponsesClient.Protocol.cs b/sdk/openai/Azure.AI.OpenAI/src/Custom/Responses/AzureResponsesClient.Protocol.cs index 2dbab7685fb1..6a81525d4393 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Custom/Responses/AzureResponsesClient.Protocol.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Custom/Responses/AzureResponsesClient.Protocol.cs @@ -41,7 +41,7 @@ internal override PipelineMessage CreateGetResponseRequest(string responseId, IE .WithOptions(options) .Build(); - internal override PipelineMessage CreateGetInputItemsRequest(string responseId, int? limit, string order, string after, string before, RequestOptions options) + internal PipelineMessage CreateGetInputItemsRequest(string responseId, int? limit, string order, string after, string before, RequestOptions options) => new AzureOpenAIPipelineMessageBuilder(Pipeline, _aoaiEndpoint, _apiVersion, string.Empty) .WithPath("responses", responseId, "input_items") .WithMethod("GET") @@ -74,4 +74,4 @@ private static string GetIncludeQueryStringValue(IEnumerable } } -#endif \ No newline at end of file +#endif diff --git a/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureVectorStoreClient.Protocol.cs b/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureVectorStoreClient.Protocol.cs index a881aef45ce6..bdee746839af 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureVectorStoreClient.Protocol.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Custom/VectorStores/AzureVectorStoreClient.Protocol.cs @@ -5,7 +5,6 @@ using System.ClientModel; using System.ClientModel.Primitives; -using System.Threading; using Azure.AI.OpenAI.Utility; namespace Azure.AI.OpenAI.VectorStores; diff --git a/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs b/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs index 721f46e23aa2..ac509b627d5d 100644 --- a/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs +++ b/sdk/openai/Azure.AI.OpenAI/tests/ChatTests.cs @@ -20,7 +20,8 @@ using OpenAI.TestFramework.Utils; namespace Azure.AI.OpenAI.Tests; - +#pragma warning disable AOAI001 +#pragma warning disable SCME0001 public partial class ChatTests : AoaiTestBase { public ChatTests(bool isAsync) : base(isAsync) @@ -168,10 +169,18 @@ bool GetSerializedOptionsContains(string value) BinaryData serialized = ModelReaderWriter.Write(options); return serialized.ToString().Contains(value); } - async Task AssertExpectedSerializationAsync(bool hasOldMaxTokens, bool hasNewMaxCompletionTokens) + async Task AssertExpectedSerializationAsync(bool hasOldMaxTokens, bool hasNewMaxCompletionTokens, bool isSentilel=false) { _ = await client.CompleteChatAsync(["Just mocking, no call here"], options); - Assert.That(GetSerializedOptionsContains("max_tokens"), Is.EqualTo(hasOldMaxTokens)); + if (isSentilel) + { + Assert.True(GetSerializedOptionsContains("max_tokens")); + Assert.True(GetSerializedOptionsContains("__EMPTY__")); + } + else + { + Assert.That(GetSerializedOptionsContains("max_tokens"), Is.EqualTo(hasOldMaxTokens)); + } Assert.That(GetSerializedOptionsContains("max_completion_tokens"), Is.EqualTo(hasNewMaxCompletionTokens)); } @@ -187,12 +196,12 @@ async Task AssertExpectedSerializationAsync(bool hasOldMaxTokens, bool hasNewMax await AssertExpectedSerializationAsync(true, false); options.SetNewMaxCompletionTokensPropertyEnabled(); - await AssertExpectedSerializationAsync(false, true); - await AssertExpectedSerializationAsync(false, true); + await AssertExpectedSerializationAsync(false, true, true); + await AssertExpectedSerializationAsync(false, true, true); options.MaxOutputTokenCount = null; - await AssertExpectedSerializationAsync(false, false); + await AssertExpectedSerializationAsync(false, false, true); options.MaxOutputTokenCount = 42; - await AssertExpectedSerializationAsync(false, true); + await AssertExpectedSerializationAsync(false, true, true); options.SetNewMaxCompletionTokensPropertyEnabled(false); await AssertExpectedSerializationAsync(true, false); @@ -560,7 +569,6 @@ public async Task MaxOutputTokensWorksAcrossModels(string testConfigName, bool u { options.SetNewMaxCompletionTokensPropertyEnabled(); } - ChatCompletion completion = await client.CompleteChatAsync( ["Hello, world! Please write a funny haiku to greet me."], options); @@ -568,15 +576,16 @@ public async Task MaxOutputTokensWorksAcrossModels(string testConfigName, bool u string serializedOptionsAfterUse = ModelReaderWriter.Write(options).ToString(); + Assert.That(serializedOptionsAfterUse, Does.Contain("max_tokens")); if (useNewProperty) { Assert.That(serializedOptionsAfterUse, Does.Contain("max_completion_tokens")); - Assert.That(serializedOptionsAfterUse, Does.Not.Contain("max_tokens")); + Assert.That(serializedOptionsAfterUse, Does.Contain("__EMPTY__")); } else { Assert.That(serializedOptionsAfterUse, Does.Not.Contain("max_completion_tokens")); - Assert.That(serializedOptionsAfterUse, Does.Contain("max_tokens")); + Assert.That(serializedOptionsAfterUse, Does.Not.Contain("__EMPTY__")); } } #endregion diff --git a/sdk/openai/Azure.AI.OpenAI/tests/ResponsesTests.cs b/sdk/openai/Azure.AI.OpenAI/tests/ResponsesTests.cs index dd63f92235e9..b516defed193 100644 --- a/sdk/openai/Azure.AI.OpenAI/tests/ResponsesTests.cs +++ b/sdk/openai/Azure.AI.OpenAI/tests/ResponsesTests.cs @@ -83,10 +83,12 @@ public async Task FileSearch(string deploymentName) Assert.That(citationAnnotation?.FileId, Is.EqualTo(testFile.Id)); Assert.That(citationAnnotation?.Index, Is.GreaterThan(0)); - await foreach (ResponseItem inputItem in client.GetResponseInputItemsAsync(response?.Id)) - { - Console.WriteLine(ModelReaderWriter.Write(inputItem).ToString()); - } + // The AzureOpenAI endpoint does not serve the path for + // https://{Azure OpenAI endpoint}/responses/{response.Id}/input_items + //await foreach (ResponseItem inputItem in client.GetResponseInputItemsAsync(response?.Id)) + //{ + // Console.WriteLine(ModelReaderWriter.Write(inputItem).ToString()); + //} } [RecordedTest] @@ -516,32 +518,33 @@ public async Task AllInstructionMethodsWork(ResponsesTestInstructionMethod instr { Assert.That(retrievedResponse?.Instructions, Is.EqualTo(instructions)); } - - List listedItems = []; - await foreach (ResponseItem item in client.GetResponseInputItemsAsync(response?.Id)) - { - listedItems.Add(item); - } - - if (instructionMethod == ResponsesTestInstructionMethod.InstructionsProperty) - { - Assert.That(listedItems, Has.Count.EqualTo(1)); - Assert.That((listedItems[0] as MessageResponseItem)?.Content?.FirstOrDefault()?.Text, Is.EqualTo(userMessage)); - } - else - { - Assert.That(listedItems, Has.Count.EqualTo(2)); - MessageResponseItem? systemOrDeveloperMessage = listedItems?[1] as MessageResponseItem; - Assert.That(systemOrDeveloperMessage, Is.Not.Null); - Assert.That(systemOrDeveloperMessage?.Role, Is.EqualTo(instructionMethod switch - { - ResponsesTestInstructionMethod.DeveloperMessage => MessageRole.Developer, - ResponsesTestInstructionMethod.SystemMessage => MessageRole.System, - _ => throw new ArgumentException() - })); - Assert.That(systemOrDeveloperMessage?.Content?.FirstOrDefault()?.Text, Is.EqualTo(instructions)); - Assert.That((listedItems?[0] as MessageResponseItem)?.Content?.FirstOrDefault()?.Text, Is.EqualTo(userMessage)); - } + // The AzureOpenAI endpoint does not serve the path for + // https://{Azure OpenAI endpoint}/responses/{response.Id}/input_items + //List listedItems = []; + //await foreach (ResponseItem item in client.GetResponseInputItemsAsync(response?.Id)) + //{ + // listedItems.Add(item); + //} + + //if (instructionMethod == ResponsesTestInstructionMethod.InstructionsProperty) + //{ + // Assert.That(listedItems, Has.Count.EqualTo(1)); + // Assert.That((listedItems[0] as MessageResponseItem)?.Content?.FirstOrDefault()?.Text, Is.EqualTo(userMessage)); + //} + //else + //{ + // Assert.That(listedItems, Has.Count.EqualTo(2)); + // MessageResponseItem? systemOrDeveloperMessage = listedItems?[1] as MessageResponseItem; + // Assert.That(systemOrDeveloperMessage, Is.Not.Null); + // Assert.That(systemOrDeveloperMessage?.Role, Is.EqualTo(instructionMethod switch + // { + // ResponsesTestInstructionMethod.DeveloperMessage => MessageRole.Developer, + // ResponsesTestInstructionMethod.SystemMessage => MessageRole.System, + // _ => throw new ArgumentException() + // })); + // Assert.That(systemOrDeveloperMessage?.Content?.FirstOrDefault()?.Text, Is.EqualTo(instructions)); + // Assert.That((listedItems?[0] as MessageResponseItem)?.Content?.FirstOrDefault()?.Text, Is.EqualTo(userMessage)); + //} } [RecordedTest] @@ -783,7 +786,7 @@ public void ItemSerialization() } AssertSerializationRoundTrip( - @"{""type"":""message"",""potato_details"":{""cultivar"":""russet""},""role"":""potato""}", + @"{""type"":""message"",""role"":""potato"",""potato_details"":{""cultivar"":""russet""}}", potatoMessage => { Assert.That(potatoMessage.Role, Is.EqualTo(MessageRole.Unknown)); diff --git a/sdk/openai/Azure.AI.OpenAI/tests/Utils/AoaiTestBase.cs b/sdk/openai/Azure.AI.OpenAI/tests/Utils/AoaiTestBase.cs index 6a31103f41bf..304b5fc54a6d 100644 --- a/sdk/openai/Azure.AI.OpenAI/tests/Utils/AoaiTestBase.cs +++ b/sdk/openai/Azure.AI.OpenAI/tests/Utils/AoaiTestBase.cs @@ -53,7 +53,15 @@ public class AoaiTestBase : RecordedClientTestBase where TClient : clas public AzureTestEnvironment TestEnvironment { get; } - protected AoaiTestBase(bool isAsync) : this(isAsync, null, null) + private static RecordedTestMode? GetRecordedTestMode() => Environment.GetEnvironmentVariable("AZURE_TEST_MODE") switch + { + "Playback" => RecordedTestMode.Playback, + "Live" => RecordedTestMode.Live, + "Record" => RecordedTestMode.Record, + _ => null + }; + + protected AoaiTestBase(bool isAsync) : this(isAsync: isAsync, mode: GetRecordedTestMode(), automaticRecord: null) { } protected AoaiTestBase(bool isAsync, RecordedTestMode? mode = null, bool? automaticRecord = null) diff --git a/sdk/provisioning/Generator/src/Generator.csproj b/sdk/provisioning/Generator/src/Generator.csproj index 33cb230332f2..f7f1d0a448e6 100644 --- a/sdk/provisioning/Generator/src/Generator.csproj +++ b/sdk/provisioning/Generator/src/Generator.csproj @@ -1,6 +1,6 @@  - net8.0 + $(LtsTargetFramework) 1.0.0-beta.1 Exe enable diff --git a/sdk/servicebus/Microsoft.Azure.WebJobs.Extensions.ServiceBus/src/Microsoft.Azure.WebJobs.Extensions.ServiceBus.csproj b/sdk/servicebus/Microsoft.Azure.WebJobs.Extensions.ServiceBus/src/Microsoft.Azure.WebJobs.Extensions.ServiceBus.csproj index 350af107fff3..132c7b511a1f 100644 --- a/sdk/servicebus/Microsoft.Azure.WebJobs.Extensions.ServiceBus/src/Microsoft.Azure.WebJobs.Extensions.ServiceBus.csproj +++ b/sdk/servicebus/Microsoft.Azure.WebJobs.Extensions.ServiceBus/src/Microsoft.Azure.WebJobs.Extensions.ServiceBus.csproj @@ -1,7 +1,7 @@ - netstandard2.0;net8.0 + $(RequiredTargetFrameworks) Microsoft Azure WebJobs SDK ServiceBus Extension 5.18.0-beta.1 diff --git a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs/samples/functionapp/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs.Samples.Function.App.csproj b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs/samples/functionapp/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs.Samples.Function.App.csproj index 80809f079ab5..4c16119d830a 100644 --- a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs/samples/functionapp/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs.Samples.Function.App.csproj +++ b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs/samples/functionapp/Microsoft.Azure.WebJobs.Extensions.Storage.Blobs.Samples.Function.App.csproj @@ -1,6 +1,6 @@  - net8.0 + $(RequiredRunnableTargetFrameworks) $(RequiredTargetFrameworks) v3 diff --git a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/samples/functionapp/Microsoft.Azure.WebJobs.Extensions.Storage.Queues.Samples.Function.App.csproj b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/samples/functionapp/Microsoft.Azure.WebJobs.Extensions.Storage.Queues.Samples.Function.App.csproj index 36c3d6da5cb6..309d576cf28c 100644 --- a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/samples/functionapp/Microsoft.Azure.WebJobs.Extensions.Storage.Queues.Samples.Function.App.csproj +++ b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Queues/samples/functionapp/Microsoft.Azure.WebJobs.Extensions.Storage.Queues.Samples.Function.App.csproj @@ -1,6 +1,6 @@  - net8.0 + $(RequiredRunnableTargetFrameworks) $(RequiredTargetFrameworks) v3 diff --git a/sdk/timeseriesinsights/Azure.IoT.TimeSeriesInsights/samples/TimeSeriesInsightsClientSample/Azure.IoT.TimeSeriesInsights.Tests.ClientSample.csproj b/sdk/timeseriesinsights/Azure.IoT.TimeSeriesInsights/samples/TimeSeriesInsightsClientSample/Azure.IoT.TimeSeriesInsights.Tests.ClientSample.csproj index 5fbff05d77fa..11a0cd9780ba 100644 --- a/sdk/timeseriesinsights/Azure.IoT.TimeSeriesInsights/samples/TimeSeriesInsightsClientSample/Azure.IoT.TimeSeriesInsights.Tests.ClientSample.csproj +++ b/sdk/timeseriesinsights/Azure.IoT.TimeSeriesInsights/samples/TimeSeriesInsightsClientSample/Azure.IoT.TimeSeriesInsights.Tests.ClientSample.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + $(RequiredRunnableTargetFrameworks) true diff --git a/sdk/webpubsub/Microsoft.Azure.WebJobs.Extensions.WebPubSubForSocketIO/samples/SampleDev-JavaScript/extensions.csproj b/sdk/webpubsub/Microsoft.Azure.WebJobs.Extensions.WebPubSubForSocketIO/samples/SampleDev-JavaScript/extensions.csproj index f398f761fec4..be56d91526c7 100644 --- a/sdk/webpubsub/Microsoft.Azure.WebJobs.Extensions.WebPubSubForSocketIO/samples/SampleDev-JavaScript/extensions.csproj +++ b/sdk/webpubsub/Microsoft.Azure.WebJobs.Extensions.WebPubSubForSocketIO/samples/SampleDev-JavaScript/extensions.csproj @@ -1,6 +1,6 @@ - net8.0 + net10.0 true ** diff --git a/sdk/webpubsub/Microsoft.Azure.WebJobs.Extensions.WebPubSubForSocketIO/samples/SampleDev/SampleDev.csproj b/sdk/webpubsub/Microsoft.Azure.WebJobs.Extensions.WebPubSubForSocketIO/samples/SampleDev/SampleDev.csproj index bfa04271df02..6b5922854f0b 100644 --- a/sdk/webpubsub/Microsoft.Azure.WebJobs.Extensions.WebPubSubForSocketIO/samples/SampleDev/SampleDev.csproj +++ b/sdk/webpubsub/Microsoft.Azure.WebJobs.Extensions.WebPubSubForSocketIO/samples/SampleDev/SampleDev.csproj @@ -1,6 +1,6 @@ - net8.0 + net10.0 v4 <_FunctionsSkipCleanOutput>true true diff --git a/sdk/webpubsub/Microsoft.Azure.WebPubSub.AspNetCore/src/Microsoft.Azure.WebPubSub.AspNetCore.csproj b/sdk/webpubsub/Microsoft.Azure.WebPubSub.AspNetCore/src/Microsoft.Azure.WebPubSub.AspNetCore.csproj index b354ba2a1dc2..54817f6e7090 100644 --- a/sdk/webpubsub/Microsoft.Azure.WebPubSub.AspNetCore/src/Microsoft.Azure.WebPubSub.AspNetCore.csproj +++ b/sdk/webpubsub/Microsoft.Azure.WebPubSub.AspNetCore/src/Microsoft.Azure.WebPubSub.AspNetCore.csproj @@ -6,11 +6,10 @@ 1.5.0 Azure, WebPubSub - net8.0 + $(RequiredRunnableTargetFrameworks) $(RequiredTargetFrameworks) $(NoWarn);419 true - net8.0 true